本文整理汇总了C++中KNI_StartHandles函数的典型用法代码示例。如果您正苦于以下问题:C++ KNI_StartHandles函数的具体用法?C++ KNI_StartHandles怎么用?C++ KNI_StartHandles使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KNI_StartHandles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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) {
//.........这里部分代码省略.........
示例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();
}