static void get (JNIEnv *_env, jobject _this, jint pname, JTYPEARRAY params_ref, jint offset) { jint _exception = 0; const char * _exceptionType; const char * _exceptionMessage; CTYPE *params_base = (CTYPE *) 0; jint _remaining; CTYPE *params = (CTYPE *) 0; int _needed = 0; if (!params_ref) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "params == null"; goto exit; } if (offset < 0) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "offset < 0"; goto exit; } _remaining = _env->GetArrayLength(params_ref) - offset; _needed = getNeededCount(pname); // if we didn't find this pname, we just assume the user passed // an array of the right size -- this might happen with extensions // or if we forget an enum here. if (_remaining < _needed) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "length - offset < needed"; goto exit; } params_base = (CTYPE *) _env->GetPrimitiveArrayCritical(params_ref, (jboolean *)0); params = params_base + offset; GET( (GLenum)pname, (CTYPE *)params ); exit: if (params_base) { _env->ReleasePrimitiveArrayCritical(params_ref, params_base, _exception ? JNI_ABORT: 0); } if (_exception) { jniThrowException(_env, _exceptionType, _exceptionMessage); } }
static void getarray (JNIEnv *_env, jobject _this, jint pname, jobject params_buf) { jint _exception = 0; const char * _exceptionType; const char * _exceptionMessage; JTYPEARRAY _array = (JTYPEARRAY) 0; jint _bufferOffset = (jint) 0; jint _remaining; CTYPE *params = (CTYPE *) 0; int _needed = 0; params = (CTYPE *)getPointer(_env, params_buf, (jarray*)&_array, &_remaining, &_bufferOffset); _remaining /= sizeof(CTYPE); // convert from bytes to item count _needed = getNeededCount(pname); // if we didn't find this pname, we just assume the user passed // an array of the right size -- this might happen with extensions // or if we forget an enum here. if (_needed>0 && _remaining < _needed) { _exception = 1; _exceptionType = "java/lang/IllegalArgumentException"; _exceptionMessage = "remaining() < needed"; goto exit; } if (params == NULL) { char * _paramsBase = (char *) getArrayPointer<JTYPEARRAY, ARRAYGETTER>( _env, _array, (jboolean *) 0); params = (CTYPE *) (_paramsBase + _bufferOffset); } GET( (GLenum)pname, (CTYPE *)params ); exit: if (_array) { releaseArrayPointer<JTYPEARRAY, NTYPEARRAY, ARRAYRELEASER>( _env, _array, (NTYPEARRAY)params, _exception ? JNI_FALSE : JNI_TRUE); } if (_exception) { jniThrowException(_env, _exceptionType, _exceptionMessage); } }