first commit

This commit is contained in:
2026-05-25 21:33:48 -03:00
commit ad9176d909
42 changed files with 5788 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
*.o
*.so
*.a
*.class
hs_err_pid*.log

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "NeoNucleus"]
path = NeoNucleus
url = https://gitea.codersquack.nl/NeoFlock/NeoNucleus.git

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/lib/jvm/java-25-openjdk/include",
"/usr/lib/jvm/java-25-openjdk/include/linux"
],
"defines": [],
"compilerPath": "/usr/lib64/ccache/clang",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"makefile.configureOnOpen": false
}

35
Makefile Normal file
View File

@@ -0,0 +1,35 @@
CC=gcc
CXX=g++
CFLAGS=-Wall -Wextra
TARGET=libneonucleusjni.so
BASE_PATH=./src/main/org/neoflock/NeoNucleus
JAVA_HOME=/usr/lib/jvm/java-25-openjdk/
BASE_NPATH=./src/native/
JAVA_SRCS = $(wildcard ./src/main/org/neoflock/NeoNucleus/*.java)
JAVA_CLASSES = $(wildcard ./src/main/org/neoflock/NeoNucleus/*.class)
CPP_SRCS = $(wildcard ${BASE_NPATH}/*.cpp)
OBJS = $(CPP_SRCS:.cpp=.o)
NATIVE_NAME=main
all: $(TARGET)
$(TARGET): $(OBJS)
g++ -shared -o ${BASE_NPATH}/$(TARGET) \
$(OBJS) ${BASE_NPATH}/libneonucleus.a -lc
%.o: %.cpp
$(CXX) -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux $(CFLAGS) \
$< -o $@
java: ${JAVA_CLASSES}
javac -h ./src/native/ ${JAVA_SRCS}
run: all
cd src/main && java -cp . -Djava.library.path=${PWD}/${BASE_NPATH} -Xcheck:jni org.neoflock.NeoNucleus.NativeBindings
clean:
rm ${JAVA_CLASSES}
rm $(OBJS) $(TARGET)
.PHONY: all clean

1
NeoNucleus Submodule

Submodule NeoNucleus added at 3b04fd45c7

4
README.md Normal file
View File

@@ -0,0 +1,4 @@
# Carbon Hydrogen
NeoNucleus JNI bindings.
### Dev Setup Notes
Java expects libneonucleusjni.so on the src/native directory. This is the default unless you're not using the Makefile.

14
build.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/bash
# deprecated, use Makefile instead
BASE_PATH=./src/main/org/neoflock/NeoNucleus
JAVA_HOME=/usr/lib/jvm/java-21-openjdk/
BASE_NPATH=./src/native/
#NATIVE_NAME=org_neoflock_NeoNucleus_NativeBindings
NATIVE_NAME=main
echo ":: Building java class"
javac -h ./src/native/ $BASE_PATH/NativeBindings.java $BASE_PATH/Context.java $BASE_PATH/Universe.java $BASE_PATH/PointerBackedClass.java $BASE_PATH/ExitCode.java $BASE_PATH/Architecture.java $BASE_PATH/ManuallyAllocated.java
echo ":: Compiling"
g++ -c -fPIC -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux ${BASE_NPATH}/${NATIVE_NAME}.cpp -o ${BASE_NPATH}/${NATIVE_NAME}.o
echo ":: Linking"
g++ -shared -o ${BASE_NPATH}/libneonucleusjni.so ${BASE_NPATH}/${NATIVE_NAME}.o ${BASE_NPATH}/libneonucleus.a -lc

5
run.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/bash
# deprecated, use Makefile instead
NLIB_PATH=$PWD/src/native/
cd src/main && java -cp . -Djava.library.path=${NLIB_PATH} org.neoflock.NeoNucleus.NativeBindings
cd ../..

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public interface ComponentHandler {
// TODO
}

View File

@@ -0,0 +1,7 @@
package org.neoflock.NeoNucleus;
public sealed class ComponentState extends PointerBackedClass permits ncl_ScreenState {
// TODO
// opaque class, you'll need to cast it to do anything
protected ComponentState() {}
}

View File

@@ -0,0 +1,6 @@
package org.neoflock.NeoNucleus;
public interface ManuallyAllocated {
boolean allocate();
boolean free();
}

View File

@@ -0,0 +1,135 @@
package org.neoflock.NeoNucleus;
public class NativeBindings {
static {
System.loadLibrary("neonucleusjni");
}
public static void main(String[] args) {
//nn_Context ctx = nn_initContext();
nn_EEPROM eeprom = new nn_EEPROM(100, 200, 300, 400, 0, 0, 0, 0);
eeprom.allocate();
System.out.println("we live");
eeprom.free();
System.out.println("about to double free");
eeprom.free();
//System.out.println(ctx.ptr);
}
public static native nn_Context nn_initContext();
public static native void nn_initPalettes();
// nn_Universe *nn_createUniverse(nn_Context *ctx, void *userdata)
public static native nn_Universe nn_createUniverse(nn_Context ctx);
// nn_Component *nn_createComponent(nn_Universe *universe, const char *address, const char *type)
public static native nn_Component nn_createComponent(nn_Universe universe, String address, String type);
public static native nn_Exit nn_setComponentMethods(nn_Component component, nn_Method[] methods);
// void nn_setComponentHandler(nn_Component *c, nn_ComponentHandler *handler)
public static native void nn_setComponentHandler(nn_Component component, ComponentHandler handler);
// nn_Exit nn_mountComponent(nn_Computer *c, nn_Component *comp, int slot, bool silent)
public static native nn_Exit nn_mountComponent(nn_Computer c, nn_Component comp, int slot, boolean silent);
// nn_Component *ncl_createEEPROM(nn_Universe *universe, const char *address, const nn_EEPROM *eeprom, const char *code, size_t codelen, bool isReadonly)
public static native nn_Component ncl_createEEPROM(nn_Universe universe, String address, nn_EEPROM eeprom, String code, boolean isReadonly);
// nn_Computer *nn_createComputer(nn_Universe *universe, void *userdata, const char *address, size_t totalMemory, size_t maxComponents, size_t maxDevices)
public static native nn_Computer nn_createComputer(nn_Universe universe, String address, long totalMemory, long maxComponents, long maxDevices);
// void nn_setComputerEnvironment(nn_Computer *computer, nn_Environment env)
public static native void nn_setComputerEnvironment(nn_Computer computer, nn_Environment env);
// void nn_setCallBudget(nn_Computer *computer, double budget)
public static native void nn_setCallBudget(nn_Computer computer, double budget);
// void nn_setTotalEnergy(nn_Computer *computer, double maxEnergy)
public static native void nn_setTotalEnergy(nn_Computer computer, double maxEnergy);
// void nn_setArchitecture(nn_Computer *computer, const nn_Architecture *arch)
public static native void nn_setArchitecture(nn_Computer computer, nn_Architecture arch);
// nn_Exit nn_addSupportedArchitecture(nn_Computer *computer, const nn_Architecture *arch)
public static native nn_Exit nn_addSupportedArchitecture(nn_Computer computer, nn_Architecture arch);
// nn_Exit nn_setTmpAddress(nn_Computer *computer, const char *address)
/**
* address is copied.
* It can be NULL if you wish to have no tmp address.
* It can fail due to out-of-memory errors.
*/
public static native nn_Exit nn_setTmpAddress(nn_Computer computer, String address);
// const char *nn_getComponentAddress(nn_Component *c)
public static native String nn_getComponentAddress(nn_Component c);
// nn_Exit nn_addCommonDeviceInfo(nn_Computer *computer, const char *addr, nn_CommonDeviceInfo info)
public static native nn_Exit nn_addCommonDeviceInfo(nn_Computer computer, String addr, nn_CommonDeviceInfo info);
// it doesn't really make sense to implement nn_clearCommonDeviceInfo, so it wont be.
// void *nn_getComponentState(nn_Component *c)
public static native ComponentState nn_getComponentState(nn_Component c);
// void ncl_lockScreen(ncl_ScreenState *state)
public static native void ncl_lockScreen(ncl_ScreenState state);
// void ncl_getScreenViewport(const ncl_ScreenState *state, size_t *width, size_t *height)
public static native Resolution ncl_getScreenViewport(ncl_ScreenState state);
// void ncl_setScreenViewport(ncl_ScreenState *state, size_t width, size_t height)
public static native void ncl_setScreenViewport(ncl_ScreenState state, long width, long height);
// ncl_ScreenFlags ncl_getScreenFlags(const ncl_ScreenState *state)
public static native ncl_ScreenFlags ncl_getScreenFlags(ncl_ScreenState state);
// int ncl_cellHeight(ncl_GlyphCache *gc)
//public static native int ncl_cellHeight(ncl_GlyphCache gc);
// void ncl_destroyGlyphCache(ncl_GlyphCache *gc)
//public static native void ncl_destroyGlyphCache(ncl_GlyphCache gc);
// ncl_GlyphCache *ncl_createGlyphCache(const char *fontPath, int fontSize)
//public static native ncl_GlyphCache ncl_createGlyphCache(String fontPath, int fontSize);
// int ncl_cellWidth(ncl_GlyphCache *gc)
//public static native int ncl_cellWidth(ncl_GlyphCache gc);
// double ncl_getScreenBrightness(ncl_ScreenState *state)
public static native double ncl_getScreenBrightness(ncl_ScreenState state);
// ncl_Pixel ncl_getScreenPixel(const ncl_ScreenState *state, int x, int y)
public static native ncl_Pixel ncl_getScreenPixel(ncl_ScreenState state, int x, int y);
// void ncl_needGlyph(ncl_GlyphCache *gc, nn_codepoint cp)
/**
* @param gc
* @param cp an nn_codepoint
*/
//public static native void ncl_needGlyph(ncl_GlyphCache gc, int cp);
// void ncl_drawGlyph(ncl_GlyphCache *gc, nn_codepoint cp, Vector2 pos, float size, Color tint)
//public static native void ncl_drawGlyph(ncl_GlyphCache gc, int cp, Vector2 pos, float size, Color tint);
// void ncl_unlockScreen(ncl_ScreenState *state)
public static native void ncl_unlockScreen(ncl_ScreenState state);
// nn_Exit nn_pushTouch(nn_Computer *computer, const char *screenAddress, double x, double y, int button, const char *player)
public static native nn_Exit nn_pushTouch(nn_Computer computer, String screenAddress, double x, double y, int button, String player);
// nn_Exit nn_pushDrop(nn_Computer *computer, const char *screenAddress, double x, double y, int button, const char *player)
public static native nn_Exit nn_pushDrop(nn_Computer computer, String screenAddress, double x, double y, int button, String player);
// nn_Exit nn_pushDrag(nn_Computer *computer, const char *screenAddress, double x, double y, int button, const char *player)
public static native nn_Exit nn_pushDrag(nn_Computer computer, String screenAddress, double x, double y, int button, String player);
// nn_Exit nn_pushScroll(nn_Computer *computer, const char *screenAddress, double x, double y, double direction, const char *player)
public static native nn_Exit nn_pushScroll(nn_Computer computer, String screenAddress, double x, double y, double direction, String player);
// size_t nn_getUsedMemory(nn_Computer *computer)
public static native long nn_getUsedMemory(nn_Computer computer);
// size_t nn_getTotalMemory(nn_Computer *computer)
public static native long nn_getTotalMemory(nn_Computer computer);
// nn_Exit nn_pushClipboard(nn_Computer *computer, const char *keyboardAddress, const char *clipboard, const char *player)
public static native nn_Exit nn_pushClipboard(nn_Computer computer, String keyboardAddress, String clipboard, String player);
// nn_Exit nn_pushKeyDown(nn_Computer *computer, const char *keyboardAddress, nn_codepoint charcode, int keycode, const char *player)
public static native nn_Exit nn_pushKeyDown(nn_Computer computer, String keyboardAddress, int charcode, int keycode, String player);
// nn_Exit nn_pushKeyUp(nn_Computer *computer, const char *keyboardAddress, nn_codepoint charcode, int keycode, const char *player)
public static native nn_Exit nn_pushKeyUp(nn_Computer computer, String keyboardAddress, int charcode, int keycode, String player);
// void nn_clearstack(nn_Computer *computer)
public static native nn_Exit nn_clearstack(nn_Computer computer);
// bool nn_removeEnergy(nn_Computer *computer, double energy)
public static native boolean nn_removeEnergy(nn_Computer computer, double energy);
// nn_Exit nn_tickSynchronized(nn_Computer *computer)
public static native nn_Exit nn_tickSynchronized(nn_Computer computer);
// double ncl_getScreenEnergyUsage(ncl_ScreenState *state)
public static native double ncl_getScreenEnergyUsage(ncl_ScreenState state);
// void nn_resetIdleTime(nn_Computer *computer)
public static native void nn_resetIdleTime(nn_Computer computer);
// nn_Exit nn_tick(nn_Computer *computer)
public static native nn_Exit nn_tick(nn_Computer computer);
// nn_ComputerState nn_getComputerState(nn_Computer *computer)
public static native nn_ComputerState nn_getComputerState(nn_Computer computer);
// const char *nn_getError(nn_Computer *computer)
public static native String nn_getError(nn_Computer computer);
// nn_Architecture nn_getDesiredArchitecture(nn_Computer *computer)
public static native nn_Architecture nn_getDesiredArchitecture(nn_Computer computer);
// void nn_stopComputer(nn_Computer *computer)
public static native void nn_stopComputer(nn_Computer computer);
// void ncl_resetScreen(ncl_ScreenState *state)
public static native void ncl_resetScreen(ncl_ScreenState state);
// void nn_addIdleTime(nn_Computer *computer, double time)
public static native void nn_addIdleTime(nn_Computer computer, double time);
// void nn_destroyComputer(nn_Computer *computer)
public static native void nn_destroyComputer(nn_Computer computer);
// void nn_dropComponent(nn_Component *c)
public static native void nn_dropComponent(nn_Component c);
// void nn_destroyUniverse(nn_Universe *universe)
public static native void nn_destroyUniverse(nn_Universe universe);
}

View File

@@ -0,0 +1,10 @@
package org.neoflock.NeoNucleus;
public class PointerBackedClass {
private long ptr;
/*public static PointerBackedClass createFromPointer(long ptr) {
PointerBackedClass clazz = new PointerBackedClass();
clazz.ptr = ptr;
return clazz;
}*/
}

View File

@@ -0,0 +1,3 @@
package org.neoflock.NeoNucleus;
public record Resolution(long width, long height) {}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
/*public class ncl_GlyphCache {
}*/

View File

@@ -0,0 +1,21 @@
package org.neoflock.NeoNucleus;
/*
typedef struct ncl_Pixel {
// 0xRRGGBB format
unsigned int fgColor;
// 0xRRGGBB format
unsigned int bgColor;
// the codepoint
nn_codepoint codepoint;
} ncl_Pixel;
*/
public class ncl_Pixel {
public final int fgColor;
public final int bgColor;
public final int codepoint;
public ncl_Pixel(int fgColor, int bgColor, int codepoint) {
this.fgColor = fgColor;
this.bgColor = bgColor;
this.codepoint = codepoint;
}
}

View File

@@ -0,0 +1,17 @@
package org.neoflock.NeoNucleus;
/*public enum ncl_ScreenFlags {
NCL_SCREEN_ON(1<<0),
NCL_SCREEN_PRECISE(1<<1),
NCL_SCREEN_TOUCHINVERTED(1<<2);
public final int value;
private ncl_ScreenFlags(int flag) {
this.value = flag;
}
}*/
public class ncl_ScreenFlags {
public static final int NCL_SCREEN_ON = 1<<0;
public static final int NCL_SCREEN_PRECISE = 1<<1;
public static final int NCL_SCREEN_TOUCHINVERTED = 1<<2;
}

View File

@@ -0,0 +1,4 @@
package org.neoflock.NeoNucleus;
// opaque type, not much to do here
public final class ncl_ScreenState extends ComponentState {}

View File

@@ -0,0 +1,21 @@
package org.neoflock.NeoNucleus;
import java.util.function.Function;
public final class nn_Architecture extends PointerBackedClass implements ManuallyAllocated {
public final String name;
public final Function<String, Integer> handler;
public nn_Architecture(String name, Function<String, Integer> handler) { // string is a placeholder; please fix
this.name = name;
this.handler = handler;
}
private int handleNative() { // i aint gonna be trying to call that Function from jni man
return handler.apply("placeholder");
}
public native boolean allocate();
public native boolean free();
}

View File

@@ -0,0 +1,48 @@
package org.neoflock.NeoNucleus;
/* const char *CLASS;
const char *DESC;
const char *VENDOR;
const char *PRODUCT;
const char *VERSION;
const char *SERIAL;
const char *CAPACITY;
const char *SIZE;
const char *CLOCK;
const char *WIDTH; */
public class nn_CommonDeviceInfo {
public final String CLASS;
public final String DESC;
public final String VENDOR;
public final String PRODUCT;
public final String VERSION;
public final String SERIAL;
public final String CAPACITY;
public final String SIZE;
public final String CLOCK;
public final String WIDTH;
public nn_CommonDeviceInfo(
String CLASS,
String DESC,
String VENDOR,
String PRODUCT,
String VERSION,
String SERIAL,
String CAPACITY,
String SIZE,
String CLOCK,
String WIDTH
) {
this.CLASS = CLASS;
this.DESC = DESC;
this.VENDOR = VENDOR;
this.PRODUCT = PRODUCT;
this.VERSION = VERSION;
this.SERIAL = SERIAL;
this.CAPACITY = CAPACITY;
this.SIZE = SIZE;
this.CLOCK = CLOCK;
this.WIDTH = WIDTH;
}
}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public final class nn_Component extends PointerBackedClass {
private nn_Component() {}
}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public class nn_Computer {
// TODO
}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public class nn_ComputerState {
// TODO
}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public class nn_Context extends PointerBackedClass {
public native void free();
}

View File

@@ -0,0 +1,54 @@
package org.neoflock.NeoNucleus;
/*
typedef struct nn_EEPROM {
// the maximum capacity of the EEPROM
size_t size;
// the maximum capacity of the EEPROM's associated data
size_t dataSize;
// the energy cost of reading an EEPROM
double readEnergyCost;
// the energy cost of reading an EEPROM's associated data
double readDataEnergyCost;
// the energy cost of writing to an EEPROM
double writeEnergyCost;
// the energy cost of writing to an EEPROM's associated data
double writeDataEnergyCost;
// idle time added when writing code
double writeDelay;
// idle time added when writing data
double writeDataDelay;
} nn_EEPROM;
*/
public class nn_EEPROM extends PointerBackedClass implements ManuallyAllocated {
public final long size;
public final long dataSize;
public final double readEnergyCost;
public final double readDataEnergyCost;
public final double writeEnergyCost;
public final double writeDataEnergyCost;
public final double writeDelay;
public final double writeDataDelay;
public nn_EEPROM(
long size,
long dataSize,
double readEnergyCost,
double readDataEnergyCost,
double writeEnergyCost,
double writeDataEnergyCost,
double writeDelay,
double writeDataDelay
) {
this.size = size;
this.dataSize = dataSize;
this.readEnergyCost = readEnergyCost;
this.readDataEnergyCost = readDataEnergyCost;
this.writeEnergyCost = writeEnergyCost;
this.writeDataEnergyCost = writeDataEnergyCost;
this.writeDelay = writeDelay;
this.writeDataDelay = writeDataDelay;
}
@Override
public native boolean allocate();
@Override
public native boolean free();
}

View File

@@ -0,0 +1,6 @@
package org.neoflock.NeoNucleus;
public class nn_Environment {
public String a;
// TODO
}

View File

@@ -0,0 +1,18 @@
package org.neoflock.NeoNucleus;
public enum nn_Exit {
// no error
NN_OK,
// out of memory.
NN_ENOMEM,
// over the limit. For example, adding too many architectures to a machine.
NN_ELIMIT,
// internal stack underflow when managing the stack.
NN_EBELOWSTACK,
// internal stack overflow when carrying values.
NN_ENOSTACK,
// bad invocation, error message stored in computer state
NN_EBADCALL,
// bad state, the function was called at the wrong time
NN_EBADSTATE,
}

View File

@@ -0,0 +1,16 @@
package org.neoflock.NeoNucleus;
public class nn_Method {
public final String name;
public final String doc;
public final byte flags;
public nn_Method(
String name,
String doc,
byte flags
) {
this.name = name;
this.doc = doc;
this.flags = flags;
}
}

View File

@@ -0,0 +1,5 @@
package org.neoflock.NeoNucleus;
public class nn_Universe extends PointerBackedClass {
}

82
src/native/carbon.cpp Normal file
View File

@@ -0,0 +1,82 @@
#include "carbon.hpp"
// redefine it here with the impl
// theres probably a better way to do this
#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);
// codename for NN JNI is Carbon because i needed something better than NN JNI
bool Carbon::PointerBacked::SetPointer(JNIEnv * env, jobject obj, void* ptr) {
jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "ptr", "J");
if (id == NULL) return false;
env->SetLongField(obj, id, (jlong) ptr);
return true;
}
void* Carbon::PointerBacked::GetPointer(JNIEnv * env, jobject obj) {
jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "ptr", "J");
IF_NULL_RET(id);
jlong ptr = env->GetLongField(obj, id);
return (void*) ptr;
}
bool Carbon::PointerBacked::ResetPointer(JNIEnv * env, jobject obj) {
jfieldID id = env->GetFieldID(env->GetObjectClass(obj), "ptr", "J");
if (id == NULL) return false;
env->SetLongField(obj, id, (jlong) NULL);
return true;
}
nn_Exit Carbon::archRequestHandler(nn_ArchitectureRequest *req) {
GlobalArchState* gstate = (GlobalArchState*)req->globalState;
JNIEnv* env = gstate->target.env;
jmethodID mid = env->GetMethodID(
env->GetObjectClass(gstate->target.obj), "handleNative", "()V");
// TODO: null check mid
jbyte ret = env->CallByteMethod(gstate->target.obj, mid);
return (nn_Exit) ret; // todo: finish the args; probably an unnecessary cast
}
jobject Carbon::InstantiateOpaqueClass(JNIEnv* env, const char* classpath) {
jclass cls = env->FindClass(classpath);
IF_NULL_RET(cls);
jmethodID methodID = env->GetMethodID(cls, "<init>", "()V");
IF_NULL_RET(methodID);
jobject obj = env->NewObject(cls, methodID);
return obj;
}
// pbc = pointer backed class
jobject Carbon::InstantiateDefaultPBC(JNIEnv* env, const char* classpath, void* ptr) {
jobject clazz = InstantiateOpaqueClass(env, classpath);
IF_NULL_RET(clazz);
Carbon::PointerBacked::SetPointer(env, clazz, ptr); // FIXME: this can silently fail
return clazz;
}
nn_Exit Carbon::JNIComponentHandler(nn_ComponentRequest* request) {
Carbon::JavaObjectTarget* ot = (Carbon::JavaObjectTarget*) request->state; // todo: make this a proper struct with a target for the component handler specifically
if (ot == NULL) return NN_EBADSTATE; // welp
//ud->target.env->
jmethodID callMethod = ot->env->GetMethodID(ot->env->GetObjectClass(ot->obj), "handleRequest", "(Lorg/neoflock/NeoNucleus/nn_ComponentRequest;)Lorg/neoflock/NeoNucleus/nn_Exit;");
jobject retex = ot->env->CallObjectMethod(ot->obj, callMethod, NULL); // todo: args
return Carbon::Map::From_nn_Exit(ot->env, retex);
}
jobject Carbon::Map::To_nn_Exit(JNIEnv* env, nn_Exit a) {
jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Exit");
switch (a) {
CARBON_MAP_TO_NN_EXIT(NN_OK)
CARBON_MAP_TO_NN_EXIT(NN_ENOMEM)
CARBON_MAP_TO_NN_EXIT(NN_ELIMIT)
CARBON_MAP_TO_NN_EXIT(NN_EBELOWSTACK)
CARBON_MAP_TO_NN_EXIT(NN_ENOSTACK)
CARBON_MAP_TO_NN_EXIT(NN_EBADCALL)
CARBON_MAP_TO_NN_EXIT(NN_EBADSTATE)
}
return NULL;
}
nn_Exit From_nn_Exit(JNIEnv* env, jobject a) {
jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Exit");
jmethodID ordMID = env->GetMethodID(clazz, "ordinal", "()I");
jint value = env->CallIntMethod(a, ordMID);
return (nn_Exit) value; // this should be fine as long as the header and java side don't desync
}
namespace Carbon::Exceptions {
CARBON_EXCEPTION_FUNC(ThrowNullPtr, "java/lang/NullPointerException");
}

