You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pEpJNIAdapter/src/codegen/gen_throw_pEp_exception.ysl2

68 lines
2.0 KiB
Plaintext

include yslt.yml2
tstylesheet {
include ./textutils.ysl2
template "/" {
apply "namespace", 0;
document "../cxx/throw_pEp_exception.hh", "text"
||
#pragma once
#include <jni.h>
namespace pEp {
namespace JNIAdapter {
jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status);
};
};
||
document("../../build/marker/gen_throw_pEp_exception.marker", "text") > ""
}
template "namespace"
document("../cxx/throw_pEp_exception.cc", "text")
||
#include <assert.h>
#include <string>
#include <pEp/pEpEngine.h>
#include "throw_pEp_exception.hh"
namespace pEp {
namespace JNIAdapter {
jint throw_pEp_Exception(JNIEnv *env, PEP_STATUS status)
{
jclass ex;
std::string ex_pkg{"foundation/pEp/jniadapter/exceptions/"};
std::string ex_name{};
switch (status) {
`` apply "exception/*[text()!=0]", 4, mode=case
default:
assert(0);
ex_name = "Exception";
}
ex = env->FindClass(ex_name.c_str());
assert(ex);
if (ex == NULL) {
ex = env->FindClass("java/lang/NoClassDefFoundError");
assert(ex);
}
return env->ThrowNew(ex, ex_name.c_str());
}
};
};
||
template "*", mode=case {
| case `call "UCASE" with "text", "name(.)"`:
| ex_name = ex_pkg + "`call "CamelCase" with "text", "name(.)"`";
| break;
}
}