Make sjme_nvm_boot return an error code.
[SquirrelJME.git] / nanocoat / frontend / emulator / nativeNvmState.c
blob6016edb16f03544b858d85964cd1e2b3fac8a977
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/boot.h"
15 #define SJME_CLASS_NVM_STATE cc_squirreljme_vm_nanocoat_NvmState
17 jlong SJME_JNI_METHOD(SJME_CLASS_NVM_STATE, _1_1nvmBoot)
18 (JNIEnv* env, jclass classy, jlong poolPtr, jobject wrapper)
20 sjme_nvm_state* state;
21 sjme_errorCode error;
23 /* Initialize new state. */
24 state = NULL;
25 if (SJME_ERROR_CODE_NONE != (error = sjme_nvm_boot(
26 SJME_JLONG_TO_POINTER(sjme_alloc_pool*, poolPtr),
27 NULL, &state, 0, NULL)) || state == NULL)
29 sjme_jni_throwVMException(env, error);
30 return 0;
33 /* Set self reference object, we need a global reference for it. */
34 state->frontEndWrapper = SJME_FRONT_END_WRAP(
35 (*env)->NewGlobalRef(env, wrapper));
37 /* Use pointer to the state. */
38 return SJME_POINTER_TO_JLONG(state);