コード例 #1
0
JNIEXPORT void JNICALL
Java_netscape_javascript_JSObject_removeMember(JNIEnv* env,
                                               jobject java_wrapper_obj,
                                               jstring property_name_jstr)
{
    if (property_name_jstr == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name");
        return;
    }

    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return;
    }
#endif

    /* Get the Unicode string for the JS property name */
    jboolean is_copy;
    const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy);
    jsize property_name_len = env->GetStringLength(property_name_jstr);

    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    RemoveMemberMessage msg(pluginInstance, js_obj, property_name_ucs2, property_name_len);
    
    sendMessage(env, &msg);
    
    env->ReleaseStringChars(property_name_jstr, property_name_ucs2);
}
コード例 #2
0
ファイル: WordObject.cpp プロジェクト: killbug2004/WSProf
HRESULT CWordObject::GetWordObject(bool bUsingCurrentInstance)
{
	HRESULT hRes = E_FAIL;

	LPUNKNOWN lpUnk = GetWordInstanceFromGit();
	if (lpUnk != NULL)
	{
		if (m_pUnknown != NULL && m_pUnknown != lpUnk )
		{
			m_pUnknown->Release();			
		}

		m_pUnknown = lpUnk;
	}

	if (m_pUnknown != NULL) 
		return S_OK;

	m_bUsingCurrentInstance = bUsingCurrentInstance;

	if (bUsingCurrentInstance)
	{
		LOG_WS_INFO(_T("Using Current Instance of Word"));
		hRes = GetCurrentInstance();
	}

	if (FAILED(hRes))
		m_pUnknown = CreateAppInstance();		
	else if (S_FALSE == hRes)
		m_pUnknown = CreateDocInstance();
	
	if (NULL != m_pUnknown)
		hRes = S_OK;
	if (S_OK == hRes)
	{
		m_pStrUnknown = m_pWordCreator->MarshallInterface(IID_IUnknown, m_pUnknown);
		
		if (NULL == m_pStrUnknown)
		{
			LOG_WS_ERROR(_T("Call to MarshallInterface returned NULL pointer"));
			hRes = E_FAIL;
		}
	}
	
	return hRes;
}
コード例 #3
0
static PRUint32 getJavaScriptThread(JNIEnv* env)
{
    PRUint32 threadID = 0;
    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
    if (pluginInstance != NULL) {
        nsIPluginInstancePeer* peer;
        if (pluginInstance->GetPeer(&peer) == NS_OK) {
            nsIPluginInstancePeer2* peer2 = NULL;
            if (peer->QueryInterface(NS_GET_IID(nsIPluginInstancePeer2), (void **)&peer2) == NS_OK) {
                if (peer2->GetJSThread(&threadID) != NS_OK)
                    threadID = 0;
                NS_RELEASE(peer2);
            }
            NS_RELEASE(peer);
        }
    }
    return threadID;
}
コード例 #4
0
JNIEXPORT jobject JNICALL
Java_netscape_javascript_JSObject_eval(JNIEnv* env,
                                       jobject java_wrapper_obj,
                                       jstring script_jstr)
{
    /* Get the Unicode string for the JS function name */
    if (script_jstr == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null script string");
        return NULL;
    }
    jboolean is_copy;
    const jchar* script_ucs2 = env->GetStringChars(script_jstr, &is_copy);
    jsize script_len = env->GetStringLength(script_jstr);

    /* unwrap the JS object from the Java object. */
    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    jobject jresult = NULL;
    
#ifdef MRJPLUGIN_4X
    nsresult status = theLiveConnectManager->Eval(env, js_obj, script_ucs2, script_len, NULL, 0, NULL, &jresult);
#else
    /* determine the plugin instance so we can obtain its codebase. */
    // beard: should file a bug with Apple that JMJNIToAWTContext doesn't work.
    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return NULL;
    }
#endif

    EvalMessage msg(pluginInstance, js_obj, script_ucs2, script_len, &jresult);
    sendMessage(env, &msg);
    
    if (jresult != NULL)
        jresult = ToLocalRef(env, jresult);
    
