def anytype_variable_set(variable, ctype): refvar = variable if not variable.ctype.is_pointer() and not variable.ctype.is_reference(): return 'lua_pushlightuserdata(L, %s)' % (cpp.cpp_cast(cpp.cpp_type('void', pointer=True), 'new {}({})'.format(variable.ctype.name, variable.name))) return 'lua_pushlightuserdata(L, %s)' % (refvar.cast(cpp.cpp_cast, cpp.cpp_type('void', pointer=True)))
def cpp_unique_ptr_to_target(variable, ctype): return 'lua_pushlightuserdata(L, %s)' % (cpp.cpp_cast(cpp.cpp_type('void', pointer=True), 'new {}(std::move({}))'.format(variable.ctype.name, variable.name)))