From 75f234fe9ad918deea19a1398280d3de99c6d861 Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 9 Feb 2023 18:20:25 +0530 Subject: [PATCH] refactor throw_pEp_Exception() --- src/codegen/gen_throw_pEp_exception.ysl2 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/codegen/gen_throw_pEp_exception.ysl2 b/src/codegen/gen_throw_pEp_exception.ysl2 index 42d99ec..fd2ebca 100644 --- a/src/codegen/gen_throw_pEp_exception.ysl2 +++ b/src/codegen/gen_throw_pEp_exception.ysl2 @@ -25,6 +25,7 @@ tstylesheet { document("../cxx/throw_pEp_exception.cc", "text") || #include + #include #include #include "throw_pEp_exception.hh" @@ -33,7 +34,8 @@ tstylesheet { jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status) { jclass ex; - const char *ex_name; + std::string ex_pkg{"foundation/pEp/jniadapter/exceptions/"}; + std::string ex_name{}; switch (status) { `` apply "exception/*[text()!=0]", 4, mode=case @@ -42,7 +44,7 @@ tstylesheet { ex_name = "Exception"; } - ex = env->FindClass(ex_name); + ex = env->FindClass(ex_name.c_str()); assert(ex); if (ex == NULL) { @@ -50,7 +52,7 @@ tstylesheet { assert(ex); } - return env->ThrowNew(ex, ex_name); + return env->ThrowNew(ex, ex_name.c_str()); } }; }; @@ -58,7 +60,7 @@ tstylesheet { template "*", mode=case { | 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; } }