54
src/native/carbon.hpp Normal file
View File

@@ -0,0 +1,54 @@
#pragma once
#include "neonucleus.h"
#include "org_neoflock_NeoNucleus_NativeBindings.h"
#define IF_NULL_RET(param) if (param == NULL) return NULL;
#define THROW_EXCEPTION(classpath, msg) env->ThrowNew(env->FindClass(classpath), msg);
#define CARBON_EXCEPTION_FUNC(fname, classpath) jint fname(JNIEnv* env, const char* message);
#define NULLPTR_THROW(cname) Carbon::Exceptions::ThrowNullPtr(env, "Received null pointer for " #cname);
#define NULLPTR_CHECK(var, cname) if (var == NULL) {\
NULLPTR_THROW(cname);\
return NULL;\
}
#define NULLPTR_CHECKNR(var, cname) if (var == NULL) {\
NULLPTR_THROW(cname);\
return;\
}
// codename for NN JNI is Carbon because i needed something better than NN JNI
namespace Carbon {
namespace PointerBacked {
bool SetPointer(JNIEnv * env, jobject obj, void* ptr);
void* GetPointer(JNIEnv * env, jobject obj);
bool ResetPointer(JNIEnv * env, jobject obj);
}
namespace Map {
jobject To_nn_Exit(JNIEnv* env, nn_Exit a);
nn_Exit From_nn_Exit(JNIEnv* env, jobject a);
}
typedef struct JavaObjectTarget { // i might lowkey drop this struct
JNIEnv * env;
jobject obj;
} JavaObjectTarget;
typedef struct ComputerUserdata {
JavaObjectTarget target;
} ComputerUserdata;
typedef struct GlobalArchState {
JavaObjectTarget target;
} GlobalArchState;
nn_Exit archRequestHandler(nn_ArchitectureRequest *req);
jobject InstantiateOpaqueClass(JNIEnv* env, const char* classpath);
// pbc = pointer backed class
jobject InstantiateDefaultPBC(JNIEnv* env, const char* classpath, void* ptr);
// typedef nn_Exit (nn_ComponentHandler)(nn_ComponentRequest *request);
nn_Exit JNIComponentHandler(nn_ComponentRequest* request);
bool CallGC(JNIEnv* env);
}
namespace Carbon::Exceptions {
CARBON_EXCEPTION_FUNC(ThrowNullPtr, "java/lang/NullPointerException");
}
#undef CARBON_EXCEPTION_FUNC

170
src/native/main.cpp Normal file
View File

