Compile fixes.
[SquirrelJME.git] / nanocoat / frontend / emulator / nativeNvmState.c
blob87e795a77fe986db8e221b276646c5850b505ac0
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 #include <jni.h>
12 #include "frontend/emulator/jniHelper.h"
13 #include "sjme/nvm/boot.h"
15 jlong SJME_JNI_METHOD(SJME_CLASS_NVM_STATE, _1_1nvmBoot)
16 (JNIEnv* env, jclass classy, jlong poolPtr, jlong reservedPtr,
17 jobject wrapper, jlong paramPtr)
19 sjme_nvm state;
20 sjme_errorCode error;
22 if (poolPtr == 0 || reservedPtr == 0 || wrapper == NULL || paramPtr == 0)
24 sjme_jni_throwVMException(env, SJME_ERROR_NULL_ARGUMENTS);
25 return 0;
28 /* Initialize new state. */
29 state = NULL;
30 if (sjme_error_is(error = sjme_nvm_boot(
31 SJME_JLONG_TO_POINTER(sjme_alloc_pool*, poolPtr),
32 SJME_JLONG_TO_POINTER(sjme_alloc_pool*, reservedPtr),
33 SJME_JLONG_TO_POINTER(const sjme_nvm_bootParam*, paramPtr),
34 &state)) || state == NULL)
36 sjme_jni_throwVMException(env, error);
37 return 0;
40 /* Set self reference object, we need a global reference for it. */
41 state->common.frontEnd.data = env;
42 state->common.frontEnd.wrapper = SJME_FRONT_END_WRAP(
43 (*env)->NewGlobalRef(env, wrapper));
45 /* Use pointer to the state. */
46 return SJME_POINTER_TO_JLONG(state);