Browse Source

refactor throw_pEp_Exception()

pull/35/head
heck 2 years ago
parent
commit
75f234fe9a
  1. 10
      src/codegen/gen_throw_pEp_exception.ysl2

10
src/codegen/gen_throw_pEp_exception.ysl2

@ -25,6 +25,7 @@ tstylesheet {
document("../cxx/throw_pEp_exception.cc", "text") document("../cxx/throw_pEp_exception.cc", "text")
|| ||
#include <assert.h> #include <assert.h>
#include <string>
#include <pEp/pEpEngine.h> #include <pEp/pEpEngine.h>
#include "throw_pEp_exception.hh" #include "throw_pEp_exception.hh"
@ -33,7 +34,8 @@ tstylesheet {
jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status) jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status)
{ {
jclass ex; jclass ex;
const char *ex_name; std::string ex_pkg{"foundation/pEp/jniadapter/exceptions/"};
std::string ex_name{};
switch (status) { switch (status) {
`` apply "exception/*[text()!=0]", 4, mode=case `` apply "exception/*[text()!=0]", 4, mode=case
@ -42,7 +44,7 @@ tstylesheet {
ex_name = "Exception"; ex_name = "Exception";
} }
ex = env->FindClass(ex_name); ex = env->FindClass(ex_name.c_str());
assert(ex); assert(ex);
if (ex == NULL) { if (ex == NULL) {
@ -50,7 +52,7 @@ tstylesheet {
assert(ex); assert(ex);
} }
return env->ThrowNew(ex, ex_name); return env->ThrowNew(ex, ex_name.c_str());
} }
}; };
}; };
@ -58,7 +60,7 @@ tstylesheet {
template "*", mode=case { template "*", mode=case {
| case `call "UCASE" with "text", "name(.)"`: | case `call "UCASE" with "text", "name(.)"`:
| ex_name = "foundation/pEp/jniadapter/exceptions/`call "CamelCase" with "text", "name(.)"`"; | ex_name = ex_pkg + "`call "CamelCase" with "text", "name(.)"`";
| break; | break;
} }
} }

Loading…
Cancel
Save