@@ -0,0 +1,170 @@
#include "org_neoflock_NeoNucleus_NativeBindings.h"
#include <iostream>
#include "neonucleus.h"
#include "ncomplib.h"
#include "carbon.hpp"
// TODO: null checks fucking everywhere (thanks java)
// NOTE: almost NOTHING of this has been tested yet
// WARN: **apparently** GetFieldID can error out on OOM, this will not be an issue for now (i think),
// but we need to account for it before or after MVP (modded minecraft is famously known for being memory hungry)
// NOTE: not sure if i should use nn_alloc over malloc where possible
/*nn_Architecture readArch(JNIEnv * env, jobject obj) {
jclass clazz = env->GetObjectClass(obj);
jfieldID nid = env->GetFieldID(clazz, "name", "Ljava.lang.String;");
jstring jstr = (jstring)env->GetObjectField(obj, nid);
const char * name = env->GetStringUTFChars(jstr, (jboolean) false);// this shit will so become invalid after the func
Carbon::GlobalArchState* statePtr = (Carbon::GlobalArchState*)Carbon::PointerBacked::GetPointer(env, obj);
if (statePtr == NULL) {
// we cant just store this on the stack since nn_Architecture wants a *pointer*,
// if i do a pointer to a variable on the stack its just gonna vanish as soon as the function ends
Carbon::GlobalArchState* state = (Carbon::GlobalArchState*)malloc(sizeof(Carbon::GlobalArchState));
*state = {
.target = {
.env = env,
.obj = env->NewGlobalRef(obj)
}
};
}
return (nn_Architecture) {
.name = name,
.state = (void*) statePtr,
.handler = Carbon::archRequestHandler
};
}*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1initContext
(JNIEnv * env, jclass ogClazz) {
//jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Context");
//jmethodID creator = env->GetStaticMethodID(clazz, "createFromPointer", "(J)Lorg/neoflock/NeoNucleus/Context;");
jobject obj = Carbon::InstantiateOpaqueClass(env, "org/neoflock/NeoNucleus/nn_Context");
nn_Context * ctx = (nn_Context*)malloc(sizeof(nn_Context));
nn_initContext(ctx);
//jobject result = env->CallStaticObjectMethod(clazz, creator, (jlong) ctx);
Carbon::PointerBacked::SetPointer(env, obj, ctx);
return obj;
}
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1initPalettes
(JNIEnv *, jclass) { // fucking cakewalk compared to the horrors that'll unfold within this cpp file
nn_initPalettes();
}
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createUniverse
(JNIEnv * env, jclass, jobject ctx) {
nn_Context* nnCtx = (nn_Context*) Carbon::PointerBacked::GetPointer(env, ctx);
// TODO: check if this is error handled properly
NULLPTR_CHECK(nnCtx, nn_Context);
nn_Universe* universe = nn_createUniverse(nnCtx, NULL);
/*jclass clazz = env->FindClass("org/neoflock/NeoNucleus/nn_Universe");
jmethodID creator = env->GetStaticMethodID(clazz, "createFromPointer", "(J)Lorg/neoflock/NeoNucleus/Universe;");
return env->CallStaticObjectMethod(clazz, creator, (jlong) universe);*/
return Carbon::InstantiateDefaultPBC(env, "org/neoflock/NeoNucleus/nn_Universe", universe);
}
// public static native nn_Component nn_createComponent(nn_Universe universe, String address, String type);
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createComponent
(JNIEnv * env, jclass, jobject universe, jstring address, jstring type) {
nn_Universe* nnUni = (nn_Universe*) Carbon::PointerBacked::GetPointer(env, universe);
NULLPTR_CHECK(nnUni, nn_Universe);
const char* addressChars = env->GetStringUTFChars(address, NULL);
const char* typeChars = env->GetStringUTFChars(type, NULL);
nn_Component* component = nn_createComponent(nnUni, addressChars, typeChars);
env->ReleaseStringUTFChars(address, addressChars);
env->ReleaseStringUTFChars(type, typeChars);
return Carbon::InstantiateDefaultPBC(env, "org/neoflock/NeoNucleus/nn_Component", component);
}
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setComponentMethods
(JNIEnv * env, jclass, jobject component, jobjectArray methods) {
NULLPTR_CHECK(methods, methods);
nn_Component* nnComp = (nn_Component*) Carbon::PointerBacked::GetPointer(env, component);
NULLPTR_CHECK(nnComp, nn_Component);
jclass methodClass = env->FindClass("org/neoflock/NeoNucleus/nn_Method");
jfieldID nameField = env->GetFieldID(methodClass, "name", "Ljava.lang.String");
jfieldID docField = env->GetFieldID(methodClass, "doc", "Ljava.lang.String");
jfieldID flagsField = env->GetFieldID(methodClass, "flags", "B");
size_t len = (size_t) env->GetArrayLength(methods);
nn_Method nMethods[len]; // stack allocated, shouldnt be an issue unless you're a freak pushing thousands of methods
for (size_t i = 0; i < len; i++) {
jobject oArr = env->GetObjectArrayElement(methods, i);
jstring nameStr = (jstring) env->GetObjectField(oArr, nameField);
jstring docStr = (jstring) env->GetObjectField(oArr, docField);
jbyte flagsByte = env->GetByteField(oArr, flagsField);
nMethods[i] = {
.name = env->GetStringUTFChars(nameStr, NULL),
.doc = env->GetStringUTFChars(docStr, NULL),
.flags = (nn_MethodFlags) env->GetByteField(oArr, NULL)
};
}
// no shot this line below is actually gonna work
nn_Exit exitCode = nn_setComponentMethodsArray(nnComp, const_cast<const nn_Method*>(&nMethods[0]), len);
// lets cleanup!!!
for (size_t i = 0; i < len; i++) {
jobject oArr = env->GetObjectArrayElement(methods, i);
jstring nameStr = (jstring) env->GetObjectField(oArr, nameField); // TODO: check if this returns a different pointer on a second run
jstring docStr = (jstring) env->GetObjectField(oArr, docField); // if it does then we'll have to store the original field jstrings too to clean them up properly
nn_Method nm = nMethods[i];
env->ReleaseStringUTFChars(nameStr, nm.name);
env->ReleaseStringUTFChars(docStr, nm.doc);
}
return Carbon::Map::To_nn_Exit(env, exitCode);
}
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setComponentHandler
(JNIEnv * env, jclass, jobject component, jobject handler) {
nn_Component* nnComp = (nn_Component*) Carbon::PointerBacked::GetPointer(env, component);
NULLPTR_CHECKNR(nnComp, nn_Component);
nn_setComponentHandler(nnComp, &Carbon::JNIComponentHandler);
}
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1mountComponent
(JNIEnv * env, jclass, jobject computer, jobject comp, jint slot, jboolean silent) {
nn_Computer* nnPC = (nn_Computer*) Carbon::PointerBacked::GetPointer(env, computer);
nn_Component* nnComp = (nn_Component*) Carbon::PointerBacked::GetPointer(env, comp);
NULLPTR_CHECK(nnPC, nn_Component);
NULLPTR_CHECK(nnComp, nn_Computer);
return Carbon::Map::To_nn_Exit(env, nn_mountComponent(nnPC, nnComp, slot, silent));
}
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1createEEPROM
(JNIEnv * env, jclass, jobject universe, jstring address, jobject eeprom, jstring code, jboolean isReadonly) {
nn_Universe* nnUni = (nn_Universe*) Carbon::PointerBacked::GetPointer(env, universe);
nn_EEPROM* nnEEPROM = (nn_EEPROM*) Carbon::PointerBacked::GetPointer(env, eeprom);
NULLPTR_CHECK(nnUni, nn_Universe);
NULLPTR_CHECK(nnEEPROM, nn_EEPROM);
const char * addr = env->GetStringUTFChars(address, NULL);
const char * codeStr = env->GetStringUTFChars(code, NULL);
jsize codeLen = env->GetStringUTFLength(code); // TODO: check if this is the byte count or character count
nn_Component* comp = ncl_createEEPROM(nnUni, addr, nnEEPROM, codeStr, codeLen, isReadonly);
env->ReleaseStringUTFChars(address, addr);
env->ReleaseStringUTFChars(code, codeStr);
return Carbon::InstantiateDefaultPBC(env, "org/neoflock/NeoNucleus/nn_Component", comp);
}
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createComputer
(JNIEnv * env, jclass, jobject universe, jstring address, jlong totalMemory, jlong maxComponents, jlong maxDevices) {
nn_Universe* nnUni = (nn_Universe*) Carbon::PointerBacked::GetPointer(env, universe);
NULLPTR_CHECK(nnUni, nn_Universe);
const char * addr = env->GetStringUTFChars(address, NULL);
// TODO: computer jni userdata lol
nn_Computer* computer = nn_createComputer(nnUni, NULL, addr, totalMemory, maxComponents, maxDevices);
env->ReleaseStringUTFChars(address, addr);
return Carbon::InstantiateDefaultPBC(env, "org/neoflock/NeoNucleus/nn_Computer", computer);
}

2437
src/native/neonucleus.h Normal file

File diff suppressed because it is too large Load Diff

2004
src/native/neonucleus.h.old Normal file

File diff suppressed because it is too large Load Diff

11
src/native/nn_Context.cpp Normal file
View File

@@ -0,0 +1,11 @@
#include "carbon.hpp"
#include "org_neoflock_NeoNucleus_Context.h"
#include <malloc.h>
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_Context_free
(JNIEnv * env, jobject obj) {
void* ptr = Carbon::PointerBacked::GetPointer(env, obj);
NULLPTR_CHECKNR(ptr, nn_Context);
free(ptr);
Carbon::PointerBacked::ResetPointer(env, obj); // lets not be having accidental double frees here
}

36
src/native/nn_EEPROM.cpp Normal file
View File

@@ -0,0 +1,36 @@
#include "org_neoflock_NeoNucleus_nn_EEPROM.h"
#include <cstdlib>
#include <cstring>
#include "carbon.hpp"
// FIXME: doesn't check for null
#define GET_LONG_FIELD(name) eepromNative->name = (uint64_t) env->GetLongField(eeprom, env->GetFieldID(clazz, #name, "J"));
#define GET_DOUBLE_FIELD(name) eepromNative->name = (double) env->GetDoubleField(eeprom, env->GetFieldID(clazz, #name, "D"));
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1EEPROM_allocate
(JNIEnv * env, jobject eeprom) {
jclass clazz = env->GetObjectClass(eeprom);
//jfieldID fid = env->GetFieldID(clazz, "ptr", "J");
//jlong size = env->GetLongField(eeprom, fid);
nn_EEPROM * eepromNative = (nn_EEPROM*)malloc(sizeof(nn_EEPROM));
GET_LONG_FIELD(size);
GET_LONG_FIELD(dataSize);
GET_DOUBLE_FIELD(readEnergyCost);
GET_DOUBLE_FIELD(readDataEnergyCost);
GET_DOUBLE_FIELD(writeEnergyCost);
GET_DOUBLE_FIELD(writeDataEnergyCost);
GET_DOUBLE_FIELD(writeDelay);
GET_DOUBLE_FIELD(writeDelay);
//printf("double_size=%d, %d %d %lf %lf %lf\n", sizeof(double), eepromNative->size, eepromNative->dataSize, eepromNative->readEnergyCost, eepromNative->readDataEnergyCost, eepromNative->writeEnergyCost);
return Carbon::PointerBacked::SetPointer(env, eeprom, eepromNative);
}
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1EEPROM_free
(JNIEnv * env, jobject eeprom) {
if (Carbon::PointerBacked::GetPointer(env, eeprom) == NULL) {
NULLPTR_THROW(nn_EEPROM);
return false;
}
// assuming free(NULL) does nothing, this should be fine
free(Carbon::PointerBacked::GetPointer(env, eeprom));
Carbon::PointerBacked::ResetPointer(env, eeprom);
return true;
}

