Created
May 30, 2017 21:40
-
-
Save elliotpotts/361a36b714779f433a4a15f4919b548b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "example/ExampleClass.jh" | |
#include <iostream> | |
#include "J/Ref.hpp" | |
#include "J/Method.hpp" | |
#include "J/Tags.hpp" | |
using namespace J::tag; | |
void test(java::lang::Object& obj) { | |
std::cout << "[Hash " << obj.hashCode() << "]\n"; | |
} | |
namespace J { | |
namespace tag { | |
struct ExampleClass : public java::lang::Object { | |
static constexpr const char* signature = "LExampleClass;"; | |
J_FIELD(int, bar); | |
J_FIELD(java::lang::String, qux); | |
J_METHOD(void(), speak); | |
J_METHOD(ExampleClass(), get_self); | |
J_METHOD(void(java::lang::String), say_something); | |
ExampleClass(JNIEnv* env, jobject obj) : Object(env, obj) { | |
} | |
void foo() { | |
say_something(qux); | |
say_something({environment, "testicles"}); | |
test(*this); | |
} | |
}; | |
} | |
} | |
JNIEXPORT void JNICALL Java_ExampleClass_foo(JNIEnv* env, jobject obj) { | |
auto example = J::tag::ExampleClass(env, obj); | |
example.foo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment