本文整理汇总了C++中KNI_ThrowNew函数的典型用法代码示例。如果您正苦于以下问题:C++ KNI_ThrowNew函数的具体用法?C++ KNI_ThrowNew怎么用?C++ KNI_ThrowNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了KNI_ThrowNew函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Java_javax_microedition_lcdui_ImageDataFactory_loadRomizedImage
/**
* boolean loadRomizedImage(IamgeData imageData, int imageDataArrayPtr,
* int imageDataArrayLength);
*/
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_javax_microedition_lcdui_ImageDataFactory_loadRomizedImage() {
int status = KNI_FALSE;
int imageDataArrayPtr = KNI_GetParameterAsInt(2);
int imageDataArrayLength = KNI_GetParameterAsInt(3);
int imgWidth, imgHeight;
img_native_error_codes creationError = IMG_NATIVE_IMAGE_NO_ERROR;
/* pointer to native image structure */
gxpport_image_native_handle newImagePtr;
KNI_StartHandles(1);
KNI_DeclareHandle(imageData);
KNI_GetParameterAsObject(1, imageData);
do {
unsigned char* buffer = (unsigned char*)imageDataArrayPtr;
gxpport_loadimmutable_from_platformbuffer(
buffer, imageDataArrayLength,
KNI_TRUE,
&imgWidth, &imgHeight,
&newImagePtr,
&creationError);
if (IMG_NATIVE_IMAGE_NO_ERROR == creationError) {
java_imagedata * dstImageDataPtr = IMGAPI_GET_IMAGEDATA_PTR(imageData);
dstImageDataPtr->width = (jint)imgWidth;
dstImageDataPtr->height = (jint)imgHeight;
dstImageDataPtr->nativeImageData = (jint)newImagePtr;
status = KNI_TRUE;
break;
} else if (IMG_NATIVE_IMAGE_OUT_OF_MEMORY_ERROR == creationError) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
break;
} else if (IMG_NATIVE_IMAGE_RESOURCE_LIMIT == creationError) {
KNI_ThrowNew(midpOutOfMemoryError,
"Resource limit exceeded for immutable image");
break;
} else {
KNI_ThrowNew(midpIllegalArgumentException, NULL);
break;
}
} while (0);
KNI_EndHandles();
KNI_ReturnBoolean(status);
}
示例2: Java_com_sun_j2me_global_StringComparatorImpl_compare0
/**
* Compare two strings using locale- and level-specific rules.
* <p>
* Java declaration:
* <pre>
* compare0(Ljava/lang/String;Ljava/lang/String;II)I
* </pre>
*
* @param locale_index the locale index in supported locales list
* @param hstr1 first string to compare
* @param hstr2 second string to compare
* @param level the collation level to use
* @return negative if <code>s1</code> belongs before <code>s2</code>,
* zero if the strings are equal, positive if <code>s1</code> belongs
* after <code>s2</code>
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_j2me_global_StringComparatorImpl_compare0() {
jint locale_index = KNI_GetParameterAsInt(1);
jint level = KNI_GetParameterAsInt(4);
jchar *s1, *s2;
jsize s1_len, s2_len;
jint res, compare_result = 0;
KNI_StartHandles(2);
KNI_DeclareHandle(hstr1);
KNI_DeclareHandle(hstr2);
KNI_GetParameterAsObject(2, hstr1);
KNI_GetParameterAsObject(3, hstr2);
s1_len = KNI_GetStringLength(hstr1);
if (s1_len == -1){
KNI_ThrowNew(midpNullPointerException, NULL);
} else {
s1 = (jchar *)midpMalloc(s1_len * sizeof(jchar));
if (NULL == s1) {
KNI_ThrowNew(midpOutOfMemoryError,
"Cannot allocate string for collation");
} else {
s2_len = KNI_GetStringLength(hstr2);
if (s2_len == -1){
KNI_ThrowNew(midpNullPointerException, NULL);
} else {
s2 = (jchar *)midpMalloc(s2_len * sizeof(jchar));
if (NULL == s2) {
KNI_ThrowNew(midpOutOfMemoryError,
"Cannot allocate string for collation");
} else {
KNI_GetStringRegion(hstr1, 0, s1_len, s1);
KNI_GetStringRegion(hstr2, 0, s2_len, s2);
res = jsr238_compare_strings(locale_index, s1, s1_len, s2, s2_len,
level, &compare_result);
if (res < 0){
KNI_ThrowNew(midpRuntimeException,"Error comparing strings");
}
midpFree(s2);
}
}
midpFree(s1);
}
}
KNI_EndHandles();
KNI_ReturnInt(compare_result);
}
示例3: Java_com_sun_midp_content_RegistryStore_getValues0
/**
* java call:
* private native String getValues0(String callerId, int searchBy);
*/
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_getValues0(void) {
jsr211_field searchBy;
pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER;
JSR211_RESULT_STRARRAY result = _JSR211_RESULT_INITIALIZER_;
KNI_StartHandles(1);
KNI_DeclareHandle(strObj); // String object
do {
KNI_GetParameterAsObject(1, strObj); // callerId
if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(strObj, &callerId)) {
KNI_ThrowNew(midpOutOfMemoryError,
"RegistryStore_getValues0 no memory for string arguments");
break;
}
searchBy = (jsr211_field) KNI_GetParameterAsInt(2);
jsr211_get_all(&callerId, searchBy, &result);
} while (0);
pcsl_string_free(&callerId);
result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&result, strObj);
KNI_EndHandlesAndReturnObject(strObj);
}
示例4: KNIDECL
/*
* Returns the number of bytes available to be read from the connection
* without blocking.
*
* Note: the method gets native connection handle directly from
* <code>handle<code> field of <code>BTSPPConnectionImpl</code> object.
*
* @return the number of available bytes
* @throws IOException if any I/O error occurs
*/
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_jsr082_bluetooth_btspp_BTSPPConnectionImpl_available0) {
javacall_handle handle;
int count = -1;
char* pError;
REPORT_INFO(LC_PROTOCOL, "btspp::available");
KNI_StartHandles(1);
KNI_DeclareHandle(thisHandle);
KNI_GetThisPointer(thisHandle);
handle = (javacall_handle)KNI_GetIntField(thisHandle, connHandleID);
switch (javacall_bt_rfcomm_get_available(handle, &count)) {
case JAVACALL_OK:
REPORT_INFO(LC_PROTOCOL, "btspp::available done!");
break;
case JAVACALL_FAIL:
javacall_bt_rfcomm_get_error(handle, &pError);
JAVAME_SNPRINTF(gBtBuffer, BT_BUFFER_SIZE,
"IO error during btspp::::available (%s)", pError);
REPORT_ERROR(LC_PROTOCOL, gBtBuffer);
KNI_ThrowNew(jsropIOException, EXCEPTION_MSG(gBtBuffer));
break;
default: /* illegal argument */
REPORT_ERROR(LC_PROTOCOL, "Internal error in btspp::available");
}
KNI_EndHandles();
KNI_ReturnInt(count);
}
示例5: KNIDECL
/**
* Gets the total advance width of the given <tt>String</tt> in this
* <tt>Font</tt>.
* <p>
* Java declaration:
* <pre>
* stringWidth(Ljava/lang/String;)I
* </pre>
*
* @param str the <tt>String</tt> to be measured
*
* @return the total advance width of the <tt>String</tt> in pixels
*/
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(javax_microedition_lcdui_Font_stringWidth) {
int strLen;
jint result = 0;
KNI_StartHandles(2);
KNI_DeclareHandle(str);
KNI_DeclareHandle(thisObject);
KNI_GetParameterAsObject(1, str);
KNI_GetParameterAsObject(0, thisObject);
if ((strLen = KNI_GetStringLength(str)) == -1) {
KNI_ThrowNew(midpNullPointerException, NULL);
} else {
int face, style, size;
_JavaString *jstr;
DECLARE_FONT_PARAMS(thisObject);
SNI_BEGIN_RAW_POINTERS;
jstr = GET_STRING_PTR(str);
result = gx_get_charswidth(face, style, size,
jstr->value->elements + jstr->offset,
strLen);
SNI_END_RAW_POINTERS;
}
KNI_EndHandles();
KNI_ReturnInt(result);
}
示例6: KNIDECL
/**
* Adds a connection to the push registry.
* <p>
* Java declaration:
* <pre>
* add0([B)I
* </pre>
*
* @param connection The connection to add to the push registry
*
* @return <tt>0</tt> upon successfully adding the connection, otherwise
* <tt>-1</tt> if connection already exists
*/
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_midp_io_j2me_push_ConnectionRegistry_add0) {
char *szConn = NULL;
int connLen;
int ret = -1;
KNI_StartHandles(1);
KNI_DeclareHandle(conn);
KNI_GetParameterAsObject(1, conn);
connLen = KNI_GetArrayLength(conn);
szConn = midpMalloc(connLen);
if (szConn != NULL) {
KNI_GetRawArrayRegion(conn, 0, connLen, (jbyte*)szConn);
ret = pushadd(szConn);
midpFree(szConn);
}
if ((szConn == NULL) || (ret == -2)) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
}
KNI_EndHandles();
KNI_ReturnInt(ret);
}
示例7: Java_com_sun_j2me_location_PlatformLocationProvider_resetImpl
/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_VOID
Java_com_sun_j2me_location_PlatformLocationProvider_resetImpl() {
MidpReentryData *info = NULL;
ProviderInfo *pInfo = NULL;
jint provider = KNI_GetParameterAsInt(1);
jsr179_result res;
info = (MidpReentryData*)SNI_GetReentryData(NULL);
if (info == NULL) {
/* reset provider */
res = jsr179_update_cancel((jsr179_handle)provider);
switch (res) {
case JSR179_STATUSCODE_OK:
case JSR179_STATUSCODE_FAIL:
break;
case JSR179_STATUSCODE_INVALID_ARGUMENT:
/* wrong provider name */
KNI_ThrowNew(midpIllegalArgumentException, "wrong provider");
break;
case JSR179_STATUSCODE_WOULD_BLOCK:
/* wait for javanotify */
pInfo = getProviderInfo(provider);
if(pInfo != NULL) {
pInfo->locked = KNI_FALSE;
}
lock_thread(JSR179_EVENT_UPDATE_ONCE, provider);
break;
default:
break;
}
}
KNI_ReturnVoid();
}
示例8: KNIDECL
/*
* Retrieves service record from the service search result.
*
* @param recHandle native handle of the service record
* @param array byte array which will receive the data,
* or null for size query
* @return size of the data read/required
*/
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_jsr082_bluetooth_SDPTransaction_getServiceRecord0)
{
jint retval = 0;
javacall_handle id = 0;
javacall_uint8 *data = NULL;
javacall_uint16 size = 0;
KNI_StartHandles(1);
KNI_DeclareHandle(dataHandle);
KNI_GetParameterAsObject(2, dataHandle);
id = (javacall_handle)KNI_GetParameterAsInt(1);
if (!KNI_IsNullHandle(dataHandle))
size = KNI_GetArrayLength(dataHandle);
data = JAVAME_MALLOC(size);
if (data == NULL) {
KNI_ThrowNew(jsropOutOfMemoryError, "Out of memory inside SDDB.readRecord()");
} else {
if (javacall_bt_sdp_get_service(id, data, &size) == JAVACALL_OK) {
retval = size;
if (!KNI_IsNullHandle(dataHandle)) {
KNI_SetRawArrayRegion(dataHandle, 0, size, data);
}
} else {
retval = 0;
}
JAVAME_FREE(data);
}
KNI_EndHandles();
KNI_ReturnInt(retval);
}
示例9: KNIDECL
/* JAVADOC COMMENT ELIDED */
KNIEXPORT KNI_RETURNTYPE_INT
KNIDECL(com_sun_j2me_location_LocationPersistentStorage_openLandmarkList) {
javacall_handle hndl = 0;
javacall_result res;
KNI_StartHandles(2);
GET_PARAMETER_AS_UTF16_STRING(1, storeName)
GET_PARAMETER_AS_UTF16_STRING(2, categoryName)
res = javacall_landmarkstore_landmarklist_open(storeName, categoryName, &hndl);
switch (res) {
case JAVACALL_OK:
/* Category list open successfully */
break;
case JAVACALL_INVALID_ARGUMENT:
/* wrong category name */
break;
default:
/* operation Failed */
KNI_ThrowNew(jsropIOException, "I/O error");
break;
}
RELEASE_UTF16_STRING_PARAMETER
RELEASE_UTF16_STRING_PARAMETER
KNI_EndHandles();
KNI_ReturnInt((jint)hndl);
}
示例10: Java_javax_microedition_lcdui_CustomItemLFImpl_setContentBuffer0
/**
* Sets the content buffer. All paints are done to that buffer.
* When paint is processed snapshot of the buffer is flushed to
* the native resource content area.
* Native implementation of Java function:
* private static native int setContentBuffer0 ( int nativeId, Image img );
* @param nativeId native resource is for this CustomItem
* @param img mutable image that serves as an offscreen buffer
*/
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_lcdui_CustomItemLFImpl_setContentBuffer0() {
MidpError err = KNI_OK;
unsigned char* imgPtr = NULL;
MidpItem *ciPtr = (MidpItem *)KNI_GetParameterAsInt(1);
KNI_StartHandles(1);
KNI_DeclareHandle(image);
KNI_GetParameterAsObject(2, image);
if (KNI_IsNullHandle(image) != KNI_TRUE) {
imgPtr = gxp_get_imagedata(image);
}
KNI_EndHandles();
err = lfpport_customitem_set_content_buffer(ciPtr, imgPtr);
if (err != KNI_OK) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
}
KNI_ReturnVoid();
}
示例11: KNIDECL
/**
* Perform a platform-defined procedure for obtaining random bytes and
* store the obtained bytes into b, starting from index 0.
* (see IETF RFC 1750, Randomness Recommendations for Security,
* http://www.ietf.org/rfc/rfc1750.txt)
* @param b array that receives random bytes
* @param nbytes the number of random bytes to receive, must not be less than size of b
* @return the number of actually obtained random bytes, -1 in case of an error
*/
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
KNIDECL(com_sun_midp_crypto_PRand_getRandomBytes) {
jint size;
jboolean res = KNI_FALSE;
unsigned char* buffer;
KNI_StartHandles(1);
KNI_DeclareHandle(hBytes);
KNI_GetParameterAsObject(1, hBytes);
size = KNI_GetParameterAsInt(2);
buffer = pcsl_mem_malloc(size);
if (0 == buffer) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
} else {
int i;
res = get_random_bytes_port(buffer, size);
for(i=0; i<size; i++) {
KNI_SetByteArrayElement(hBytes,i,(jbyte)buffer[i]);
}
pcsl_mem_free(buffer);
}
KNI_EndHandles();
KNI_ReturnBoolean(res);
}
示例12: Java_com_sun_cldc_i18n_j2me_Conv_sizeOfUnicodeInByte
/**
* Gets the length of a specific converted string as an array of
* Unicode characters.
* <p>
* Java declaration:
* <pre>
* sizeOfUnicodeInByte(I[CII)I
* </pre>
*
* @param handler handle returned from getHandler
* @param c buffer of characters to be converted
* @param offset offset into the provided buffer
* @param length length of data to be processed
*
* @return length of the converted string, or zero if the
* arguments were not valid
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_cldc_i18n_j2me_Conv_sizeOfUnicodeInByte() {
int length = KNI_GetParameterAsInt(4);
int offset = KNI_GetParameterAsInt(3);
int id = KNI_GetParameterAsInt(1);
jchar *buf;
jint result = 0;
KNI_StartHandles(1);
KNI_DeclareHandle(c);
KNI_GetParameterAsObject(2, c);
/* Instead of always multiplying the length by sizeof(jchar),
* we shift left by 1. This can be done because jchar has a
* size of 2 bytes.
*/
buf = (jchar*)midpMalloc(length<<1);
if (buf == NULL) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
} else {
KNI_GetRawArrayRegion(c, offset<<1, length<<1, (jbyte*)buf);
result = lcConv[id]
? lcConv[id]->sizeOfUnicodeInByte((const jchar *)buf,
offset, length)
: 0;
midpFree(buf);
}
KNI_EndHandles();
KNI_ReturnInt(result);
}
示例13: Java_com_sun_cldc_i18n_j2me_Conv_sizeOfByteInUnicode
/**
* Gets the length of a specific converted string as an array of
* Unicode bytes.
* <p>
* Java declaration:
* <pre>
* sizeOfByteInUnicode(I[BII)I
* </pre>
*
* @param handler handle returned from getHandler
* @param b buffer of bytes to be converted
* @param offset offset into the provided buffer
* @param length length of data to be processed
*
* @return length of the converted string, or zero if the
* arguments were not valid
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_cldc_i18n_j2me_Conv_sizeOfByteInUnicode() {
int length = KNI_GetParameterAsInt(4);
int offset = KNI_GetParameterAsInt(3);
int id = KNI_GetParameterAsInt(1);
char *buf;
jint result = 0;
KNI_StartHandles(1);
KNI_DeclareHandle(b);
KNI_GetParameterAsObject(2, b);
buf = (char*)midpMalloc(length);
if (buf == NULL) {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
} else {
KNI_GetRawArrayRegion(b, offset, length, (jbyte*)buf);
result = lcConv[id]
? lcConv[id]->sizeOfByteInUnicode((const unsigned char *)buf,
offset, length)
: 0;
midpFree(buf);
}
KNI_EndHandles();
KNI_ReturnInt(result);
}
示例14: Java_com_sun_cldc_i18n_j2me_Conv_getHandler
/**
* Gets a handle to specific character encoding conversion routine.
* <p>
* Java declaration:
* <pre>
* getHandler(Ljava/lang/String;)I
* </pre>
*
* @param encoding character encoding
*
* @return identifier for requested handler, or <tt>-1</tt> if
* the encoding was not supported.
*/
KNIEXPORT KNI_RETURNTYPE_INT
Java_com_sun_cldc_i18n_j2me_Conv_getHandler() {
jint result = 0;
KNI_StartHandles(1);
KNI_DeclareHandle(str);
KNI_GetParameterAsObject(1, str);
if (!KNI_IsNullHandle(str)) {
int strLen = KNI_GetStringLength(str);
jchar* strBuf;
/* Instead of always multiplying the length by sizeof(jchar),
* we shift left by 1. This can be done because jchar has a
* size of 2 bytes.
*/
strBuf = (jchar*)midpMalloc(strLen<<1);
if (strBuf != NULL) {
KNI_GetStringRegion(str, 0, strLen, strBuf);
result = getLcConvMethodsID(strBuf, strLen);
midpFree(strBuf);
} else {
KNI_ThrowNew(midpOutOfMemoryError, NULL);
}
}
KNI_EndHandles();
KNI_ReturnInt(result);
}
示例15: Java_com_sun_midp_content_RegistryStore_getHandler0
/**
* java call:
* private native String getHandler0(String callerId, String id, int mode);
*/
KNIEXPORT KNI_RETURNTYPE_OBJECT
Java_com_sun_midp_content_RegistryStore_getHandler0(void) {
int mode;
pcsl_string callerId = PCSL_STRING_NULL_INITIALIZER;
pcsl_string id = PCSL_STRING_NULL_INITIALIZER;
JSR211_RESULT_CH handler = _JSR211_RESULT_INITIALIZER_;
KNI_StartHandles(2);
KNI_DeclareHandle(callerObj);
KNI_DeclareHandle(handlerObj);
do {
KNI_GetParameterAsObject(1, callerObj);
KNI_GetParameterAsObject(2, handlerObj);
if (PCSL_STRING_OK != midp_jstring_to_pcsl_string(callerObj, &callerId) ||
PCSL_STRING_OK != midp_jstring_to_pcsl_string(handlerObj, &id)) {
KNI_ThrowNew(midpOutOfMemoryError,
"RegistryStore_getHandler0 no memory for string arguments");
break;
}
mode = KNI_GetParameterAsInt(3);
jsr211_get_handler(&callerId, &id, mode, &handler);
} while (0);
pcsl_string_free(&callerId);
pcsl_string_free(&id);
result2string((_JSR211_INTERNAL_RESULT_BUFFER_*)&handler, handlerObj);
KNI_EndHandlesAndReturnObject(handlerObj);
}