Skip to content

Commit

Permalink
implementing changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhea committed Nov 20, 2019
1 parent 67d75e9 commit 8422c1d
Show file tree
Hide file tree
Showing 12 changed files with 225 additions and 188 deletions.
10 changes: 9 additions & 1 deletion bindings/java/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ c/build/*
*.dylib
.DS_Store
.gradle
build
build
.classpath
.project
.settings/
java/.classpath
java/.project
java/.settings/
java/bin/
java/hs_err_pid*
42 changes: 2 additions & 40 deletions bindings/java/c/evmc-vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,6 @@
#include "evmc-vm.h"
#include "host.h"


JNIEXPORT jint JNICALL Java_org_ethereum_evmc_EvmcVm_test(JNIEnv* jenv, jclass jcls, jobject jbuffer){
struct test_struct{
int one;
long two;
int int1;
int int2;
char three;
long four;
char five[11];
};

struct test_struct *test = (struct test_struct *) (*jenv)->GetDirectBufferAddress(jenv, jbuffer);

struct test_struct *dummy =malloc (sizeof (struct test_struct));
printf("struct: dummy=%p, test=%p\n",dummy,test);
printf("one: dummy=%p, test=%p\n",&dummy->one,&test->one);
printf("two: dummy=%p, test=%p\n",&dummy->two,&test->two);
printf("int1: dummy=%p, test=%p\n",&dummy->int1,&test->int1);
printf("int2: dummy=%p, test=%p\n",&dummy->int2,&test->int2);
printf("three: dummy=%p, test=%p\n",&dummy->three,&test->three);
printf("four: dummy=%p, test=%p\n",&dummy->four, &test->four);
printf("five: dummy=%p, test=%p\n\n",&dummy->five,&test->five);

printf("one=%d\n",test->one);
printf("two=%ld\n",test->two);
printf("int1=%d\n",test->int1);
printf("int2=%d\n",test->int2);
printf("three=%c\n",test->three);
printf("four=%ld\n",test->four);
printf("five=%s\n",test->five);

return 0;


}

JNIEXPORT jint JNICALL Java_org_ethereum_evmc_EvmcVm_init(JNIEnv* jenv, jclass jcls, jstring jfilename)
{
jint rs = (*jenv)->GetJavaVM(jenv, &jvm);
Expand All @@ -55,15 +18,14 @@ JNIEXPORT jint JNICALL Java_org_ethereum_evmc_EvmcVm_init(JNIEnv* jenv, jclass j
evm_handle = evmc_load_and_create(filename, &loader_error);
if (evm_handle == NULL || loader_error != EVMC_LOADER_SUCCESS) {
const char *error_msg = evmc_last_error_msg();
printf("EVMC loading error: %s\n", error_msg);
exit(EXIT_FAILURE);
(*jenv)->ThrowNew(jenv, jcls, error_msg);
}
(*jenv)->ReleaseStringUTFChars(jenv, jfilename, filename);

// instantiate the EVMC host interface
host = malloc (sizeof (struct evmc_host_interface));
if (host == NULL) {
exit(EXIT_FAILURE);
(*jenv)->ThrowNew(jenv, jcls, "JNI error: Couldn't instantiate EVMC host interface");
}

host->account_exists = account_exists_fn;
Expand Down
3 changes: 0 additions & 3 deletions bindings/java/c/evmc-vm.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_ethereum_evmc_EvmcVm */

Expand All @@ -8,8 +7,6 @@
extern "C" {
#endif

JNIEXPORT jint JNICALL Java_org_ethereum_evmc_EvmcVm_test
(JNIEnv *, jclass, jobject);
/*
* Class: org_ethereum_evmc_EvmcVm
* Method: init
Expand Down
Loading

0 comments on commit 8422c1d

Please sign in to comment.