diff --git a/jscore/jscore.pyx b/jscore/jscore.pyx index cbd41cf..a16297d 100644 --- a/jscore/jscore.pyx +++ b/jscore/jscore.pyx @@ -50,6 +50,7 @@ cdef extern from "JavaScriptCore/JavaScript.h": cdef JSGlobalContextRef JSGlobalContextCreate(JSClassRef globalObjectClass) cdef JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) + cdef void JSGlobalContextRelease(JSGlobalContextRef ctx) ctypedef unsigned short JSChar cdef JSStringRef JSStringCreateWithUTF8CString(const_char_ptr string) @@ -191,6 +192,11 @@ cdef class GlobalContext(Context): def __init__(self): self.ctx = JSGlobalContextCreate(NULL) + def __dealloc__(self): + cdef JSGlobalContextRef ctx = self.ctx + JSGlobalContextRelease(ctx) + JSGarbageCollect(self.ctx) + cdef class _Value cdef _value_load(Context ctx, JSValueRef value):