JNI ready for testing. -fPIC enabled for objects in src and jni.
This commit is contained in:
parent
1529c0641e
commit
106b8bb6a7
25 changed files with 954 additions and 145 deletions
45
jni/com_upstandinghackers_hammer_ParseResult.c
Normal file
45
jni/com_upstandinghackers_hammer_ParseResult.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#include "jhammer.h"
|
||||
#include "com_upstandinghackers_hammer_ParseResult.h"
|
||||
|
||||
HParseResult *unwrap_parse_result(JNIEnv *env, jobject obj)
|
||||
{
|
||||
jclass parseResultClass;
|
||||
jfieldID parseResultInner;
|
||||
FIND_CLASS(parseResultClass, env, "com/upstandinghackers/hammer/ParseResult");
|
||||
parseResultInner = (*env)->GetFieldID(env, parseResultClass, "inner", "J");
|
||||
return (HParseResult *)((*env)->GetLongField(env, obj, parseResultInner));
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_com_upstandinghackers_hammer_ParseResult_getAst
|
||||
(JNIEnv *env, jobject this)
|
||||
{
|
||||
HParseResult *inner;
|
||||
jclass parsedTokenClass;
|
||||
jobject retVal;
|
||||
|
||||
if(this == NULL)
|
||||
return NULL; // parse unsuccessful
|
||||
inner = unwrap_parse_result(env, this);
|
||||
if(inner->ast == NULL)
|
||||
return NULL; // parse successful, but empty
|
||||
|
||||
FIND_CLASS(parsedTokenClass, env, "com/upstandinghackers/hammer/ParsedToken");
|
||||
NEW_INSTANCE(retVal, env, parsedTokenClass, inner->ast);
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_upstandinghackers_hammer_ParseResult_getBitLength
|
||||
(JNIEnv *env, jobject this)
|
||||
{
|
||||
HParseResult *inner = unwrap_parse_result(env, this);
|
||||
return (jlong) (inner->bit_length);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_upstandinghackers_hammer_ParseResult_free
|
||||
(JNIEnv *env, jobject this)
|
||||
{
|
||||
//XXX: NOT IMPLEMENTED
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue