• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ KNI_StartHandles函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: unlock

/**
 *  The function unblocks threads waiting for Transaction Store
 */
void unlock() {
    int i, n;
    JVMSPI_BlockedThreadInfo *blocked_threads;
    MidpReentryData* pThreadReentryData;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    if ((locked == KNI_TRUE) && 
            (getStorageOpenFlag(thisObject)->isOpen == KNI_TRUE)) {
        blocked_threads = SNI_GetBlockedThreads(&n);
        getStorageOpenFlag(thisObject)->isOpen = KNI_FALSE;
        locked = KNI_FALSE;
        for (i = 0; i < n; i++) {

            pThreadReentryData =
                (MidpReentryData*)(blocked_threads[i].reentry_data);

            if (pThreadReentryData == NULL) {
                continue;
            }
     
            if (pThreadReentryData->waitingFor != 
                    PAYMENT_TRANSACTION_STORE_SIGNAL) {
                continue;
            }

            pThreadReentryData->status = KNI_TRUE;
 
            midp_thread_unblock(blocked_threads[i].thread_id);
        }

    }

    KNI_EndHandles();
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:40,代码来源:transactionStorage_kni.c


示例2: Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_pushCheckout

/**
 * Checks out (takes ownership of) an active server connection maintained
 * by push subsystem.
 *
 * @param url URL used during registration of the push entry
 * @param suiteId suite id
 * @return true if the operation succeeds, false otherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_midp_io_j2me_btspp_BTSPPNotifierImpl_pushCheckout(void) {
    jboolean retval = KNI_FALSE;
    SuiteIdType suiteId;
    MidpString wsUrl;
    char *szUrl;
    bt_port_t port;

    KNI_StartHandles(2);
    KNI_DeclareHandle(thisHandle);
    KNI_DeclareHandle(urlHandle);
    KNI_GetThisPointer(thisHandle);
    KNI_GetParameterAsObject(1, urlHandle);
    suiteId = KNI_GetParameterAsInt(2);

    wsUrl = midpNewString(urlHandle);
    szUrl = midpJcharsToChars(wsUrl);

    if (bt_push_parse_url(szUrl, &port, NULL) == BT_RESULT_SUCCESS) {
        if (pushcheckout(szUrl, 0, (char*)midp_suiteid2chars(suiteId)) == -2) {
            KNI_ThrowNew(midpIOException, "Port already in use.");
        } else {
            bt_handle_t handle;
            bt_pushid_t pushid = bt_push_checkout_server(&port, &handle, NULL);
            if (pushid != BT_INVALID_PUSH_HANDLE) {
                KNI_SetIntField(thisHandle, pushHandleID, (jint)pushid);
                KNI_SetIntField(thisHandle, notifHandleID, (jint)handle);
                retval = KNI_TRUE;
            }
        }
    }

    midpFree(szUrl);
    MIDP_FREE_STRING(wsUrl);
    KNI_EndHandles();
    KNI_ReturnBoolean(retval);
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:45,代码来源:btSPPNotifierGlue.c


示例3: Java_com_sun_midp_io_j2me_datagram_Protocol_finalize

/**
 * Releases any native resources used by the datagram connection.
 * <p>
 * Java declaration:
 * <pre>
 *     finalize(V)V
 * </pre>
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_io_j2me_datagram_Protocol_finalize(void) {
    void *handle;
    int status;
    void *context = NULL;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    handle = (void *)getMidpDatagramProtocolPtr(thisObject)->nativeHandle;

    if (handle != INVALID_HANDLE) {
        if (pushcheckin((int)handle) == -1) {
            status = pcsl_datagram_close_start(handle, &context);
            if (status == PCSL_NET_SUCCESS) {
                if (midpDecResourceCount(RSC_TYPE_UDP, 1) == 0) {
                    REPORT_INFO(LC_PROTOCOL,
                        "Datagrams: resource limit update error");
                }
            } else if (status == PCSL_NET_IOERROR) {
                REPORT_INFO2(LC_PROTOCOL,
                    "datagram::finalize handle 0x%x I/O error code %d",
                    (int)handle, pcsl_network_error(handle));
            } else if (status == PCSL_NET_WOULDBLOCK) {
                REPORT_ERROR1(LC_PROTOCOL,
                    "datagram::finalize handle 0x%x WOULDBLOCK not supported",
                    (int)handle);
            }
            getMidpDatagramProtocolPtr(thisObject)->nativeHandle =
                (jint)INVALID_HANDLE;
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:jiangxilong,项目名称:yari,代码行数:45,代码来源:datagramProtocol.c


示例4: Java_javax_microedition_lcdui_ImageDataFactory_createImmutableImageDataCopy

/**
 * Creates a copy of the specified <tt>ImageData</tt> and stores the
 * copied image in this object.
 * <p>
 * Java declaration:
 * <pre>
 *     createImmutableImageDataCopy(Ljavax/microedition/lcdui/ImageData;
 *                                  Ljavax/microedition/lcdui/ImageData;)V
 * </pre>
 *
 * @param dest  The <tt>ImageData </tt>where to make a copy
 * @param source The mutable <tt>ImageData</tt> to copy
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_ImageDataFactory_createImmutableImageDataCopy() {

    img_native_error_codes creationError = IMG_NATIVE_IMAGE_NO_ERROR;

    /* mutable image */
    gxpport_image_native_handle srcImage;

    /* pointer to native image structure */
    gxpport_image_native_handle newImage;

    KNI_StartHandles(2);
    KNI_DeclareHandle(dest);
    KNI_DeclareHandle(source);

    KNI_GetParameterAsObject(2, source);
    KNI_GetParameterAsObject(1, dest);

    srcImage = gxp_get_imagedata(source);

    gxpport_createimmutable_from_mutable(srcImage, &newImage, &creationError);

    if (IMG_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR == creationError) {
	KNI_ThrowNew(midpOutOfMemoryError, NULL);
    } else if (IMG_NATIVE_IMAGE_RESOURCE_LIMIT == creationError) {
	KNI_ThrowNew(midpOutOfMemoryError,
                     "Resource limit exceeded for immutable image");
    } else if (IMG_NATIVE_IMAGE_NO_ERROR != creationError) {
	KNI_ThrowNew(midpIllegalArgumentException, NULL);
    } else {
	IMGAPI_GET_IMAGEDATA_PTR(dest)->nativeImageData = (jint)newImage;
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:AllBinary,项目名称:phoneme-components-midp,代码行数:49,代码来源:imgp_imagedatafactory_kni.c


示例5: Java_com_sun_midp_io_j2me_socket_Protocol_available0

/**
 * Gets the number of bytes that can be read without blocking.
 * <p>
 * Java declaration:
 * <pre>
 *     available0(V)I
 * </pre>
 *
 * @return number of bytes that can be read without blocking
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_io_j2me_socket_Protocol_available0(void) {
    void *pcslHandle;
    int bytesAvailable = 0;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);
    
    pcslHandle = (void *)(getMidpSocketProtocolPtr(thisObject)->handle);

    KNI_EndHandles();

    REPORT_INFO1(LC_PROTOCOL, "socket::available0 fd=%d\n", (int)pcslHandle);

    if (INVALID_HANDLE == pcslHandle) {
        KNI_ThrowNew(midpIOException, "invalid handle during socket::available");
    } else {
        int status;

        status = pcsl_socket_available(pcslHandle, &bytesAvailable);
        /* status is only PCSL_NET_SUCCESS or PCSL_NET_IOERROR */
        if (status == PCSL_NET_IOERROR) {
            bytesAvailable = 0;
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                    "IOError %d during socket::available0", 
                    pcsl_network_error(pcslHandle));
            KNI_ThrowNew(midpIOException, gKNIBuffer);
        }
    }

    REPORT_INFO1(LC_PROTOCOL, "socket::available0 bytesAvailable=%d\n", 
                 bytesAvailable);

    KNI_ReturnInt((jint)bytesAvailable);
}
开发者ID:jiangxilong,项目名称:yari,代码行数:46,代码来源:socketProtocol.c


