Correct SIGSEGV with forwarders.
[SquirrelJME.git] / emulators / emulator-base / src / main / c / mle_task.c
blob6216140df3df2dba7f8312c930026e35f04c7d1d
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 <stdio.h>
12 #include "squirreljme.h"
14 // The class to forward to
15 #define TASK_CLASSNAME "cc/squirreljme/emulator/EmulatedTaskShelf"
17 #define TASK_START_DESC "([Lcc/squirreljme/jvm/mle/brackets/JarPackageBracket;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;II)Lcc/squirreljme/jvm/mle/brackets/TaskBracket;"
18 #define TASK_STATUS_DESC "(Lcc/squirreljme/jvm/mle/brackets/TaskBracket;)I"
20 JNIEXPORT jobject JNICALL Impl_mle_TaskShelf_start(
21 JNIEnv* env, jclass classy, jobjectArray classPath, jstring mainClass,
22 jobjectArray args, jobjectArray sysPropPairs, jint stdOut, jint stdErr)
24 return forwardCallStaticObject(env, TASK_CLASSNAME,
25 "start", TASK_START_DESC,
26 classPath, mainClass, args, sysPropPairs, stdOut, stdErr);
29 JNIEXPORT jint JNICALL Impl_mle_TaskShelf_status(
30 JNIEnv* env, jclass classy, jobject task)
32 return forwardCallStaticInteger(env, TASK_CLASSNAME,
33 "status", TASK_STATUS_DESC,
34 task);
37 static const JNINativeMethod mleTaskMethods[] =
39 {"start", TASK_START_DESC, (void*)Impl_mle_TaskShelf_start},
40 {"status", TASK_STATUS_DESC, (void*)Impl_mle_TaskShelf_status},
43 jint JNICALL mleTaskInit(JNIEnv* env, jclass classy)
45 return (*env)->RegisterNatives(env,
46 (*env)->FindClass(env, "cc/squirreljme/jvm/mle/TaskShelf"),
47 mleTaskMethods, sizeof(mleTaskMethods) /
48 sizeof(JNINativeMethod));