diff --git a/src/Makefile b/src/Makefile index eaadf29..0bed908 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,9 +12,9 @@ $(JAR): $(JAVASOURCE) org_pEp_jniadapter_Engine.h: org/pEp/jniadapter/Engine.java javah org.pEp.jniadapter.Engine -org_pEp_jniadapter_Engine.o: org_pEp_jniadapter_Engine.h org_pEp_jniadapter_Engine.cc +org_pEp_jniadapter_Engine.o: org_pEp_jniadapter_Engine.h org_pEp_jniadapter_Engine.cc throw_pEp_exception.hh -$(LIBRARY): org_pEp_jniadapter_Engine.o +$(LIBRARY): org_pEp_jniadapter_Engine.o throw_pEp_exception.o ar -r $@ $< .PHONY: clean generate distclean @@ -26,7 +26,13 @@ clean: rm -f *.class rm -f org/pEp/jniadapter/*.class rm -f org/pEp/jniadapter/pEp*.java + rm -f throw_pEp_exception.* org/pEp/jniadapter/pEpException.java: pEp.yml2 gen_java_exceptions.ysl2 yml2proc -y gen_java_exceptions.ysl2 $< -o $@ +throw_pEp_exception.cc throw_pEp_exception.hh: pEp.yml2 gen_throw_pEp_exception.ysl2 + yml2proc -y gen_throw_pEp_exception.ysl2 $< -o throw_pEp_exception.cc + +throw_pEp_exception.o: throw_pEp_exception.cc throw_pEp_exception.hh + diff --git a/src/gen_java_exceptions.ysl2 b/src/gen_java_exceptions.ysl2 index dd56820..7420ec5 100644 --- a/src/gen_java_exceptions.ysl2 +++ b/src/gen_java_exceptions.ysl2 @@ -1,37 +1,7 @@ include yslt.yml2 tstylesheet { - function "UCASE" { - param "text"; - - value "translate($text, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"; - } - - function "lcase" { - param "text"; - - value "translate($text, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')"; - } - - function "CamelCase" { - param "text"; - - choose { - when "contains($text, '-')" { - const "tokens", "str:tokenize($text, '-')"; - for "$tokens" { - choose { - when ".='pEp'" > pEp - otherwise { - call "UCASE" with "text", "substring(., 1, 1)"; - call "lcase" with "text", "substring(., 2)"; - } - } - } - } - otherwise | unsupported - } - } + include ./textutils.ysl2 template "/" { | package org.pEp.jniadapter; diff --git a/src/org_pEp_jniadapter_Engine.cc b/src/org_pEp_jniadapter_Engine.cc index 289dc79..d73a71d 100644 --- a/src/org_pEp_jniadapter_Engine.cc +++ b/src/org_pEp_jniadapter_Engine.cc @@ -5,45 +5,10 @@ #include #include +#include "throw_pEp_exception.hh" + namespace pEp { namespace JNIAdapter { - jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status) - { - jclass ex; - const char *ex_name; - - switch (status) { - case PEP_INIT_CANNOT_LOAD_GPGME: - ex_name = "org/pEp/jniadapter/InitCannotLoadGPGME"; - break; - case PEP_INIT_GPGME_INIT_FAILED: - ex_name = "org/pEp/jniadapter/GPGMEInitFailed"; - break; - case PEP_INIT_SQLITE3_WITHOUT_MUTEX: - ex_name = "org/pEp/jniadapter/SQLite3WithoutMutex"; - break; - case PEP_INIT_CANNOT_OPEN_DB: - ex_name = "org/pEp/jniadapter/InitCannotOpenDB"; - break; - case PEP_INIT_CANNOT_OPEN_SYSTEM_DB: - ex_name = "org/pEp/jniadapter/InitCannotOpenSystemDB"; - break; - default: - assert(0); - ex_name = "Exception"; - } - - ex = env->FindClass(ex_name); - assert(ex); - - if (ex == NULL) { - ex = env->FindClass("java/lang/NoClassDefFoundError"); - assert(ex); - } - - return env->ThrowNew(ex, ex_name); - } - jfieldID getFieldID( JNIEnv *env, const char *classname,