#endif

    env->ReleaseStringChars(script_jstr, script_ucs2);

    return jresult;
}
コード例 #5
0
JNIEXPORT void JNICALL
Java_netscape_javascript_JSObject_setSlot(JNIEnv* env,
                                          jobject java_wrapper_obj,
                                          jint slot,
                                          jobject java_obj)
{
    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return;
    }
#endif

    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    java_obj = ToGlobalRef(env, java_obj);
    
    SetSlotMessage msg(pluginInstance, js_obj, slot, java_obj);
    sendMessage(env, &msg);
    env->DeleteGlobalRef(java_obj);
}
コード例 #6
0
JNIEXPORT jstring JNICALL
Java_netscape_javascript_JSObject_toString(JNIEnv* env, jobject java_wrapper_obj)
{
    /* unwrap the JS object from the Java object. */
    jstring jresult = NULL;
    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);

    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return NULL;
    }
#endif

    ToStringMessage msg(pluginInstance, js_obj, &jresult);
    sendMessage(env, &msg);
    
    if (jresult != NULL)
        jresult = (jstring) ToLocalRef(env, jresult);
    
    return jresult;
}
コード例 #7
0
JNIEXPORT jobject JNICALL
Java_netscape_javascript_JSObject_getMember(JNIEnv* env,
                                            jobject java_wrapper_obj,
                                            jstring property_name_jstr)
{
    if (property_name_jstr == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null member name");
        return NULL;
    }

    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return NULL;
    }
#endif

    /* Get the Unicode string for the JS property name */
    jboolean is_copy;
    const jchar* property_name_ucs2 = env->GetStringChars(property_name_jstr, &is_copy);
    jsize property_name_len = env->GetStringLength(property_name_jstr);

    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    jobject member = NULL;

    GetMemberMessage msg(pluginInstance, js_obj, property_name_ucs2, property_name_len, &member);
    sendMessage(env, &msg);

    // convert the resulting reference back to a local reference.
    if (member != NULL)
        member = ToLocalRef(env, member);
    
    env->ReleaseStringChars(property_name_jstr, property_name_ucs2);

    return member;
}
コード例 #8
0
JNIEXPORT jobject JNICALL
Java_netscape_javascript_JSObject_call(JNIEnv* env, jobject java_wrapper_obj,
                                       jstring function_name_jstr, jobjectArray java_args)
{
    if (function_name_jstr == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal null function name");
        return NULL;
    }

    /* Try to determine which plugin instance is responsible for this thread. This is done by checking class loaders. */
    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return NULL;
    }
#endif

    /* Get the Unicode string for the JS function name */
    jboolean is_copy;
    const jchar* function_name_ucs2 = env->GetStringChars(function_name_jstr, &is_copy);
    jsize function_name_len = env->GetStringLength(function_name_jstr);

    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    jobject jresult = NULL;

    CallMessage msg(pluginInstance, js_obj, function_name_ucs2, function_name_len, java_args, &jresult);
    sendMessage(env, &msg);

    env->ReleaseStringChars(function_name_jstr, function_name_ucs2);

    if (jresult != NULL)
        jresult = ToLocalRef(env, jresult);

    return jresult;
}
コード例 #9
0
JNIEXPORT jobject JNICALL
Java_netscape_javascript_JSObject_getSlot(JNIEnv* env,
                                          jobject java_wrapper_obj,
                                          jint slot)
{
    MRJPluginInstance* pluginInstance = GetCurrentInstance(env);
#if 0
    if (pluginInstance == NULL) {
        env->ThrowNew(env->FindClass("java/lang/NullPointerException"), "illegal JNIEnv (can't find plugin)");
        return NULL;
    }
#endif

    jsobject js_obj = Unwrap_JSObject(env, java_wrapper_obj);
    jobject member = NULL;
    
    GetSlotMessage msg(pluginInstance, js_obj, slot, &member);
    sendMessage(env, &msg);
    
    // convert the resulting reference back to a local reference.
    if (member != NULL)
        member = ToLocalRef(env, member);
    return member;
}