jqioajerifjiorwji
This commit is contained in:
2
Makefile
2
Makefile
@@ -19,7 +19,7 @@ all: java $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CXX) -shared -o ${BASE_NPATH}/$(TARGET) \
|
||||
$(OBJS) ${BASE_NPATH}/libneonucleus.a $(TLA_PATH)/libtla.a -lc $(LD_FLAGS)
|
||||
$(OBJS) ${BASE_NPATH}/libneonucleus.a $(TLA_PATH)/libtla.a $(TLA_PATH)/foreign/lua54/liblua.a -lc $(LD_FLAGS)
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux $(CFLAGS) \
|
||||
$< -o $@
|
||||
|
||||
@@ -24,19 +24,26 @@ public class NativeBindings {
|
||||
eeprom.free();
|
||||
nn_Computer computer = nn_createComputer(universe, UUID.randomUUID().toString(), 4096, 100, 100);
|
||||
nn_setCallBudget(computer, 0);
|
||||
System.out.println("Arch: " + arch.name);
|
||||
nn_setArchitecture(computer, arch);
|
||||
System.out.println("past setArch");
|
||||
nn_addSupportedArchitecture(computer, arch);
|
||||
System.out.println("past addSupported");
|
||||
nn_mountComponent(computer, eepromCard, 0, false);
|
||||
System.out.println("past mountComponent");
|
||||
nn_Exit e = nn_tick(computer);
|
||||
System.out.println("ticked");
|
||||
if (e != nn_Exit.NN_OK) {
|
||||
System.out.println("NN tick error: " + nn_getError(computer));
|
||||
return;
|
||||
}
|
||||
System.out.println("sync ticked");
|
||||
e = nn_tickSynchronized(computer);
|
||||
if (e != nn_Exit.NN_OK) {
|
||||
System.out.println("NN synchronized tick error: " + nn_getError(computer));
|
||||
return;
|
||||
}
|
||||
System.out.println("getting state");
|
||||
nn_ComputerState state = nn_getComputerState(computer);
|
||||
if(state == nn_ComputerState.NN_POWEROFF) return;
|
||||
if(state == nn_ComputerState.NN_CRASHED) {
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
#include "carbon.hpp"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
// redefine it here with the impl
|
||||
// theres probably a better way to do this
|
||||
#define CARBON_JNI_EXCEPTION_CHECK() if (env->ExceptionCheck()) return NULL;
|
||||
#define CARBON_EXCEPTION_FUNC(fname, classpath) jint fname(JNIEnv* env, const char* message) { return THROW_EXCEPTION(classpath, message); }
|
||||
#define CARBON_MAP_TO_NN_EXIT(enumcase) case enumcase: {\
|
||||
jfieldID id = env->GetFieldID(clazz, #enumcase, "Lorg.neoflock.NeoNucleus.nn_Exit;");\
|
||||
return env->GetStaticObjectField(clazz, id);\
|
||||
jfieldID id = env->GetStaticFieldID(clazz, #enumcase, "Lorg/neoflock/NeoNucleus/nn_Exit;");\
|
||||
CARBON_JNI_EXCEPTION_CHECK();\
|
||||
jobject obj = env->GetStaticObjectField(clazz, id);\
|
||||
CARBON_JNI_EXCEPTION_CHECK();\
|
||||
return obj;\
|
||||
}
|
||||
#define CARBON_MAP_TO_NN_COMPUTERSTATE(enumcase) case enumcase: {\
|
||||
jfieldID id = env->GetFieldID(clazz, #enumcase, "Lorg.neoflock.NeoNucleus.nn_ComputerState;");\
|
||||
jfieldID id = env->GetFieldID(clazz, #enumcase, "Lorg/neoflock/NeoNucleus/nn_ComputerState;");\
|
||||
CARBON_JNI_EXCEPTION_CHECK()\
|
||||
return env->GetStaticObjectField(clazz, id);\
|
||||
}
|
||||
|
||||
@@ -66,6 +73,7 @@ nn_Exit Carbon::JNIComponentHandler(nn_ComponentRequest* request) {
|
||||
}
|
||||
jobject Carbon::Map::To_nn_Exit(JNIEnv* env, nn_Exit a) {
|
||||
jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Exit");
|
||||
CARBON_JNI_EXCEPTION_CHECK();
|
||||
switch (a) {
|
||||
CARBON_MAP_TO_NN_EXIT(NN_OK)
|
||||
CARBON_MAP_TO_NN_EXIT(NN_ENOMEM)
|
||||
@@ -105,7 +113,22 @@ jobject Carbon::Map::To_nn_Architecture(JNIEnv* env, nn_Architecture a) {
|
||||
jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Architecture");
|
||||
jmethodID consMID = env->GetMethodID(clazz, "<init>", "(Ljava/lang/String;)V");
|
||||
jstring str = env->NewStringUTF(a.name);
|
||||
return env->NewObject(clazz, consMID, str);
|
||||
jobject obj = env->NewObject(clazz, consMID, str);
|
||||
printf("malloc\n");
|
||||
nn_Architecture* data = (nn_Architecture*) malloc(sizeof(nn_Architecture));
|
||||
if (data == NULL) {
|
||||
printf("null data\n");
|
||||
return NULL;
|
||||
}
|
||||
printf("memcpy\n");
|
||||
memcpy(data, &a, sizeof(nn_Architecture));
|
||||
printf("setptr\n");
|
||||
if (!Carbon::PointerBacked::SetPointer(env, obj, data)) {
|
||||
printf("SetPointer is false");
|
||||
return NULL;
|
||||
}
|
||||
printf("return\n");
|
||||
return obj;
|
||||
}
|
||||
namespace Carbon::Exceptions {
|
||||
CARBON_EXCEPTION_FUNC(ThrowNullPtr, "java/lang/NullPointerException");
|
||||
|
||||
@@ -212,7 +212,9 @@ JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1addSup
|
||||
NULLPTR_CHECK(nnPC, nn_Computer);
|
||||
NULLPTR_CHECK(nnArch, nn_Architecture);
|
||||
|
||||
nn_addSupportedArchitecture(nnPC, nnArch);
|
||||
return Carbon::Map::To_nn_Exit(env, nn_addSupportedArchitecture(nnPC, nnArch));
|
||||
//nn_addSupportedArchitecture(nnPC, nnArch);
|
||||
//return NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setTmpAddress
|
||||
|
||||
Reference in New Issue
Block a user