当前位置: 首页>>代码示例>>C++>>正文


C++ JNU_GetEnv函数代码示例

本文整理汇总了C++中JNU_GetEnv函数的典型用法代码示例。如果您正苦于以下问题:C++ JNU_GetEnv函数的具体用法?C++ JNU_GetEnv怎么用?C++ JNU_GetEnv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了JNU_GetEnv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: JNU_GetEnv

uint32 JavaInputStream::read(void *dataPtr, uint32 dataSize) {
	JNIEnv* env = JNU_GetEnv();

	if (_buflen < dataSize) {
		_buflen = dataSize;
		env->DeleteGlobalRef(_buf);
		_buf = static_cast<jbyteArray>(env->NewGlobalRef(env->NewByteArray(_buflen)));
	}

	jint ret = env->CallIntMethod(_input_stream, MID_read, _buf, 0, dataSize);
	if (env->ExceptionCheck()) {
		warning("Exception during JavaInputStream::read(%p, %d)",
				dataPtr, dataSize);
		env->ExceptionDescribe();
		env->ExceptionClear();
		_err = true;
		ret = -1;
	} else if (ret == -1) {
		_eos = true;
		ret = 0;
	} else {
		env->GetByteArrayRegion(_buf, 0, ret, static_cast<jbyte*>(dataPtr));
		_pos += ret;
	}
	return ret;
}
开发者ID:MatChung,项目名称:scummvm-ps3,代码行数:26,代码来源:asset-archive.cpp

示例2: DASSERT

//
// (static)
// Switches to Windows thread via SendMessage and synchronously
// calls AwtObject::WinThreadExecProc with the given command id
// and parameters.
//
// Useful for writing code that needs to be synchronized with
// what's happening on the Windows thread.
//
LRESULT AwtObject::WinThreadExec(
    jobject                             peerObject,
    UINT                                cmdId,
    LPARAM                              param1,
    LPARAM                              param2,
    LPARAM                              param3,
    LPARAM                              param4 )
{
    DASSERT( peerObject != NULL);

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    // since we pass peerObject to another thread we must
    //   make a global ref
    jobject peerObjectGlobalRef = env->NewGlobalRef(peerObject);

    ExecuteArgs         args;
    LRESULT         retVal;

    // setup arguments
    args.cmdId = cmdId;
    args.param1 = param1;
    args.param2 = param2;
    args.param3 = param3;
    args.param4 = param4;

    // call WinThreadExecProc on the toolkit thread
    retVal = AwtToolkit::GetInstance().SendMessage(WM_AWT_EXECUTE_SYNC,
                                                   (WPARAM)peerObjectGlobalRef,
                                                   (LPARAM)&args);
    return retVal;
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:40,代码来源:awt_Object.cpp

示例3: _SetScrollPos

void AwtScrollPane::_SetScrollPos(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    SetScrollPosStruct *spss = (SetScrollPosStruct *)param;
    jobject self = spss->scrollpane;
    jint x = spss->x;
    jint y = spss->y;

    AwtScrollPane *s = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(self, ret);
    s = (AwtScrollPane *)pData;
    if (::IsWindow(s->GetHWnd()))
    {
        DTRACE_PRINTLN3("%x: WScrollPanePeer.setScrollPosition(%d, %d)", self, x, y);
        SCROLLINFO si;
        ZeroMemory(&si, sizeof(si));
        si.fMask = SIF_POS;
        si.cbSize = sizeof(si);
        // set x
        si.nPos = x;
        ::SetScrollInfo(s->GetHWnd(), SB_HORZ, &si, TRUE);
        // set y
        si.nPos = y;
        ::SetScrollInfo(s->GetHWnd(), SB_VERT, &si, TRUE);
    }
ret:
   env->DeleteGlobalRef(self);

   delete spss;
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:33,代码来源:awt_ScrollPane.cpp

示例4: GetTarget

/* Execute a callback to the associated Java peer. */
void
AwtObject::DoCallback(const char* methodName, const char* methodSig, ...)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    /* don't callback during the create & initialization process */
    if (m_peerObject != NULL && m_callbacksEnabled) {
        va_list args;
        va_start(args, methodSig);
#ifdef DEBUG
        if (reportEvents) {
            jstring targetStr =
                (jstring)JNU_CallMethodByName(env, NULL, GetTarget(env),
                                              "getName",
                                              "()Ljava/lang/String;").l;
            DASSERT(!safe_ExceptionOccurred(env));
            printf("Posting %s%s method to %S\n", methodName, methodSig,
                   TO_WSTRING(targetStr));
        }
#endif
        /* caching would do much good here */
        JNU_CallMethodByNameV(env, NULL, GetPeer(env),
                              methodName, methodSig, args);
        {
            jthrowable exc = safe_ExceptionOccurred(env);
            if (exc) {
                env->DeleteLocalRef(exc);
                env->ExceptionDescribe();
                env->ExceptionClear();
            }
        }
        DASSERT(!safe_ExceptionOccurred(env));
        va_end(args);
    }
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:36,代码来源:awt_Object.cpp

示例5: HandleEvent

MsgRouting AwtCanvas::HandleEvent(MSG *msg, BOOL synthetic)
{
    if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) {
        /*
         * Fix for BugTraq ID 4041703: keyDown not being invoked.
         * Give the focus to a Canvas or Panel if it doesn't have heavyweight
         * subcomponents so that they will behave the same way as on Solaris
         * providing a possibility of giving keyboard focus to an empty Applet.
         * Since ScrollPane doesn't receive focus on mouse press on Solaris,
         * HandleEvent() is overriden there to do nothing with focus.
         */
        if (AwtComponent::sm_focusOwner != GetHWnd() &&
            ::GetWindow(GetHWnd(), GW_CHILD) == NULL)
        {
            JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
            jobject target = GetTarget(env);
            env->CallStaticVoidMethod
                (AwtKeyboardFocusManager::keyboardFocusManagerCls,
                 AwtKeyboardFocusManager::heavyweightButtonDownMID,
                 target, ((jlong)msg->time) & 0xFFFFFFFF);
            env->DeleteLocalRef(target);
            AwtSetFocus();
        }
    }
    return AwtComponent::HandleEvent(msg, synthetic);
}
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:26,代码来源:awt_Canvas.cpp

示例6: JNU_GetEnv

NS_IMETHODIMP
EmbedEventListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
{
    if (!aMouseEvent)
	return NS_OK;
    // return FALSE to this function to mark this event as not
    // consumed...
    PRBool return_val = PR_FALSE;

    JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
    ::util_StoreIntoPropertiesObject(env, mProperties,  CLICK_COUNT_KEY,
                                     TWO_VALUE, (jobject) 
                                     &(mOwner->GetWrapperFactory()->shareContext));

    util_SendEventToJava(nsnull, 
                         mEventRegistration, 
                         MOUSE_LISTENER_CLASSNAME,
                         DOMMouseListener_maskValues[MOUSE_DOUBLE_CLICK_EVENT_MASK], 
                         mProperties);

    if (return_val) {
	aMouseEvent->StopPropagation();
	aMouseEvent->PreventDefault();
    }
    return NS_OK;
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:26,代码来源:EmbedEventListener.cpp

示例7:

// static
void D3DPipelineManager::NotifyAdapterEventListeners(UINT adapter,
                                                     jint eventType)
{
    HMONITOR hMon;
    int gdiScreen;
    D3DPipelineManager *pMgr;

    // fix for 6946559: if d3d preloading fails jmv may be NULL
    if (jvm == NULL) {
        return;
    }

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    RETURN_IF_NULL(env);

    pMgr = D3DPipelineManager::GetInstance();
    RETURN_IF_NULL(pMgr);
    hMon = pMgr->pd3d9->GetAdapterMonitor(adapter);

    /*
     * If we don't have devices initialized yet, no sense to clear them.
     */
    if (!Devices::GetInstance()){
         return;
    }

    gdiScreen = AwtWin32GraphicsDevice::GetScreenFromHMONITOR(hMon);

    JNU_CallStaticMethodByName(env, NULL,
        "sun/java2d/pipe/hw/AccelDeviceEventNotifier",
        "eventOccured", "(II)V",
        gdiScreen, eventType);
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:34,代码来源:D3DPipelineManager.cpp

示例8: DASSERT

//
// utility function to get the C++ object from the Java one
//
// (static)
AwtRobot * AwtRobot::GetRobot( jobject self )
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    AwtRobot * robot = (AwtRobot *)JNI_GET_PDATA(self);
    DASSERT( !::IsBadWritePtr( robot, sizeof(AwtRobot)));
    return robot;
}
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:11,代码来源:awt_Robot.cpp

示例9: DASSERT

//
// (static)
// Switches to Windows thread via SendMessage and synchronously
// calls AwtObject::WinThreadExecProc with the given command id
// and parameters.
//
// Useful for writing code that needs to be synchronized with
// what's happening on the Windows thread.
//
LRESULT AwtObject::WinThreadExec(
    jobject			 	peerObject,
    UINT				cmdId,
    LPARAM 				param1,
    LPARAM 				param2,
    LPARAM 				param3,
    LPARAM 				param4 )
{
    DASSERT( peerObject != NULL);

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    AwtObject* object = (AwtObject *)JNI_GET_PDATA(peerObject);
    DASSERT( !IsBadReadPtr(object, sizeof(AwtObject)) );

    ExecuteArgs		args;
    LRESULT         retVal;

    // setup arguments
    args.cmdId = cmdId;
    args.param1 = param1;
    args.param2 = param2;
    args.param3 = param3;
    args.param4 = param4;

    // call WinThreadExecProc on the toolkit thread
    retVal = AwtToolkit::GetInstance().SendMessage(WM_AWT_EXECUTE_SYNC,
						   (WPARAM)object,
						   (LPARAM)&args);
    return retVal;
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:39,代码来源:awt_Object.cpp

示例10: FileDialogWndProc

LRESULT CALLBACK FileDialogWndProc(HWND hWnd, UINT message,
                                        WPARAM wParam, LPARAM lParam)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    switch (message) {
        case WM_COMMAND: {
            if (LOWORD(wParam) == IDCANCEL)
            {
                // Unlike Print/Page dialogs, we only handle IDCANCEL here and
                // don't handle IDOK. This is because user can press OK button
                // when no file is selected, and the dialog is not closed. So
                // OK button is handled in the CDN_FILEOK notification handler
                // (see FileDialogHookProc below)
                jobject peer = (jobject)(::GetProp(hWnd, ModalDialogPeerProp));
                env->CallVoidMethod(peer, AwtFileDialog::setHWndMID, (jlong)0);
            }
            break;
        }
        case WM_SETICON: {
            return 0;
        }
    }

    WNDPROC lpfnWndProc = (WNDPROC)(::GetProp(hWnd, NativeDialogWndProcProp));
    return ComCtl32Util::GetInstance().DefWindowProc(lpfnWndProc, hWnd, message, wParam, lParam);
}
开发者ID:lmsf,项目名称:jdk9-dev,代码行数:27,代码来源:awt_FileDialog.cpp

示例11: HandleEvent

MsgRouting
AwtScrollbar::HandleEvent(MSG *msg, BOOL synthetic)
{
    if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) {
        if (IsFocusable() && AwtComponent::sm_focusOwner != GetHWnd()) {
            JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
            jobject target = GetTarget(env);
            env->CallStaticVoidMethod
                (AwtKeyboardFocusManager::keyboardFocusManagerCls,
                 AwtKeyboardFocusManager::heavyweightButtonDownMID,
                 target, ((jlong)msg->time) & 0xFFFFFFFF);
            env->DeleteLocalRef(target);
            AwtSetFocus();
        }
	// Left button press was already routed to default window
	// procedure in the WmMouseDown above.  Propagating synthetic
	// press seems like a bad idea as internal message loop
	// doesn't know how to unwrap synthetic release.
	delete msg;
	return mrConsume;
    }
    else {
	return AwtComponent::HandleEvent(msg, synthetic);
    }
}
开发者ID:fatman2021,项目名称:myforthprocessor,代码行数:25,代码来源:awt_Scrollbar.cpp

示例12: _GetOffset

jint AwtScrollPane::_GetOffset(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    GetOffsetStruct *gos = (GetOffsetStruct *)param;
    jobject self = gos->scrollpane;
    jint orient = gos->orient;

    jint result = 0;
    AwtScrollPane *s = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(self, ret);
    s = (AwtScrollPane *)pData;
    if (::IsWindow(s->GetHWnd()))
    {
        DTRACE_PRINTLN2("%x: WScrollPanePeer.getOffset(%d)", self, orient);
        s->VerifyState();
        int nBar = (orient == java_awt_Adjustable_HORIZONTAL) ? SB_HORZ : SB_VERT;
        result = s->GetScrollPos(nBar);
    }
ret:
   env->DeleteGlobalRef(self);

   delete gos;

   return result;
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:28,代码来源:awt_ScrollPane.cpp

示例13: _AddMenu

void AwtMenuBar::_AddMenu(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    AddMenuStruct *ams = (AddMenuStruct *)param;
    jobject self = ams->menubar;
    jobject menu = ams->menu;

    AwtMenuBar *m = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(self, ret);
    JNI_CHECK_NULL_GOTO(menu, "null menu", ret);
    m = (AwtMenuBar *)pData;
    if (::IsWindow(m->GetOwnerHWnd()))
    {
        /* The menu was already created and added during peer creation -- redraw */
        m->RedrawMenuBar();
    }
ret:
    env->DeleteGlobalRef(self);
    if (menu != NULL) {
        env->DeleteGlobalRef(menu);
    }

    delete ams;
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:27,代码来源:awt_MenuBar.cpp

示例14: _SetSpans

void AwtScrollPane::_SetSpans(void *param)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    SetSpansStruct *sss = (SetSpansStruct *)param;
    jobject self = sss->scrollpane;
    jint parentWidth = sss->parentWidth;
    jint parentHeight = sss->parentHeight;
    jint childWidth = sss->childWidth;
    jint childHeight = sss->childHeight;

    AwtScrollPane *s = NULL;

    PDATA pData;
    JNI_CHECK_PEER_GOTO(self, ret);
    s = (AwtScrollPane *)pData;
    if (::IsWindow(s->GetHWnd()))
    {
        DTRACE_PRINTLN5("%x: WScrollPanePeer.setSpans(%d, %d, %d, %d)", self,
            parentWidth, parentHeight, childWidth, childHeight);
        s->RecalcSizes(parentWidth, parentHeight, childWidth, childHeight);
        s->VerifyState();
    }
ret:
   env->DeleteGlobalRef(self);

   delete sss;
}
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:28,代码来源:awt_ScrollPane.cpp

示例15: UpdateMaxItemWidth

// This function goes through all strings in the list to find the width,
// in pixels, of the longest string in the list.
void AwtList::UpdateMaxItemWidth()
{
    m_nMaxWidth = 0;

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(2) < 0)
        return;

    HDC hDC = ::GetDC(GetHWnd());

    jobject self = GetPeer(env);
    DASSERT(self);

    /* target is java.awt.List */
    jobject target = env->GetObjectField(self, AwtObject::targetID);
    jobject font = GET_FONT(target, self);

    int nCount = GetCount();
    for ( int i=0; i < nCount; i++ )
    {
        jstring jstr = GetItemString( env, target, i );
        SIZE size = AwtFont::getMFStringSize( hDC, font, jstr );
        if ( size.cx > m_nMaxWidth )
            m_nMaxWidth = size.cx;
        env->DeleteLocalRef( jstr );
    }

    // free up the shared DC and release local refs
    ::ReleaseDC(GetHWnd(), hDC);
    env->DeleteLocalRef( target );
    env->DeleteLocalRef( font );

    // Now adjust the horizontal scrollbar extent
    AdjustHorizontalScrollbar();
}
开发者ID:Gustfh,项目名称:jdk8u-dev-jdk,代码行数:37,代码来源:awt_List.cpp


注:本文中的JNU_GetEnv函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。