| 35 | |
| 36 | template <typename Cls> |
| 37 | static duk_ret_t managed_finalizer(duk_context* ctx) |
| 38 | { |
| 39 | duk_get_prop_string(ctx, 0, "\xFF" "obj_ptr"); |
| 40 | Cls* obj = (Cls*) duk_require_pointer(ctx, -1); |
| 41 | duk_pop(ctx); // pop obj_ptr |
| 42 | |
| 43 | if (obj != NULL) { |
| 44 | delete obj; |
| 45 | |
| 46 | // for safety, set the pointer to undefined |
| 47 | duk_push_undefined(ctx); |
| 48 | duk_put_prop_string(ctx, 0, "\xFF" "obj_ptr"); |
| 49 | } |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | template<typename Cls> |
| 55 | static duk_ret_t call_native_deleter(duk_context* ctx) |
nothing calls this directly
no outgoing calls
no test coverage detected