View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_neoflock_NeoNucleus_Context */
#ifndef _Included_org_neoflock_NeoNucleus_Context
#define _Included_org_neoflock_NeoNucleus_Context
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_neoflock_NeoNucleus_Context
* Method: free
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_Context_free
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,405 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_neoflock_NeoNucleus_NativeBindings */
#ifndef _Included_org_neoflock_NeoNucleus_NativeBindings
#define _Included_org_neoflock_NeoNucleus_NativeBindings
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_initContext
* Signature: ()Lorg/neoflock/NeoNucleus/nn_Context;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1initContext
(JNIEnv *, jclass);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_initPalettes
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1initPalettes
(JNIEnv *, jclass);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_createUniverse
* Signature: (Lorg/neoflock/NeoNucleus/nn_Context;)Lorg/neoflock/NeoNucleus/nn_Universe;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createUniverse
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_createComponent
* Signature: (Lorg/neoflock/NeoNucleus/nn_Universe;Ljava/lang/String;Ljava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Component;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createComponent
(JNIEnv *, jclass, jobject, jstring, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setComponentMethods
* Signature: (Lorg/neoflock/NeoNucleus/nn_Component;[Lorg/neoflock/NeoNucleus/nn_Method;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setComponentMethods
(JNIEnv *, jclass, jobject, jobjectArray);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setComponentHandler
* Signature: (Lorg/neoflock/NeoNucleus/nn_Component;Lorg/neoflock/NeoNucleus/ComponentHandler;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setComponentHandler
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_mountComponent
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Lorg/neoflock/NeoNucleus/nn_Component;IZ)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1mountComponent
(JNIEnv *, jclass, jobject, jobject, jint, jboolean);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_createEEPROM
* Signature: (Lorg/neoflock/NeoNucleus/nn_Universe;Ljava/lang/String;Lorg/neoflock/NeoNucleus/nn_EEPROM;Ljava/lang/String;Z)Lorg/neoflock/NeoNucleus/nn_Component;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1createEEPROM
(JNIEnv *, jclass, jobject, jstring, jobject, jstring, jboolean);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_createComputer
* Signature: (Lorg/neoflock/NeoNucleus/nn_Universe;Ljava/lang/String;JJJ)Lorg/neoflock/NeoNucleus/nn_Computer;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1createComputer
(JNIEnv *, jclass, jobject, jstring, jlong, jlong, jlong);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setComputerEnvironment
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Lorg/neoflock/NeoNucleus/nn_Environment;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setComputerEnvironment
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setCallBudget
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;D)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setCallBudget
(JNIEnv *, jclass, jobject, jdouble);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setTotalEnergy
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;D)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setTotalEnergy
(JNIEnv *, jclass, jobject, jdouble);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setArchitecture
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Lorg/neoflock/NeoNucleus/nn_Architecture;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setArchitecture
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_addSupportedArchitecture
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Lorg/neoflock/NeoNucleus/nn_Architecture;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1addSupportedArchitecture
(JNIEnv *, jclass, jobject, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_setTmpAddress
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1setTmpAddress
(JNIEnv *, jclass, jobject, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getComponentAddress
* Signature: (Lorg/neoflock/NeoNucleus/nn_Component;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getComponentAddress
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_addCommonDeviceInfo
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;Lorg/neoflock/NeoNucleus/nn_CommonDeviceInfo;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1addCommonDeviceInfo
(JNIEnv *, jclass, jobject, jstring, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getComponentState
* Signature: (Lorg/neoflock/NeoNucleus/nn_Component;)Lorg/neoflock/NeoNucleus/ComponentState;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getComponentState
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_lockScreen
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1lockScreen
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_getScreenViewport
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)Lorg/neoflock/NeoNucleus/Resolution;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1getScreenViewport
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_setScreenViewport
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;JJ)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1setScreenViewport
(JNIEnv *, jclass, jobject, jlong, jlong);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_getScreenFlags
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)Lorg/neoflock/NeoNucleus/ncl_ScreenFlags;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1getScreenFlags
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_getScreenBrightness
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)D
*/
JNIEXPORT jdouble JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1getScreenBrightness
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_getScreenPixel
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;II)Lorg/neoflock/NeoNucleus/ncl_Pixel;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1getScreenPixel
(JNIEnv *, jclass, jobject, jint, jint);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_unlockScreen
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1unlockScreen
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushTouch
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;DDILjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushTouch
(JNIEnv *, jclass, jobject, jstring, jdouble, jdouble, jint, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushDrop
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;DDILjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushDrop
(JNIEnv *, jclass, jobject, jstring, jdouble, jdouble, jint, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushDrag
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;DDILjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushDrag
(JNIEnv *, jclass, jobject, jstring, jdouble, jdouble, jint, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushScroll
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;DDDLjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushScroll
(JNIEnv *, jclass, jobject, jstring, jdouble, jdouble, jdouble, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getUsedMemory
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)J
*/
JNIEXPORT jlong JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getUsedMemory
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getTotalMemory
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)J
*/
JNIEXPORT jlong JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getTotalMemory
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushClipboard
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushClipboard
(JNIEnv *, jclass, jobject, jstring, jstring, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushKeyDown
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;IILjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushKeyDown
(JNIEnv *, jclass, jobject, jstring, jint, jint, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_pushKeyUp
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;Ljava/lang/String;IILjava/lang/String;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1pushKeyUp
(JNIEnv *, jclass, jobject, jstring, jint, jint, jstring);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_clearstack
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1clearstack
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_removeEnergy
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;D)Z
*/
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1removeEnergy
(JNIEnv *, jclass, jobject, jdouble);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_tickSynchronized
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1tickSynchronized
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_getScreenEnergyUsage
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)D
*/
JNIEXPORT jdouble JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1getScreenEnergyUsage
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_resetIdleTime
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1resetIdleTime
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_tick
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Lorg/neoflock/NeoNucleus/nn_Exit;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1tick
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getComputerState
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Lorg/neoflock/NeoNucleus/nn_ComputerState;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getComputerState
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getError
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getError
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_getDesiredArchitecture
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)Lorg/neoflock/NeoNucleus/nn_Architecture;
*/
JNIEXPORT jobject JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1getDesiredArchitecture
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_stopComputer
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1stopComputer
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: ncl_resetScreen
* Signature: (Lorg/neoflock/NeoNucleus/ncl_ScreenState;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_ncl_1resetScreen
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_addIdleTime
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;D)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1addIdleTime
(JNIEnv *, jclass, jobject, jdouble);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_destroyComputer
* Signature: (Lorg/neoflock/NeoNucleus/nn_Computer;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1destroyComputer
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_dropComponent
* Signature: (Lorg/neoflock/NeoNucleus/nn_Component;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1dropComponent
(JNIEnv *, jclass, jobject);
/*
* Class: org_neoflock_NeoNucleus_NativeBindings
* Method: nn_destroyUniverse
* Signature: (Lorg/neoflock/NeoNucleus/nn_Universe;)V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_NativeBindings_nn_1destroyUniverse
(JNIEnv *, jclass, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_neoflock_NeoNucleus_nn_Architecture */
#ifndef _Included_org_neoflock_NeoNucleus_nn_Architecture
#define _Included_org_neoflock_NeoNucleus_nn_Architecture
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_neoflock_NeoNucleus_nn_Architecture
* Method: allocate
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1Architecture_allocate
(JNIEnv *, jobject);
/*
* Class: org_neoflock_NeoNucleus_nn_Architecture
* Method: free
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1Architecture_free
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,21 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_neoflock_NeoNucleus_nn_Context */
#ifndef _Included_org_neoflock_NeoNucleus_nn_Context
#define _Included_org_neoflock_NeoNucleus_nn_Context
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_neoflock_NeoNucleus_nn_Context
* Method: free
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_org_neoflock_NeoNucleus_nn_1Context_free
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,29 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_neoflock_NeoNucleus_nn_EEPROM */
#ifndef _Included_org_neoflock_NeoNucleus_nn_EEPROM
#define _Included_org_neoflock_NeoNucleus_nn_EEPROM
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_neoflock_NeoNucleus_nn_EEPROM
* Method: allocate
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1EEPROM_allocate
(JNIEnv *, jobject);
/*
* Class: org_neoflock_NeoNucleus_nn_EEPROM
* Method: free
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_org_neoflock_NeoNucleus_nn_1EEPROM_free
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif