Skip to content

Commit

Permalink
Merge pull request #8 from ChristopherHX/clang-8-fix
Browse files Browse the repository at this point in the history
Clang 8 and gcc/g++ 10.2.0 fix
  • Loading branch information
ChristopherHX authored May 25, 2021
2 parents 9b6f694 + 61c370b commit 64e2d3d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/jnivm/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ namespace jnivm {
}
};

template<class T, FunctionType bind, bool EnvArg> struct HookManagerHelper2<T, bind, EnvArg, std::enable_if_t<(((int)bind & (int)FunctionType::Getter) && Function<T>::plength > (EnvArg ? 1 : 0) || ((int)bind & (int)FunctionType::Setter) && Function<T>::plength > (EnvArg ? 2 : 1))>> {
template<class T, FunctionType bind, bool EnvArg> struct HookManagerHelper2<T, bind, EnvArg, std::enable_if_t<((((int)bind & (int)FunctionType::Getter) && Function<T>::plength > (EnvArg ? 1 : 0)) || (((int)bind & (int)FunctionType::Setter) && Function<T>::plength > (EnvArg ? 2 : 1)))>> {
static void install(ENV* env, Class* cl, const std::string& id, T&& t) {
impl::HookManagerHelper<T, bind, EnvArg ? 1 : 0>::install(env, cl, id, std::move(t));
}
Expand Down
13 changes: 13 additions & 0 deletions src/jnivm/internal/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,17 @@ DeclareTemplate(jdouble);
DeclareTemplate(jchar);
DeclareTemplate(jobject);
DeclareTemplate(void);
#undef DeclareTemplate

#define DeclareTemplate(T) template T jnivm::defaultVal(ENV* env, std::string signature)
DeclareTemplate(jboolean);
DeclareTemplate(jbyte);
DeclareTemplate(jshort);
DeclareTemplate(jint);
DeclareTemplate(jlong);
DeclareTemplate(jfloat);
DeclareTemplate(jdouble);
DeclareTemplate(jchar);
DeclareTemplate(jobject);
DeclareTemplate(void);
#undef DeclareTemplate
12 changes: 12 additions & 0 deletions src/jnivm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,15 @@ jvalue Method::jinvoke(jnivm::ENV &env, jobject obj, ...) {
va_end(l);
return ret;
}

#define DeclareTemplate(T) template jvalue toJValue(T val);
DeclareTemplate(jboolean);
DeclareTemplate(jbyte);
DeclareTemplate(jshort);
DeclareTemplate(jint);
DeclareTemplate(jlong);
DeclareTemplate(jfloat);
DeclareTemplate(jdouble);
DeclareTemplate(jchar);
DeclareTemplate(jobject);
#undef DeclareTemplate
5 changes: 4 additions & 1 deletion src/jnivm/vm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,4 +565,7 @@ const JNINativeInterface &jnivm::VM::GetNativeInterfaceTemplate() {
jnivm::VM *jnivm::VM::FromJavaVM(JavaVM *vm) {
if(vm == nullptr || vm->functions->reserved0 == nullptr) throw std::runtime_error("Failed to get reference to jnivm::VM");
return static_cast<jnivm::VM*>(vm->functions->reserved0);
}
}

template JNINativeInterface jnivm::VM::GetNativeInterfaceTemplate<true>();
template JNINativeInterface jnivm::VM::GetNativeInterfaceTemplate<false>();

0 comments on commit 64e2d3d

Please sign in to comment.