MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / set_instance_value

Function set_instance_value

Source/Misc/luabind/src/object_rep.cpp:101–152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99 {
100
101 int set_instance_value(lua_State* L)
102 {
103 lua_getuservalue(L, 1);
104 lua_pushvalue(L, 2);
105 lua_rawget(L, -2);
106
107 if (lua_isnil(L, -1) && lua_getmetatable(L, -2))
108 {
109 lua_pushvalue(L, 2);
110 lua_rawget(L, -2);
111 lua_replace(L, -3);
112 lua_pop(L, 1);
113 }
114
115 if (lua_tocfunction(L, -1) == &property_tag && lua_tocfunction(L, 3) != &property_tag)
116 {
117 // this member is a property, extract the "set" function and call it.
118 lua_getupvalue(L, -1, 2);
119
120 if (lua_isnil(L, -1))
121 {
122 lua_pushfstring(L, "property '%s' is read only", lua_tostring(L, 2));
123 lua_error(L);
124 }
125
126 lua_pushvalue(L, 1);
127 lua_pushvalue(L, 3);
128 lua_call(L, 2, 0);
129 return 0;
130 }
131
132 lua_pop(L, 1);
133
134 if (!lua_getmetatable(L, 4))
135 {
136 lua_newtable(L);
137 lua_pushvalue(L, -1);
138 lua_setuservalue(L, 1);
139 lua_pushvalue(L, 4);
140 lua_setmetatable(L, -2);
141 }
142 else
143 {
144 lua_pop(L, 1);
145 }
146
147 lua_pushvalue(L, 2);
148 lua_pushvalue(L, 3);
149 lua_rawset(L, -3);
150
151 return 0;
152 }
153
154 int get_instance_value(lua_State* L)
155 {

Callers

nothing calls this directly

Calls 11

lua_pushvalueFunction · 0.85
lua_rawgetFunction · 0.85
lua_getmetatableFunction · 0.85
lua_replaceFunction · 0.85
lua_tocfunctionFunction · 0.85
lua_getupvalueFunction · 0.85
lua_pushfstringFunction · 0.85
lua_errorFunction · 0.85
lua_callFunction · 0.85
lua_setmetatableFunction · 0.85
lua_rawsetFunction · 0.85

Tested by

no test coverage detected