示例#1
0
JSClassRef AccessibilityController::getJSClass()
{
    static JSStaticFunction staticFunctions[] = {
        { "logFocusEvents", logFocusEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "logValueChangeEvents", logValueChangeEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "logScrollingStartEvents", logScrollingStartEventsCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "elementAtPoint", getElementAtPointCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0 }
    };

    static JSStaticValue staticValues[] = {
        { "focusedElement", getFocusedElementCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "rootElement", getRootElementCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0, 0 }
    };

    static JSClassDefinition classDefinition = {
        0, kJSClassAttributeNone, "AccessibilityController", 0, staticValues, staticFunctions,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };

    static JSClassRef ref = 0;
    if (!ref)
        ref = JSClassCreate(&classDefinition);
    else
        JSClassRetain(ref);

    return ref;
}
void JSCallbackConstructor::finishCreation(JSGlobalObject* globalObject, JSClassRef jsClass)
{
    Base::finishCreation(globalObject->vm());
    ASSERT(inherits(info()));
    if (m_class)
        JSClassRetain(jsClass);
}
JSCallbackConstructor::JSCallbackConstructor(ExecState* exec, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
    : JSObject(exec->lexicalGlobalObject()->objectPrototype())
    , m_class(jsClass)
    , m_callback(callback)
{
    if (m_class)
        JSClassRetain(jsClass);
}
JSCallbackConstructor::JSCallbackConstructor(PassRefPtr<Structure> structure, JSClassRef jsClass, JSObjectCallAsConstructorCallback callback)
    : JSObject(structure)
    , m_class(jsClass)
    , m_callback(callback)
{
    if (m_class)
        JSClassRetain(jsClass);
}
JNIEXPORT jintLong JNICALL WebKit_win32_NATIVE(JSClassRetain)
	(JNIEnv *env, jclass that, jintLong arg0)
{
	jintLong rc = 0;
	WebKit_win32_NATIVE_ENTER(env, that, JSClassRetain_FUNC);
	rc = (jintLong)JSClassRetain((JSClassRef)arg0);
	WebKit_win32_NATIVE_EXIT(env, that, JSClassRetain_FUNC);
	return rc;
}
示例#6
0
JSClassDefinition *
seed_get_signal_class (void)
{
  JSClassDefinition signal_holder = kJSClassDefinitionEmpty;

  signal_holder.className = "gobject_signals";
  signal_holder.getProperty = seed_signal_holder_get_property;
  signal_holder.staticFunctions = signal_holder_static_functions;
  signal_holder_class = JSClassCreate (&signal_holder);
  JSClassRetain (signal_holder_class);

  return &gobject_signal_def;
}
JSClassRef CreateClassForJava_android_os_Bundle()
{
    static bool init;
    if (!init)
    {
        init = true;
        
        ClassDefinitionForJava_android_os_Bundle = kJSClassDefinitionEmpty;
        ClassDefinitionForJava_android_os_Bundle.className = "Activity";
        ClassDefinitionForJava_android_os_Bundle.finalize = FinalizerForJava_android_os_Bundle;
        ClassDefinitionForJava_android_os_Bundle.parentClass = CreateClassConstructorForJava_java_lang_Object();
        ClassRefForJava_android_os_Bundle = JSClassCreate(&ClassDefinitionForJava_android_os_Bundle);
        
        JSClassRetain(ClassRefForJava_android_os_Bundle);
    }
    return ClassRefForJava_android_os_Bundle;
}
JSClassRef CreateClassConstructorForJava_android_view_Gravity ()
{
    static bool init;
    if (!init)
    {
        init = true;
        
        ClassDefinitionConstructorForJava_android_view_Gravity = kJSClassDefinitionEmpty;
        ClassDefinitionConstructorForJava_android_view_Gravity.className = "Gravity";
        ClassDefinitionConstructorForJava_android_view_Gravity.staticValues = StaticValueArrayForJava_android_view_Gravity;
        
        ClassDefinitionConstructorForJava_android_view_Gravity.parentClass = CreateClassConstructorForJava_java_lang_Object();
        ClassRefConstructorForJava_android_view_Gravity = JSClassCreate(&ClassDefinitionConstructorForJava_android_view_Gravity);
        
        JSClassRetain(ClassRefConstructorForJava_android_view_Gravity);
    }
    return ClassRefConstructorForJava_android_view_Gravity;
}
示例#9
0
/**
 * called to get the JSClassRef for JSBuffer class
 */
JSClassRef CreateClassForJSBuffer ()
{
    static bool init;
    if (!init)
    {
        init = true;

        ClassDefinitionForJSBuffer = kJSClassDefinitionEmpty;
        ClassDefinitionForJSBuffer.staticValues = StaticValueArrayForJSBuffer;
        ClassDefinitionForJSBuffer.staticFunctions = StaticFunctionArrayForJSBuffer;
        ClassDefinitionForJSBuffer.initialize = InitializerForJSBuffer;
        ClassDefinitionForJSBuffer.finalize = FinalizerForJSBuffer;
        ClassDefinitionForJSBuffer.className = "JSBuffer";

        JSBufferClassDef = JSClassCreate(&ClassDefinitionForJSBuffer);

        JSClassRetain(JSBufferClassDef);
    }
    return JSBufferClassDef;
}
示例#10
0
/**
 * called to get the JSClassRef for JSBuffer class
 */
JSClassRef CreateClassForJSBufferConstructor ()
{
    static bool init;
    if (!init)
    {
        init = true;

        ClassDefinitionForJSBufferConstructor = kJSClassDefinitionEmpty;
        ClassDefinitionForJSBufferConstructor.staticValues = StaticValueArrayForJSBuffer;
        ClassDefinitionForJSBufferConstructor.callAsConstructor = MakeInstanceForJSBuffer;
        ClassDefinitionForJSBufferConstructor.callAsFunction = MakeInstanceFromFunctionForJSBuffer;
        ClassDefinitionForJSBufferConstructor.className = "JSBufferConstructor";


        JSBufferClassDefForConstructor = JSClassCreate(&ClassDefinitionForJSBufferConstructor);

        JSClassRetain(JSBufferClassDefForConstructor);

    }
    return JSBufferClassDefForConstructor;
}
示例#11
0
JSClassRef GCController::getJSClass()
{
    static JSStaticFunction staticFunctions[] = {
        { "collect", collectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "collectOnAlternateThread", collectOnAlternateThreadCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { "getJSObjectCount", getJSObjectCountCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
        { 0, 0, 0 }
    };

    static JSClassDefinition classDefinition = {
        0, kJSClassAttributeNone, "GCController", 0, 0, staticFunctions,
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
    };

    static JSClassRef ref = 0;
    if (!ref)
        ref = JSClassCreate(&classDefinition);
    else
        JSClassRetain(ref);

    return ref;
}
示例#12
0
文件: ns.cpp 项目: danilocesar/gwkjs
static JSObjectRef
ns_new(JSContextRef context,
       const char   *ns_name)
{
    Ns *priv = NULL;
    JSObjectRef ret = NULL;
    JSObjectRef global = NULL;
    gboolean found = FALSE;
    JSObjectRef proto = NULL;
    JSValueRef exception = NULL;

    // XXX: NOT THREAD SAFE?
    if (!gwkjs_ns_class_ref) {
        gwkjs_ns_class_ref = JSClassCreate(&gwkjs_ns_class);
        JSClassRetain(gwkjs_ns_class_ref);
    }

    global = gwkjs_get_import_global(context);
    if (!(found = gwkjs_object_has_property(context,
                                            global,
                                            gwkjs_ns_class.className))) {
        proto = JSObjectMake(context,
                             gwkjs_ns_class_ref,
                             NULL);

        gwkjs_object_set_property(context, global,
                                  gwkjs_ns_class.className,
                                  proto,
                                  GWKJS_PROTO_PROP_FLAGS,
                                  &exception);

        if (exception)
           g_error("Can't init class %s", gwkjs_ns_class.className);

        gwkjs_debug(GWKJS_DEBUG_IMPORTER, "Initialized class %s prototype %p",
                    gwkjs_ns_class.className, proto);
    } else {
        JSValueRef proto_val = gwkjs_object_get_property(context,
                                                         global,
                                                         gwkjs_ns_class.className,
                                                         &exception);

        if (exception || proto_val == NULL || !JSValueIsObject(context, proto_val))
            g_error("Can't get protoType for class %s", gwkjs_ns_class.className);

        proto = JSValueToObject(context, proto_val, NULL);
    }
    g_assert(proto != NULL);

    ret = JSObjectMake(context, gwkjs_ns_class_ref, NULL);

    if (ret == NULL)
        return ret;

    JSObjectSetPrototype(context, ret, proto);

    priv = g_slice_new0(Ns);
    GWKJS_INC_COUNTER(ns);
    
    g_assert(priv_from_js(ret) == NULL);
    JSObjectSetPrivate(ret, priv);

    gwkjs_debug_lifecycle(GWKJS_DEBUG_GNAMESPACE, "ns constructor, obj %p priv %p", ret, priv);

    priv = priv_from_js(ret);
    priv->modules = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);

    priv->gi_namespace = g_strdup(ns_name);
    return ret;
}