| 955 | }; |
| 956 | |
| 957 | static int lua_java_instance_index(lua_State* L) { |
| 958 | const char* key = luaL_checkstring(L, 2); |
| 959 | if (strcmp(key, "raw") == 0) { |
| 960 | jobject* ud = (jobject*)lua_touserdata(L, 1); |
| 961 | if (*ud) { |
| 962 | JNIEnv* env = get_jni_env(); |
| 963 | if (env) { |
| 964 | void* raw = jni_ref_to_raw_ptr(env, *ud); |
| 965 | lua_pushinteger(L, (lua_Integer)(uintptr_t)raw); |
| 966 | } else { |
| 967 | lua_pushinteger(L, (lua_Integer)(uintptr_t)*ud); |
| 968 | } |
| 969 | } else { |
| 970 | lua_pushinteger(L, 0); |
| 971 | } |
| 972 | return 1; |
| 973 | } |
| 974 | if (strcmp(key, "call") == 0) { |
| 975 | lua_pushcfunction(L, lua_java_call_instance); |
| 976 | return 1; |
| 977 | } |
| 978 | lua_pushnil(L); |
| 979 | return 1; |
| 980 | } |
| 981 | |
| 982 | static const luaL_Reg java_instance_methods[] = { |
| 983 | {"__gc", lua_java_instance_gc}, |
nothing calls this directly
no test coverage detected