11#include "jni_h/jvmqmsgque_MqContextC.h"
12#include "LibMqMsgque_private_jv.h"
15#define META_CONTEXT_S mqctx
19#define JavaErrorCheck2 if ((*env)->ExceptionCheck(env) == JNI_TRUE) goto error_jv;
28#define typeSTR MK_STRN
29#define typeBIN MK_BINN
35#define jniBOL jboolean
48 JNIEnv *env,
MK_MNG hdl, jobject val, jclass to, jsize pos,
MK_STRN caller
52 jclass from = (*env)->GetObjectClass(env,val);
54 jstring sVal = (*env)->CallStaticObjectMethod(env,MK(Class_String),NS(MID_String_valueOf),val);
56 jstring sFrom = (*env)->CallObjectMethod(env,from,MQ(MID_Class_getSimpleName));
58 jstring sTo = (*env)->CallObjectMethod(env,to ,MQ(MID_Class_getSimpleName));
61 MK_STRN cVal = (*env)->GetStringUTFChars(env,sVal ,NULL);
62 MK_STRN cFrom = (*env)->GetStringUTFChars(env,sFrom,NULL);
63 MK_STRN cTo = (*env)->GetStringUTFChars(env,sTo ,NULL);
66 "expect '%s' argument but got '%s' of type '%s' at position '%d'",
67 cTo, cVal, cFrom, pos);
69 if (cFrom) (*env)->ReleaseStringUTFChars(env,sFrom,cFrom);
70 if (cTo) (*env)->ReleaseStringUTFChars(env,sTo ,cTo );
71 if (cVal) (*env)->ReleaseStringUTFChars(env,sVal ,cVal );
73 jstring sTo = (*env)->CallObjectMethod(env,to ,MQ(MID_Class_getSimpleName));
75 MK_STRN cTo = (*env)->GetStringUTFChars(env,sTo ,NULL);
78 "expect '%s' argument but got '%s' at position '%d'",
81 if (cTo) (*env)->ReleaseStringUTFChars(env,sTo ,cTo );
86 (*env)->ExceptionDescribe(env);
87 (*env)->ExceptionClear(env);
94#define BLOCK_START(T) \
95 jobject val = (*env)->GetObjectArrayElement(env, argv, *posP); \
99 } else if (OT_LNG_OBJ_CLASS_IS(val,MQ(Class_##T))) { \
101#define BLOCK_END(T) \
103 MkErrorCheck(ArgumentTypeError(env,hdl,val,MQ(Class_##T),*posP,__func__)); \
107 return MkErrorGetCode_0E(); \
109 MkErrorStack_1X(hdl); \
112 OT_ERROR_LNG_2_META(hdl); \
117#define sendX1(T,TTT) \
118static enum MkErrorE send##T(MQ_RT_ARGS JNIEnv *env, MQ_CTX hdl, jobject argv, jsize *posP) { \
121 out = (type##T)(*env)->Call##TTT##Method(env,val,MQ(get_##T)); \
123 MkErrorCheck(MqSend##T(hdl,out)); \
124 } else if (OT_LNG_OBJ_CLASS_IS(val,MQ(Class_STR))) { \
125 MK_NUM cLen = (*env)->GetStringUTFLength(env,val); \
126 MK_STRN cVal = (*env)->GetStringUTFChars(env,val ,NULL); \
127 enum MkErrorE ret = MkString2##T##_RT(MK_RT_CALL cVal,cLen,&out); \
128 if (cVal) (*env)->ReleaseStringUTFChars(env,val ,cVal ); \
130 MkErrorCheck(MqSend##T(hdl,out)); \
133 MqSend##T##_E(hdl,0); \
146#define sendX2(T,ClassC) \
147static enum MkErrorE send##T(MQ_RT_ARGS JNIEnv *env, MQ_CTX hdl, jobject argv, jsize *posP) { \
150 out = (type##T)pObj2Hdl(env,ClassC,val); \
152 MkErrorCheck(MqSend##T(hdl,out)); \
155 MqSend##T##_E(hdl,NULL); \
160sendX2(BFL,"MkBufferListC")
164 typeSTR out = (*env)->GetStringUTFChars(env,val,NULL);
167 if (out) (*env)->ReleaseStringUTFChars(env,val,out);
178 typeBIN out = (
MK_BINN) (*env)->GetByteArrayElements(env, val, NULL);
183 (*env)->ReleaseByteArrayElements(env, val, (jbyte*)out, JNI_ABORT);
270 MK_STR str,
size_t size ) {
271 jobject val = (*env)->GetObjectArrayElement(env, argv, *posP);
273 if (OT_LNG_OBJ_CLASS_IS(val,MK(Class_String))) {
274 MK_STRN strS = JO2C_START(env, val);
275 strncpy(str,strS,size);
276 JO2C_STOP(env,val,strS);
284 OT_ERROR_LNG_2_META(hdl);
289 jobject val = (*env)->GetObjectArrayElement(env, argv, *posP);
291 if (OT_LNG_OBJ_CLASS_IS(val,NS(Class_MqServiceIF))) {
292 (*cb) = MK(ProcCreate)(
MK_RT_CALL env, val, NULL, NS(MID_callback),
true);
295 MkErrorSetC(hdl,
"ERROR: expect an FUNCTION pointer, but got 'NULL'",__func__,-1);
299 MkErrorCheck(
ArgumentTypeError(env,hdl,val,NS(Class_MqServiceIF),*posP,__func__));
305 OT_ERROR_LNG_2_META(hdl);
310 jobject val = (*env)->GetObjectArrayElement(env, argv, *posP);
312 if (OT_LNG_OBJ_CLASS_IS(val,MQ(Class_I64))) {
313 *out = (
MK_TIME_T) (*env)->CallIntMethod(env,val,MQ(get_I64));
322 OT_ERROR_LNG_2_META(hdl);
329JNIEXPORT jobject JNICALL Java_jvmqmsgque_MqContextC_Send (
336 if ((*env)->ExceptionCheck(env) == JNI_TRUE)
return NULL;
339 jsize objc = (*env)->GetArrayLength(env, argv);
349 jobject retObj = NULL;
351#define highSELF "Send"
358#define highSKIP_SHIFT 0
363#define highSIZE_AVAILABLE 1
364#define highREAD_RETURN_LIST 1
365#define highREAD_HAS_REFERENCE 0
367#define highTOKEN(s) MkErrorCheck(getSTRING(MQ_RT_CALL env,hdl,self,argv,&skip,s,MQ_SEND_TOKEN_SIGNATURE_SIZE))
368#define highTRAN(s) MkErrorCheck(getSTRING(MQ_RT_CALL env,hdl,self,argv,&skip,s,MQ_SEND_TRANSACTION_TOKEN_SIZE))
369#define highCALL(f) MkErrorCheck(getCALL(MQ_RT_CALL env,hdl,self,argv,&skip,&f))
370#define highTIME(t) MkErrorCheck(getTIME(MQ_RT_CALL env,hdl,argv,&skip,&t));
372#define highINITcstr cstr = JO2C_START(env,jcallSig); JavaErrorCheck;
373#define highCMD "ctx.%s('%s', ..., '%s', ...)"
374#define highFARGS(f) NS(ServiceCall),f,NS(ServiceFree)
377#define OT_retObj_SET_None retObj = NULL;
378#define OT_retObj_SET_BUF(obj) retObj = MK(MkBufferC_ObjNew)(MK_RT_CALL env,obj);
379#define OT_retObj_SET_BFL(obj) retObj = MK(MkBufferListC_ObjNew)(MK_RT_CALL env,obj);
380#define OT_MK_CALL_0(obj,cls,meth,ret) \
381 ret = (*env)->CallObjectMethod(env,cls##_NS(cls##_ObjNew)(MK_RT_CALL env,obj),cls##_NS(MID_##cls##_##meth));JavaErrorCheck;
383#define highRETURN highRETURN_type_S
384#define highRETok goto end
386#define highERRORnative if ((*env)->ExceptionCheck(env) == JNI_TRUE) OT_ERROR_LNG_2_META(mqctx);
387#define highRETerror OT_ERROR_META_2_LNG(hdl)
391#define highSEND(T) MkErrorCheck(send##T(MQ_RT_CALL env,hdl,argv,&skip));break;
393#define highSend_I8 highSEND(I8)
394#define highSend_BOL highSEND(BOL)
395#define highSend_I16 highSEND(I16)
396#define highSend_I32 highSEND(I32)
397#define highSend_FLT highSEND(FLT)
398#define highSend_I64 highSEND(I64)
399#define highSend_DBL highSEND(DBL)
400#define highSend_STR highSEND(STR)
401#define highSend_BUF highSEND(BUF)
402#define highSend_BFL highSEND(BFL)
403#define highSend_BIN highSEND(BIN)
404#define highSend_HDL highSEND(HDL)
408#define highREADprepare
428#include "tmpl/high_lng.h"
431 if (callSig != unknown) JO2C_STOP(env,jcallSig,callSig);
static enum MkErrorE sendBIN(MK_RT mkrt, MQ_RT mqrt, JNIEnv *env, MQ_CTX hdl, jobject argv, jsize *posP)
static enum MkErrorE ArgumentTypeError(JNIEnv *env, MK_MNG hdl, jobject val, jclass to, jsize pos, MK_STRN caller)
static enum MkErrorE getSTRING(MK_RT mkrt, MQ_RT mqrt, JNIEnv *env, MK_MNG hdl, jobject self, jobject argv, jsize *posP, MK_STR str, size_t size)
#define sendX2(T, ClassC)
static enum MkErrorE getCALL(MK_RT mkrt, MQ_RT mqrt, JNIEnv *env, MK_MNG hdl, jobject self, jobject argv, jsize *posP, MK_CBP *cb)
static enum MkErrorE getTIME(MK_RT mkrt, MQ_RT mqrt, JNIEnv *env, MK_MNG hdl, jobject argv, jsize *posP, MK_TIME_T *out)
#define MkErrorGetCode_0E()
#define MkErrorSetV_4M_NULL(m,...)
#define MkErrorSetC_1_NULL(msg)
static MkBinaryR MkBinaryCreate(MK_SIZE size, MK_BINN data)
struct MqContextS * MQ_CTX
class-shortcut for struct MqContextS *, all shortcut using the XX_YYY syntax (only for public API) …
PUBLIC data structure for the jvmqmsgque-specific-data