src/main/c/jnlua.c
static int writehandler(lua_State *L, const void *data, size_t size, void *ud) {
	Stream *stream;

	stream = (Stream *)ud;
	if (!stream->bytes) {
		stream->bytes = (*thread_env)->GetByteArrayElements(thread_env, stream->byte_array, &stream->is_copy);
		if (!stream->bytes) {
			(*thread_env)->ThrowNew(thread_env, ioexception_class, "JNI error: GetByteArrayElements() failed accessing IO buffer");
			return 1;
		}
	}
	memcpy(stream->bytes, data, size);
	if (stream->is_copy) {
		(*thread_env)->ReleaseByteArrayElements(thread_env, stream->byte_array, stream->bytes, JNI_COMMIT);
	}
	(*thread_env)->CallVoidMethod(thread_env, stream->stream, write_id, stream->byte_array, 0, size);
	if ((*thread_env)->ExceptionCheck(thread_env)) {
		return 1;
	}
	return 0;
}
/* Lua writer for Java output streams. */
Lua writer for Java output streams.
Lua writer for Java output streams .
static int writehandler(lua_State *L, const void *data, size_t size, void *ud) {
	Stream *stream;
	stream = (Stream *)ud;
	if (!stream->bytes) {
		stream->bytes = (*thread_env)->GetByteArrayElements(thread_env, stream->byte_array, &stream->is_copy);
		if (!stream->bytes) {
			(*thread_env)->ThrowNew(thread_env, ioexception_class, "JNI error: GetByteArrayElements() failed accessing IO buffer");
			return 1;
		}
	}
	memcpy(stream->bytes, data, size);
	if (stream->is_copy) {
		(*thread_env)->ReleaseByteArrayElements(thread_env, stream->byte_array, stream->bytes, JNI_COMMIT);
	}
	(*thread_env)->CallVoidMethod(thread_env, stream->stream, write_id, stream->byte_array, 0, size);
	if ((*thread_env)->ExceptionCheck(thread_env)) {
		return 1;
	}
	return 0;
}
static int writehandler ( lua_State * L , const void * data , size_t size , void * ud ) { Stream * stream ; stream = ( Stream * ) ud ; if ( ! stream -> bytes ) { stream -> bytes = ( * thread_env ) -> GetByteArrayElements ( thread_env , stream -> byte_array , & stream -> is_copy ) ; if ( ! stream -> bytes ) { ( * thread_env ) -> ThrowNew ( thread_env , ioexception_class , " " ) ; return 1 ; } } memcpy ( stream -> bytes , data , size ) ; if ( stream -> is_copy ) { ( * thread_env ) -> ReleaseByteArrayElements ( thread_env , stream -> byte_array , stream -> bytes , JNI_COMMIT ) ; } ( * thread_env ) -> CallVoidMethod ( thread_env , stream -> stream , write_id , stream -> byte_array , 0 , size ) ; if ( ( * thread_env ) -> ExceptionCheck ( thread_env ) ) { return 1 ; } return 0 ; }
Lua writer for Java output streams.
Lua writer for Java output streams .