Skip to content

Instantly share code, notes, and snippets.

@elliotpotts
Created May 30, 2017 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotpotts/361a36b714779f433a4a15f4919b548b to your computer and use it in GitHub Desktop.
Save elliotpotts/361a36b714779f433a4a15f4919b548b to your computer and use it in GitHub Desktop.
#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