@@ -46,7 +46,7 @@ struct CFunc
4646 Retrieves functions from metatables and properties from propget tables.
4747 Looks through the class hierarchy if inheritance is present.
4848 */
49- static int indexMetaMethod (lua_State* L)
49+ static int indexMetaMethod (lua_State* L) noexcept
5050 {
5151 assert (lua_istable (L, 1 ) ||
5252 lua_isuserdata (L, 1 )); // Stack (further not shown): table | userdata, name
@@ -112,16 +112,22 @@ struct CFunc
112112 __newindex metamethod for namespace or class static members.
113113 Retrieves properties from propset tables.
114114 */
115- static int newindexStaticMetaMethod (lua_State* L) { return newindexMetaMethod (L, false ); }
115+ static int newindexStaticMetaMethod (lua_State* L) noexcept
116+ {
117+ return newindexMetaMethod (L, false );
118+ }
116119
117120 // ----------------------------------------------------------------------------
118121 /* *
119122 __newindex metamethod for non-static members.
120123 Retrieves properties from propset tables.
121124 */
122- static int newindexObjectMetaMethod (lua_State* L) { return newindexMetaMethod (L, true ); }
125+ static int newindexObjectMetaMethod (lua_State* L) noexcept
126+ {
127+ return newindexMetaMethod (L, true );
128+ }
123129
124- static int newindexMetaMethod (lua_State* L, bool pushSelf)
130+ static int newindexMetaMethod (lua_State* L, bool pushSelf) noexcept
125131 {
126132 assert (
127133 lua_istable (L, 1 ) ||
@@ -183,13 +189,18 @@ struct CFunc
183189
184190 The name of the variable is in the first upvalue.
185191 */
186- static int readOnlyError (lua_State* L)
192+ static int readOnlyError (lua_State* L) noexcept
187193 {
188- std::string s;
189-
190- s = s + " '" + lua_tostring (L, lua_upvalueindex (1 )) + " ' is read-only" ;
191-
192- return luaL_error (L, s.c_str ());
194+ try
195+ {
196+ std::string s;
197+ s = s + " '" + lua_tostring (L, lua_upvalueindex (1 )) + " ' is read-only" ;
198+ return luaL_error (L, s.c_str ());
199+ }
200+ catch (...)
201+ {
202+ return luaL_error (L, " Property is read-only" );
203+ }
193204 }
194205
195206 // ----------------------------------------------------------------------------
@@ -308,7 +319,7 @@ struct CFunc
308319 static int f (lua_State* L)
309320 {
310321 assert (isfulluserdata (L, lua_upvalueindex (1 )));
311- typedef int (T::*MFP)(lua_State * L);
322+ typedef int (T::*MFP)(lua_State* L);
312323 T* const t = Userdata::get<T>(L, 1 , false );
313324 MFP const & fnptr = *static_cast <MFP const *>(lua_touserdata (L, lua_upvalueindex (1 )));
314325 assert (fnptr != 0 );
@@ -322,7 +333,7 @@ struct CFunc
322333 static int f (lua_State* L)
323334 {
324335 assert (isfulluserdata (L, lua_upvalueindex (1 )));
325- typedef int (T::*MFP)(lua_State * L);
336+ typedef int (T::*MFP)(lua_State* L);
326337 T const * const t = Userdata::get<T>(L, 1 , true );
327338 MFP const & fnptr = *static_cast <MFP const *>(lua_touserdata (L, lua_upvalueindex (1 )));
328339 assert (fnptr != 0 );
0 commit comments