示例6: Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf

KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_cldc_io_j2me_socket_Protocol_readBuf() {
  int result = -1;
  SocketBufferParameter *p;

  if (!ANI_Start()) {
    ANI_Wait();
    KNI_ReturnInt(-1);
  }
  KNI_StartHandles(1);
  KNI_DeclareHandle(buffer_object);
  KNI_GetParameterAsObject(2, buffer_object);

  p = (SocketBufferParameter *) ANI_GetParameterBlock(NULL);
  if (p == NULL) {
    int buffer_size = KNI_GetParameterAsInt(4);
    p = new_buffer_parameter(/*fd*/ KNI_GetParameterAsInt(1), buffer_size);

    if (!ANI_UseFunction(asynchronous_socket_read,
                         /*try_non_blocking*/ KNI_FALSE)) {
      ANI_BlockThread();
      goto EXIT;
    }
  }

  if ((result = p->buffer_size) > 0) {
    jint offset = KNI_GetParameterAsInt(3);
    KNI_SetRawArrayRegion(buffer_object, offset, p->buffer_size,
                          (jbyte *) p->buffer);
  }

EXIT:
  KNI_EndHandles();
  ANI_End();
  KNI_ReturnInt(result);
}
开发者ID:jiangxilong,项目名称:yari,代码行数:36,代码来源:ani_bsd_socket.cpp


示例7: KNIDECL

/*
 * Creates a client connection object.
 *
 * Note: the method sets native connection handle directly to
 * <code>handle<code> field of <code>RFCOMMConnectionImpl</code> object.
 *
  * @param auth   <code>true</code> if authication is required
 * @param enc    <code>true</code> indicates
 *                what connection must be encrypted
 * @param master <code>true</code> if client requires to be
 *               a connection's master
 * @throws IOException if any I/O error occurs
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(com_sun_jsr082_bluetooth_btspp_BTSPPConnectionImpl_create0) {
    javacall_bool auth  = (KNI_GetParameterAsBoolean(1) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;
    javacall_bool enc  = (KNI_GetParameterAsBoolean(2) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;
    javacall_bool master  = (KNI_GetParameterAsBoolean(3) == KNI_TRUE)
        ? JAVACALL_TRUE : JAVACALL_FALSE;

    javacall_handle handle = JAVACALL_BT_INVALID_HANDLE;

    REPORT_INFO(LC_PROTOCOL, "btspp::create");

    /* create RFCOMMC server connection */
    if (javacall_bt_rfcomm_create_client(auth, enc, master, &handle)
            == JAVACALL_FAIL) {
        REPORT_ERROR(LC_PROTOCOL,
            "Connection creation failed during btspp::create");
        KNI_ThrowNew(jsropIOException,
            EXCEPTION_MSG("Can not create RFCOMM connection"));
        KNI_ReturnVoid();
    }

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisHandle);
    KNI_GetThisPointer(thisHandle);

    /* store native connection handle to Java object */
    KNI_SetIntField(thisHandle, connHandleID, (jint)handle);

    REPORT_INFO1(LC_PROTOCOL,
        "btspp::create0 handle=%d connection created", handle);

    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:Sektor,项目名称:phoneme-qtopia,代码行数:49,代码来源:btSPPConnectionGlue_c.c


示例8: Java_com_sun_midp_io_j2me_datagram_Protocol_getMaximumLength0

/**
 * Get the maximum length of a datagram.
 * <p>
 * Java declaration:
 * <pre>
 *     getMaximumLength0(V)I
 * </pre>
 *
 * @return maximum length of a datagram
 */
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_midp_io_j2me_datagram_Protocol_getMaximumLength0(void) {
    void *socketHandle;
    int len = -1;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);
    KNI_GetThisPointer(thisObject);

    socketHandle =
        (void *)getMidpDatagramProtocolPtr(thisObject)->nativeHandle;

    if (socketHandle != INVALID_HANDLE) {
        int status;

        /*
         * IMPL NOTE:
         * Option=3 represents SO_RCVBUF
         * The SO_RCVBUF option is used by the the network implementation
         * as a hint to size the underlying network I/O buffers.
         */
        status = pcsl_network_getsockopt(socketHandle, 3, &len);
        if (status != PCSL_NET_SUCCESS) {
            KNI_ThrowNew(midpIOException, NULL);
        }
    } else {
        KNI_ThrowNew(midpIOException, "socket closed");
    }

    REPORT_INFO2(LC_PROTOCOL,
        "datagram::getMaximumLength0 handle=%d len=%d %d\n",
        (int)socketHandle, len);

    KNI_EndHandles();
    KNI_ReturnInt((jint)len);
}
开发者ID:jiangxilong,项目名称:yari,代码行数:46,代码来源:datagramProtocol.c


示例9: KNIDECL

/**
 * Initializes the native peer of this <tt>Font</tt>.
 * <p>
 * Java declaration:
 * <pre>
 *     init(III)V
 * </pre>
 *
 * @param face The face of the font to initialize
 * @param style The style of the font to initialize
 * @param size The point size of the font to initialize
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_Font_init) {
    int size  = (int)KNI_GetParameterAsInt(3);
    int style = (int)KNI_GetParameterAsInt(2);
    int face  = (int)KNI_GetParameterAsInt(1);
    int ascent, descent, leading;

    KNI_StartHandles(1);
    KNI_DeclareHandle(thisObject);

    KNI_GetParameterAsObject(0, thisObject);

    gx_get_fontinfo(face, style, size, &ascent, &descent, &leading);

    SNI_BEGIN_RAW_POINTERS;

    GET_FONT_PTR(thisObject)->baseline = (jint)ascent;
    GET_FONT_PTR(thisObject)->height = (jint)(ascent + descent + leading);

    SNI_END_RAW_POINTERS;
    
    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:jiangxilong,项目名称:yari,代码行数:36,代码来源:gxapi_font_kni.c


示例10: KNIDECL

/**
 * Gets an ARGB integer array from this <tt>ImmutableImage</tt>. The
 * array consists of values in the form of 0xAARRGGBB.
 * <p>
 * Java declaration:
 * <pre>
 *     getRGB([IIIIIII)V
 * </pre>
 *
 * @param rgbData The target integer array for the ARGB data
 * @param offset Zero-based index of first ARGB pixel to be saved
 * @param scanlen Number of intervening pixels between pixels in
 *                the same column but in adjacent rows
 * @param x The x coordinate of the upper left corner of the
 *          selected region
 * @param y The y coordinate of the upper left corner of the
 *          selected region
 * @param width The width of the selected region
 * @param height The height of the selected region
 */
KNIEXPORT KNI_RETURNTYPE_VOID
KNIDECL(javax_microedition_lcdui_Image_getRGB) {
    int height = KNI_GetParameterAsInt(7);
    int width = KNI_GetParameterAsInt(6);
    int y = KNI_GetParameterAsInt(5);
    int x = KNI_GetParameterAsInt(4);
    int scanlength = KNI_GetParameterAsInt(3);
    int offset = KNI_GetParameterAsInt(2);
    int buflen;
    int *rgbBuffer;
    int img_width;
    int img_height;
    jboolean iae = KNI_FALSE;
    java_imagedata * srcImageDataPtr = NULL;

    KNI_StartHandles(2);
    KNI_DeclareHandle(rgbData);
    KNI_DeclareHandle(thisObject);

    KNI_GetParameterAsObject(1, rgbData);
    KNI_GetThisPointer(thisObject);

    srcImageDataPtr = GET_IMAGE_PTR(thisObject)->imageData;

    img_width  = srcImageDataPtr->width;
    img_height = srcImageDataPtr->height;

    /* see if absolute value of scanlength is greater than or equal to width */
    if (scanlength >= 0 && scanlength < width) {
        iae = KNI_TRUE;
    } else if (scanlength < 0 && (0 - scanlength) < width) {
        iae = KNI_TRUE;
    }
    if (KNI_IsNullHandle(rgbData)) {
        KNI_ThrowNew(midpNullPointerException, NULL);
    } else if((y < 0) || (x < 0) || (x + width > img_width) ||
              (y + height > img_height) || iae == KNI_TRUE) {
        KNI_ThrowNew(midpIllegalArgumentException, NULL);
    } else if (height < 0 || width < 0 ) {
        /* spec says noop in this case */
    } else {
        buflen = KNI_GetArrayLength(rgbData);
        if (offset < 0
            || offset + ((height - 1) * scanlength) + width > buflen
            || offset + ((height - 1) * scanlength) < 0) {
            KNI_ThrowNew(midpArrayIndexOutOfBoundsException, NULL);
        } else {
  	    gxutl_native_image_error_codes error = GXUTL_NATIVE_IMAGE_NO_ERROR;

	    SNI_BEGIN_RAW_POINTERS;

            rgbBuffer = JavaIntArray(rgbData);
	    gx_get_argb(srcImageDataPtr, rgbBuffer,
		       offset, scanlength,
		       x, y, width, height, &error);

	    SNI_END_RAW_POINTERS;

	    if (error != GXUTL_NATIVE_IMAGE_NO_ERROR) {
		KNI_ThrowNew(midpOutOfMemoryError, NULL);
	    }
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:87,代码来源:gxapi_image_kni.c


示例11: Java_com_sun_midp_io_j2me_comm_Protocol_native_1openByName

/**
 * Open a serial port by system dependent device name.
 *
 * @param name device name of the port
 * @param baud baud rate to set the port at
 * @param flags options for the serial port
 *
 * @return handle to a native serial port
 *
 * @exception  IOException  if an I/O error occurs.
 */
KNIEXPORT KNI_RETURNTYPE_INT
    Java_com_sun_midp_io_j2me_comm_Protocol_native_1openByName() {

    int    flags = (int)KNI_GetParameterAsInt(3);
    int    baud = (int)KNI_GetParameterAsInt(2);
    int    nameLen;
    char   szName[MAX_NAME_LEN];
    jchar* temp;
    int    hPort = (int)INVALID_HANDLE;
    int    i;
    int status = PCSL_NET_IOERROR;
    void* context = NULL;
    MidpReentryData* info;

    KNI_StartHandles(1);
    KNI_DeclareHandle(nameObject);
    KNI_GetParameterAsObject(1, nameObject);
    
    info = (MidpReentryData*)SNI_GetReentryData(NULL);
    if (info == NULL) {
        nameLen = KNI_GetStringLength(nameObject);
        if (nameLen > MAX_NAME_LEN) {
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Serial device name has wrong length: %d\n", nameLen);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpIllegalArgumentException, gKNIBuffer);
        } else {
            temp = (jchar*)szName;
            KNI_GetStringRegion(nameObject, 0, nameLen, temp);

            /* device names are in ASCII */
            for (i = 0; i < nameLen; i++) {
                szName[i] = (char)temp[i];
            }
            szName[nameLen] = 0;
		
            status = openPortByNameStart(szName, baud, flags, &hPort, &context);
        }
    } else {
        /* reinvocation */
        hPort = info->descriptor;
        context = info->pResult;
        status = openPortByNameFinish(szName, baud, flags, &hPort, context);	
    }

    switch (status) {
        case PCSL_NET_SUCCESS:			
            /* do nothing and return normally */
            break;
        case PCSL_NET_INTERRUPTED:			
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Opening port %s has been interrupted\n", szName);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpInterruptedIOException, gKNIBuffer);
            break;
        case PCSL_NET_WOULDBLOCK:			
            midp_thread_wait(COMM_OPEN_SIGNAL, hPort, context);
            break;
        default:	   
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Opening port %s was failed\n", szName);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpIOException, gKNIBuffer);
    }

    KNI_EndHandles();
    KNI_ReturnInt((jint)hPort);
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:79,代码来源:commProtocol.c


示例12: Java_com_sun_midp_io_j2me_comm_Protocol_native_1writeBytes

/**
 * Write to a serial port without blocking.
 *
 * @param hPort handle to a native serial port
 * @param b I/O buffer
 * @param off starting offset for data
 * @param len length of data
 *
 * @return number of bytes that were written
 *
 * @exception  IOException  if an I/O error occurs.
 */
KNIEXPORT KNI_RETURNTYPE_INT
    Java_com_sun_midp_io_j2me_comm_Protocol_native_1writeBytes() {

    int  length = (int)KNI_GetParameterAsInt(4);
    int  offset = (int)KNI_GetParameterAsInt(3);
    int  hPort  = (int)KNI_GetParameterAsInt(1);
    int   bytesWritten = 0;
    int status = PCSL_NET_IOERROR;
    void* context = NULL;
    MidpReentryData* info;

    KNI_StartHandles(1);
    KNI_DeclareHandle(bufferObject);
    KNI_GetParameterAsObject(2, bufferObject);

    info = (MidpReentryData*)SNI_GetReentryData(NULL);
    if (info == NULL) {

        if (hPort < 0) {
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Write to port: handle %d is invalid\n", hPort);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpIllegalArgumentException, gKNIBuffer);
        } else {        		
            SNI_BEGIN_RAW_POINTERS;
            status = writeToPortStart(hPort,
                (char*)&(JavaByteArray(bufferObject)[offset]),
                length, &bytesWritten, &context);
            SNI_END_RAW_POINTERS;
        }
    } else {
        /* reinvocation */
        hPort = info->descriptor;
        context = info->pResult;
        SNI_BEGIN_RAW_POINTERS;
        status = writeToPortFinish(hPort,
            (char*)&(JavaByteArray(bufferObject)[offset]),
            length, &bytesWritten, context);
        SNI_END_RAW_POINTERS;
    }

    switch (status) {
        case PCSL_NET_SUCCESS:			
            /*do nothing and return normally */
            break;
        case PCSL_NET_INTERRUPTED:			
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Writing to port %d has been interrupted\n", hPort);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpInterruptedIOException, gKNIBuffer);
            break;
        case PCSL_NET_WOULDBLOCK:			
            midp_thread_wait(COMM_WRITE_SIGNAL, hPort, context);
            break;
        default:	   
            midp_snprintf(gKNIBuffer, KNI_BUFFER_SIZE,
                "Writing to  port %d was failed\n", hPort);
            REPORT_INFO1(LC_PROTOCOL, "%s\n", gKNIBuffer);
            KNI_ThrowNew(midpIOException, gKNIBuffer);
    }
    	    
    KNI_EndHandles();
    KNI_ReturnInt((jint)bytesWritten);
    
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:77,代码来源:commProtocol.c


示例13: Java_com_sun_midp_content_InvocationStore_setStatus0

/**
 * Implementation of native method to set the status of an Invocation.
 * If the status is set to a response status then the "finish"
 * behavior is performed.  If a response is required, the Invocation
 * is requeued to the invoking application. Otherwise, the Invocation
 * is discarded.
 *
 * @param invoc the InvocationImpl to update the native status
 * @see StoredInvoc
 * @see #invocQueue
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_content_InvocationStore_setStatus0(void) {
    StoredLink* link;
    StoredInvoc* invoc;
    int tid;

    KNI_StartHandles(3);
    KNI_DeclareHandle(invocObj);
    KNI_DeclareHandle(obj1);
    KNI_DeclareHandle(obj2);

    KNI_GetParameterAsObject(1, invocObj);
    init(invocObj, obj1);

    /* Find the matching entry in the queue */
    tid = KNI_GetIntField(invocObj, tidFid);
    link = invocFindTid(tid);
    if (link != NULL) {
        invoc = link->invoc;
        /* Update the status */
        invoc->status = KNI_GetIntField(invocObj, statusFid);
    
        switch (invoc->status) {
        case STATUS_OK:
        case STATUS_CANCELLED:
        case STATUS_ERROR:
        case STATUS_INITIATED:
            /* 
             * If a response is required, switch the target
             * application; if not then discard the Invocation.
             */
            if (invoc->responseRequired) {
                /* Swap the source and target suite and classname */
                SuiteIdType tmpSuiteId = invoc->invokingSuiteId;
                SuiteIdType tmpSuiteId2;
                pcsl_string tmpClassname = invoc->invokingClassname;
                invoc->invokingSuiteId = invoc->suiteId;
                invoc->invokingClassname = invoc->classname;
                invoc->suiteId = tmpSuiteId;
                invoc->classname = tmpClassname;
        
                /* Unmark the response it is "new" to the target */
                invoc->cleanup = KNI_FALSE;
                invoc->notified = KNI_FALSE;
        
                /* Swap the references in the Invocation object. */
                tmpSuiteId = KNI_GetIntField(invocObj, suiteIdFid);
                tmpSuiteId2 = KNI_GetIntField(invocObj, invokingSuiteIdFid);
                KNI_SetIntField(invocObj, invokingSuiteIdFid, tmpSuiteId);
                KNI_SetIntField(invocObj, suiteIdFid, tmpSuiteId2);

                KNI_GetObjectField(invocObj, invokingClassnameFid, obj1);
                KNI_GetObjectField(invocObj, classnameFid, obj2);
                KNI_SetObjectField(invocObj, classnameFid, obj1);
                KNI_SetObjectField(invocObj, invokingClassnameFid, obj2);
        
                /* Unblock any waiting threads so they can retrieve this. */
                unblockWaitingThreads(STATUS_OK);
                break;
            }
            /* If no response; Fall into DISPOSE */
    
        case STATUS_DISPOSE:
            /*
             * Free the Invocation, clean the Tid in the Invocation
             */
            invoc->tid = 0;
            KNI_SetIntField(invocObj, tidFid, 0);
            removeEntry(link);
            invocFree(invoc);
            break;
        case STATUS_ACTIVE:
        case STATUS_HOLD:
        case STATUS_WAITING:
            /* No Action. */
            break;
        }
    }

    KNI_EndHandles();
    KNI_ReturnVoid();
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:93,代码来源:invocStore.c


示例14: Java_com_sun_midp_content_InvocationStore_put0

/**
 * Implementation of native method to queue a new Invocation.
 * The state of the InvocationImpl is copied to the heap
 * and inserted in the head of the invocation queue.
 * An StoredInvoc struct is allocated on the native heap and 
 * the non-null strings for each field of the InvocationImpl class
 * are copied to the heap.
 * A new transaction ID is assigned to this Invocation
 * and returned in the tid field of the InvocationImpl.
 * @param invoc the InvocationImpl to store
 * @throws OutOfMemoryError if the memory allocation fails
 * @see StoredInvoc
 * @see #invocQueue
 */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_midp_content_InvocationStore_put0(void) {
    StoredInvoc* invoc = NULL;

    KNI_StartHandles(4);
    KNI_DeclareHandle(invocObj);
    KNI_DeclareHandle(classObj);
    KNI_DeclareHandle(argsObj);
    KNI_DeclareHandle(str);

    KNI_GetParameterAsObject(1, invocObj);
    init(invocObj, classObj);

    do {
        /* On any error break out of this block */
        /* Allocate a new zero'ed struct to save the values in */
        invoc = (StoredInvoc*) pcsl_mem_calloc(1, sizeof (StoredInvoc));
        if (invoc == NULL) {
            KNI_ThrowNew(midpOutOfMemoryError, 
                                "InvocationStore_put0 no memory for [invoc]");
            break;
        }
    
        /* Assign a new transaction id and set it */
        invoc->tid = invocNextTid();
        KNI_SetIntField(invocObj, tidFid, invoc->tid);
    
        /*
         * Copy all the parameters to native
         * Includes ID, type,url, action, args, data
         */
        if (KNI_TRUE != setParamsFromObj(invoc, invocObj, str, argsObj))
            break;
    
        invoc->previousTid = KNI_GetIntField(invocObj, previousTidFid);
    
        invoc->status = KNI_GetIntField(invocObj, statusFid);
        invoc->responseRequired =
            KNI_GetBooleanField(invocObj, responseRequiredFid);
    
        invoc->suiteId = KNI_GetIntField(invocObj, suiteIdFid);
    
        KNI_GetObjectField(invocObj, classnameFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, &invoc->classname))
            break;
    
        KNI_GetObjectField(invocObj, invokingAuthorityFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, 
                                                    &invoc->invokingAuthority))
            break;
    
        KNI_GetObjectField(invocObj, invokingAppNameFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, 
                                                    &invoc->invokingAppName))
            break;
    
        invoc->invokingSuiteId = KNI_GetIntField(invocObj, invokingSuiteIdFid);
    
        KNI_GetObjectField(invocObj, invokingClassnameFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, 
                                                    &invoc->invokingClassname))
            break;
    
        KNI_GetObjectField(invocObj, invokingIDFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, &invoc->invokingID))
            break;
    
        KNI_GetObjectField(invocObj, usernameFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, &invoc->username))
            break;
    
        KNI_GetObjectField(invocObj, passwordFid, str);
        if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(str, &invoc->password))
            break;
    
        /* Insert the new Invocation at the end of the queue */
        if (!invocPut(invoc))
            break;
    
        unblockWaitingThreads(STATUS_OK);
    
        /* Clear to skip cleanup and throwing exception */
        invoc = NULL;
    } while (0);

    if (invoc != NULL) {
//.........这里部分代码省略.........
开发者ID:sfsy1989,项目名称:j2me,代码行数:101,代码来源:invocStore.c


示例15: JSR239_putWindowContents

/* Copy engine buffer back to MIDP */
void
JSR239_putWindowContents(jobject graphicsHandle,
                         jint delta_height,
                         JSR239_Pixmap *src, jint flipY) {

    void* s;
    void* d;

    KNI_StartHandles(1);
    KNI_DeclareHandle(GraphicsClassHandle);

#ifdef DEBUG
    printf("JSR239_putWindowContents >>\n");
#endif

    KNI_FindClass("javax/microedition/lcdui/Graphics", GraphicsClassHandle);
    if (!KNI_IsInstanceOf(graphicsHandle, GraphicsClassHandle)) {
#ifdef DEBUG
        printf("JSR239_putWindowContents only implemented for graphicsHandle "
               "instanceof Graphics!\n");
#endif
    } else {
        gxj_screen_buffer sbuf;
        gxj_screen_buffer* gimg;

        // Obtain the dimensions of the destination.
        jint dest_width = lcdlf_get_screen_width();
        jint dest_height = lcdlf_get_screen_height();

        jint min_height = 0;
        
        gimg = GXJ_GET_GRAPHICS_SCREEN_BUFFER(graphicsHandle, &sbuf);
        if (gimg != NULL) {
            dest_width = gimg->width;
            dest_height= gimg->height;
        }

#ifdef DEBUG
        printf("JSR239_putWindowContents:\n"); 
        printf("  src Bpp    = %d\n", src->pixelBytes);
        printf("  src width  = %d\n", src->width);
        printf("  src height = %d\n", src->height);
        printf("  min height = %d\n", min_height);
#endif

        /* IMPL_NOTE: get clip sizes into account. */
        copyToScreenBuffer(src, delta_height, flipY);

        /* src->screen_buffer is an output of copyToScreenBuffer function. */
        s = (void*)src->screen_buffer;
        d = (void*)getGraphicsBuffer(graphicsHandle);

        min_height = (dest_height > src->height) ? src->height : dest_height;

        if ((src->width  != dest_width) ||
            (sizeof(gxj_pixel_type) != 2)) {
#ifdef DEBUG
        printf("JSR239: offscreen buffer data is incorrect.\n");
#endif
        } else {
            /* Source data must be in 16bit 565 format. */
            JSR239_memcpy(d, s,
                dest_width * min_height * sizeof(gxj_pixel_type));
        }
    }

#ifdef DEBUG
    printf("JSR239_putWindowContents <<\n");
#endif

    KNI_EndHandles();
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:73,代码来源:JSR239-KNIWindow.c


示例16: Java_com_sun_midp_content_InvocationStore_listen0

/**
 * 
 * Listens for  an InvocationImpl from the store using a MIDlet suiteId
 * and optional, and status. Each Invocation must be returned only
 * once.  When an Invocation is returned; it is marked as being
 * notified.
 *
 * @param suiteId to match a pending invocation
 * @param classname to match a pending invocation
 * @param mode one of {@link #MODE_REQUEST}, {@link #MODE_RESPONSE},
 *    or {@link #MODE_CLEANUP}
 * @param blocking true to block until a matching invocation is available
 * @return true if an Invocation is found with 
 *  the same MIDlet suiteId and classname; false is returne dotherwise
 */
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_com_sun_midp_content_InvocationStore_listen0(void) {
    StoredLink* match = NULL;
    SuiteIdType desiredSuiteId;
    pcsl_string desiredClassname = PCSL_STRING_NULL_INITIALIZER;

    KNI_StartHandles(1);
    KNI_DeclareHandle(classname); /* Arg2: non-null classname */
    int mode;                  /* Arg3: requested invocation mode */
    jboolean blocking = KNI_FALSE; /* Arg4: true if should block */

    /* Argument indices must match Java native method declaration */
#define listenSuiteIdArg 1
#define listenClassnameArg 2
#define listenModeArg 3
#define listenBlockingArg 4

    do {/* Block to break out of on exceptions */
        /* Check if blocked invocation was cancelled. */
        if (isThreadCancelled()) {
            /* blocking is always false to cleanup and exit immediately */
            break;
        }
    
        /* Get the desired blocking mode. */
        blocking = KNI_GetParameterAsBoolean(listenBlockingArg);
    
        if (!isEmpty()) {
            /* Queue is not empty
             * Need a string copy of the desired suiteID and classname
             * to use for comparisons
             */
            desiredSuiteId = KNI_GetParameterAsInt(listenSuiteIdArg);
    
                KNI_GetParameterAsObject(listenClassnameArg, classname);
            if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(classname, 
                               &desiredClassname)) {
                KNI_ThrowNew(midpOutOfMemoryError, 
                    "InvocationStore_listen0 no memory for [desiredClassname]");
                break;
            }

            /* Get the desired request mode. */
            mode = KNI_GetParameterAsInt(listenModeArg);
            match = invocFind(desiredSuiteId, &desiredClassname, mode);
        }
    } while (KNI_FALSE);

    /* Always free strings allocated */
    pcsl_string_free(&desiredClassname);

    if (match != NULL) {
        match->invoc->notified = KNI_TRUE;
    } else {
        if (blocking) {
            /* No found; block the thread in the VM */
            blockThread();
            /* Fall into the return to manage handles correctly */
        }
    }

    KNI_EndHandles();
    KNI_ReturnBoolean(match != NULL);
}
开发者ID:sfsy1989,项目名称:j2me,代码行数:79,代码来源:invocStore.c


示例17: KNIDECL

KNIEXPORT KNI_RETURNTYPE_OBJECT
KNIDECL(com_sun_midp_chameleon_skins_resources_LoadedSkinData_readStringArray) {
    int arrayLength;
    int i;

    KNI_StartHandles(2);
    KNI_DeclareHandle(returnArray);
    KNI_DeclareHandle(stringHandle);

    do {
        /*
         * First, read array length
         */
        ENSURE_SKIN_DATA_AVAILABILITY(sizeof(jint));
        memcpy((void*)&arrayLength, (void*)gsSkinFileDataPos, sizeof(jint));
        gsSkinFileDataPos += sizeof(jint);


        /*
         * Then create array
         */
        SNI_NewArray(SNI_STRING_ARRAY, arrayLength, returnArray);
        if (KNI_IsNullHandle(returnArray)) {
            KNI_ThrowNew(midpOutOfMemoryError, NULL);
            break;
        }

        /*
         * And finally populate it with strings
         */
        for (i = 0; i < arrayLength; ++i) {
            unsigned char dataLength;
            unsigned char encoding;

            /* read data length */
            ENSURE_SKIN_DATA_AVAILABILITY(sizeof(char));
            dataLength = *((unsigned char*)gsSkinFileDataPos);
            gsSkinFileDataPos += 1;

            /* read encoding */
            ENSURE_SKIN_DATA_AVAILABILITY(sizeof(char));
            encoding = *((unsigned char*)gsSkinFileDataPos);
            gsSkinFileDataPos += 1;

            ENSURE_SKIN_DATA_AVAILABILITY(dataLength * sizeof(char));

            if (encoding == STRING_ENCODING_USASCII) {    
                int j;

                /* 
                 * In case of USASCII encoding, each byte of 
                 * string data corresponds to one string char
                 */
                int stringLength = dataLength;

                /* use gKNIBuffer for storing string chars */
                jchar* stringChars = (jchar*)gKNIBuffer;
                
                /* 
                 * Safety measure to prevent gKNIBuffer overflow 
                 * (which should never happens unless something is broken) 
                 */
                if (stringLength > (int)(KNI_BUFFER_SIZE/sizeof(jchar))) {
                    stringLength = (int)(KNI_BUFFER_SIZE/sizeof(jchar));
                    REPORT_WARN(LC_HIGHUI, 
                            "gKNIBuffer is too small for skin string");
                }

                /* fill string chars array */
                for (j = 0; j < stringLength; ++j) {
                    stringChars[j] = gsSkinFileDataPos[j];
                }

                /* and create string from it */
                KNI_NewString(stringChars, stringLength, stringHandle);
            } else if (encoding == STRING_ENCODING_UTF8) {
                KNI_NewStringUTF((char*)gsSkinFileDataPos, stringHandle);
            } else {
                KNI_ThrowNew(midpIllegalStateException, 
                        "Illegal skin string encoding");
                break;
            }
            
            KNI_SetObjectArrayElement(returnArray, i, stringHandle);

            gsSkinFileDataPos += dataLength;
        }

    } while (0);

    KNI_EndHandlesAndReturnObject(returnArray);
}
开发者ID:AllBinary,项目名称:phoneme-components-midp,代码行数:92,代码来源:lfj_cskin.c


示例18: Java_javax_microedition_khronos_egl_EGL10Impl__1eglCreatePbufferSurface

/*  private native int _eglCreatePbufferSurface ( int display , int config , int [ ] attrib_list ) ; */
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_khronos_egl_EGL10Impl__1eglCreatePbufferSurface() {

    jint display = KNI_GetParameterAsInt(1);
    jint config = KNI_GetParameterAsInt(2);
    EGLint *attrib_list = (EGLint *)0;

    jint returnValue = (jint)EGL_NO_SURFACE;

    KNI_StartHandles(2);
    KNI_DeclareHandle(attrib_listHandle);
    KNI_DeclareHandle(thisHandle);

    KNI_GetParameterAsObject(3, attrib_listHandle);
    KNI_GetThisPointer(thisHandle);

    /* Construct attrib_list as a copy of attrib_listHandle if non-null */
    if (!KNI_IsNullHandle(attrib_listHandle)) {
        jint attrib_list_length, attrib_list_size;

	attrib_list_length = KNI_GetArrayLength(attrib_listHandle);
	attrib_list_size = attrib_list_length*sizeof(jint);
	attrib_list = (EGLint *)JSR239_malloc(attrib_list_size);
	if (!attrib_list) {
            KNI_ThrowNew("java.lang.OutOfMemoryException",
			 "eglCreatePbufferSurface");
	    goto exit;
	}
	KNI_GetRawArrayRegion(attrib_listHandle, 0, attrib_list_size,
			      (jbyte *) attrib_list);
    }

#ifdef DEBUG
    {
        int idx = 0;
        int attr;
     
#ifdef DEBUG
        printf("In eglCreatePbufferSurface:\n");
#endif
        if (!attrib_list) {
#ifdef DEBUG
            printf("attrib_list is null!\n");
#endif
        } else {
            while (1) {
                attr = attrib_list[idx++];
#ifdef DEBUG
                printf("attr[%d] = 0x%x\n", idx, attr);
#endif
                if (attr == EGL_NONE) {
                    break;
                }
            }
        }
    }
#endif
        
    returnValue = (jint)eglCreatePbufferSurface((EGLDisplay)display,
						(EGLConfig)config,
						(EGLint const *) attrib_list);

#ifdef DEBUG
    if (returnValue > 0) {
        ++surfaces;
    }

    printf("eglCreatePbufferSurface(0x%x, 0x%x, attrib_list) = %d, surfaces = %d\n",
	   display, config, returnValue, surfaces);

    {
        EGLint error; /* debugging */
        error = eglGetError();
        if (error != EGL_SUCCESS) {
            printf("egl error = 0x%x\n", error);
        }
    }
#endif

 exit:
    if (attrib_list) {
	JSR239_free(attrib_list);
    }

    KNI_EndHandles();
    KNI_ReturnInt(returnValue);
}
开发者ID:Sektor,项目名称:phoneme-qtopia,代码行数:88,代码来源:JSR239-KNIEGL11Impl.c


示例19: Java_javax_microe


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ KNI_ThrowNew函数代码示例发布时间:2022-05-30
下一篇:
C++ KNI_ReturnVoid函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap