21 #ifndef jtie_gcalls_hpp
22 #define jtie_gcalls_hpp
24 #include "jtie_stdint.h"
25 #include "jtie_tconv_impl.hpp"
26 #include "jtie_tconv_object_impl.hpp"
27 #include "helpers.hpp"
152 #define BSL1(m) LE(m(1))
153 #define BSL2(m) BSL1(m) LE(m(2))
154 #define BSL3(m) BSL2(m) LE(m(3))
155 #define BSL4(m) BSL3(m) LE(m(4))
156 #define BSL5(m) BSL4(m) LE(m(5))
157 #define BSL6(m) BSL5(m) LE(m(6))
158 #define BSL7(m) BSL6(m) LE(m(7))
159 #define BSL8(m) BSL7(m) LE(m(8))
160 #define BSL9(m) BSL8(m) LE(m(9))
161 #define BSL10(m) BSL9(m) LE(m(10))
162 #define BSL11(m) BSL10(m) LE(m(11))
163 #define BSL12(m) BSL11(m) LE(m(12))
164 #define BSL13(m) BSL12(m) LE(m(13))
165 #define BSL14(m) BSL13(m) LE(m(14))
166 #define BSL15(m) BSL14(m) LE(m(15))
167 #define BSL16(m) BSL15(m) LE(m(16))
168 #define BSL17(m) BSL16(m) LE(m(17))
169 #define BSL18(m) BSL17(m) LE(m(18))
170 #define BSL19(m) BSL18(m) LE(m(19))
180 #define RBSL1(m) LE(m(1))
181 #define RBSL2(m) LE(m(2)) RBSL1(m)
182 #define RBSL3(m) LE(m(3)) RBSL2(m)
183 #define RBSL4(m) LE(m(4)) RBSL3(m)
184 #define RBSL5(m) LE(m(5)) RBSL4(m)
185 #define RBSL6(m) LE(m(6)) RBSL5(m)
186 #define RBSL7(m) LE(m(7)) RBSL6(m)
187 #define RBSL8(m) LE(m(8)) RBSL7(m)
188 #define RBSL9(m) LE(m(9)) RBSL8(m)
189 #define RBSL10(m) LE(m(10)) RBSL9(m)
190 #define RBSL11(m) LE(m(11)) RBSL10(m)
191 #define RBSL12(m) LE(m(12)) RBSL11(m)
192 #define RBSL13(m) LE(m(13)) RBSL12(m)
193 #define RBSL14(m) LE(m(14)) RBSL13(m)
194 #define RBSL15(m) LE(m(15)) RBSL14(m)
195 #define RBSL16(m) LE(m(16)) RBSL15(m)
196 #define RBSL17(m) LE(m(17)) RBSL16(m)
197 #define RBSL18(m) LE(m(18)) RBSL17(m)
198 #define RBSL19(m) LE(m(19)) RBSL18(m)
208 #define CSL1(m) LE(m(1))
209 #define CSL2(m) CSL1(m), LE(m(2))
210 #define CSL3(m) CSL2(m), LE(m(3))
211 #define CSL4(m) CSL3(m), LE(m(4))
212 #define CSL5(m) CSL4(m), LE(m(5))
213 #define CSL6(m) CSL5(m), LE(m(6))
214 #define CSL7(m) CSL6(m), LE(m(7))
215 #define CSL8(m) CSL7(m), LE(m(8))
216 #define CSL9(m) CSL8(m), LE(m(9))
217 #define CSL10(m) CSL9(m), LE(m(10))
218 #define CSL11(m) CSL10(m), LE(m(11))
219 #define CSL12(m) CSL11(m), LE(m(12))
220 #define CSL13(m) CSL12(m), LE(m(13))
221 #define CSL14(m) CSL13(m), LE(m(14))
222 #define CSL15(m) CSL14(m), LE(m(15))
223 #define CSL16(m) CSL15(m), LE(m(16))
224 #define CSL17(m) CSL16(m), LE(m(17))
225 #define CSL18(m) CSL17(m), LE(m(18))
226 #define CSL19(m) CSL18(m), LE(m(19))
236 #define CPL1(m) ,LE(m(1))
237 #define CPL2(m) CPL1(m) ,LE(m(2))
238 #define CPL3(m) CPL2(m) ,LE(m(3))
239 #define CPL4(m) CPL3(m) ,LE(m(4))
240 #define CPL5(m) CPL4(m) ,LE(m(5))
241 #define CPL6(m) CPL5(m) ,LE(m(6))
242 #define CPL7(m) CPL6(m) ,LE(m(7))
243 #define CPL8(m) CPL7(m) ,LE(m(8))
244 #define CPL9(m) CPL8(m) ,LE(m(9))
245 #define CPL10(m) CPL9(m) ,LE(m(10))
246 #define CPL11(m) CPL10(m) ,LE(m(11))
247 #define CPL12(m) CPL11(m) ,LE(m(12))
248 #define CPL13(m) CPL12(m) ,LE(m(13))
249 #define CPL14(m) CPL13(m) ,LE(m(14))
250 #define CPL15(m) CPL14(m) ,LE(m(15))
251 #define CPL16(m) CPL15(m) ,LE(m(16))
252 #define CPL17(m) CPL16(m) ,LE(m(17))
253 #define CPL18(m) CPL17(m) ,LE(m(18))
254 #define CPL19(m) CPL18(m) ,LE(m(19))
264 #define CTL1(m) LE(m(1)),
265 #define CTL2(m) CTL1(m) LE(m(2)),
266 #define CTL3(m) CTL2(m) LE(m(3)),
267 #define CTL4(m) CTL3(m) LE(m(4)),
268 #define CTL5(m) CTL4(m) LE(m(5)),
269 #define CTL6(m) CTL5(m) LE(m(6)),
270 #define CTL7(m) CTL6(m) LE(m(7)),
271 #define CTL8(m) CTL7(m) LE(m(8)),
272 #define CTL9(m) CTL8(m) LE(m(9)),
273 #define CTL10(m) CTL9(m) LE(m(10)),
274 #define CTL11(m) CTL10(m) LE(m(11)),
275 #define CTL12(m) CTL11(m) LE(m(12)),
276 #define CTL13(m) CTL12(m) LE(m(13)),
277 #define CTL14(m) CTL13(m) LE(m(14)),
278 #define CTL15(m) CTL14(m) LE(m(15)),
279 #define CTL16(m) CTL15(m) LE(m(16)),
280 #define CTL17(m) CTL16(m) LE(m(17)),
281 #define CTL18(m) CTL17(m) LE(m(18)),
282 #define CTL19(m) CTL18(m) LE(m(19)),
291 #define STRING_NE(x) #x
296 #define STRING(m) STRING_NE(m)
321 #define SCSL1(m) STRING(m(1))
322 #define SCSL2(m) SCSL1(m) ", " STRING(m(2))
323 #define SCSL3(m) SCSL2(m) ", " STRING(m(3))
324 #define SCSL4(m) SCSL3(m) ", " STRING(m(4))
325 #define SCSL5(m) SCSL4(m) ", " STRING(m(5))
326 #define SCSL6(m) SCSL5(m) ", " STRING(m(6))
327 #define SCSL7(m) SCSL6(m) ", " STRING(m(7))
328 #define SCSL8(m) SCSL7(m) ", " STRING(m(8))
329 #define SCSL9(m) SCSL8(m) ", " STRING(m(9))
330 #define SCSL10(m) SCSL9(m) ", " STRING(m(10))
331 #define SCSL11(m) SCSL10(m) ", " STRING(m(11))
332 #define SCSL12(m) SCSL11(m) ", " STRING(m(12))
333 #define SCSL13(m) SCSL12(m) ", " STRING(m(13))
334 #define SCSL14(m) SCSL13(m) ", " STRING(m(14))
335 #define SCSL15(m) SCSL14(m) ", " STRING(m(15))
336 #define SCSL16(m) SCSL15(m) ", " STRING(m(16))
337 #define SCSL17(m) SCSL16(m) ", " STRING(m(17))
338 #define SCSL18(m) SCSL17(m) ", " STRING(m(18))
339 #define SCSL19(m) SCSL18(m) ", " STRING(m(19))
350 #define SCPL1(m) ", " STRING(m(1))
351 #define SCPL2(m) SCPL1(m) ", " STRING(m(2))
352 #define SCPL3(m) SCPL2(m) ", " STRING(m(3))
353 #define SCPL4(m) SCPL3(m) ", " STRING(m(4))
354 #define SCPL5(m) SCPL4(m) ", " STRING(m(5))
355 #define SCPL6(m) SCPL5(m) ", " STRING(m(6))
356 #define SCPL7(m) SCPL6(m) ", " STRING(m(7))
357 #define SCPL8(m) SCPL7(m) ", " STRING(m(8))
358 #define SCPL9(m) SCPL8(m) ", " STRING(m(9))
359 #define SCPL10(m) SCPL9(m) ", " STRING(m(10))
360 #define SCPL11(m) SCPL10(m) ", " STRING(m(11))
361 #define SCPL12(m) SCPL11(m) ", " STRING(m(12))
362 #define SCPL13(m) SCPL12(m) ", " STRING(m(13))
363 #define SCPL14(m) SCPL13(m) ", " STRING(m(14))
364 #define SCPL15(m) SCPL14(m) ", " STRING(m(15))
365 #define SCPL16(m) SCPL15(m) ", " STRING(m(16))
366 #define SCPL17(m) SCPL16(m) ", " STRING(m(17))
367 #define SCPL18(m) SCPL17(m) ", " STRING(m(18))
368 #define SCPL19(m) SCPL18(m) ", " STRING(m(19))
375 #define JEPD JNIEnv * env
378 #define SJET "JNIEnv *"
383 #define JCPD jclass cls
386 #define SJCT "jclass"
391 #define TFRTD typename RT
394 #define CFRT typename RT::CF_t
397 #define JFRT typename RT::JF_t
400 #define JART typename RT::JA_t
403 #define CART typename RT::CA_t
406 #define SJFRT "RT::JF_t"
409 #define CARD CART car
412 #define JARD JART jar = 0
417 #define TFOT typename OT
420 #define SCFOT OT::CF_t
423 #define JAOT typename OT::JA_t
426 #define CAOT typename OT::CA_t
429 #define JFOPD typename OT::JF_t jfo
432 #define SJFOT "OT::JF_t"
437 #define TFPT(n) P##n##T
440 #define TFPTD(n) typename P##n##T
443 #define CFPT(n) typename P##n##T::CF_t
446 #define JFPT(n) typename P##n##T::JF_t
449 #define JAPT(n) typename P##n##T::JA_t
452 #define CAPT(n) typename P##n##T::CA_t
455 #define JFPD(n) JFPT(n) jfp##n
458 #define JFP(n) jfp##n
461 #define CAP(n) cap##n
464 #define SJFPT(n) P##n##T::JF_t
469 #define SFD int s = 1; (void)s;
471 #define PARAM_CONV_BEGIN(n) \
472 JAPT(n) jap##n = cast< JAPT(n), JFPT(n) >(jfp##n); \
473 CAPT(n) cap##n = Param< JAPT(n), CAPT(n) >::convert(s, jap##n, env); \
476 #define PARAM_CONV_END(n) \
477 Param< JAPT(n), CAPT(n) >::release(cap##n, jap##n, env); \
480 #define TARGET_CONV_BEGIN \
481 JAOT jao = cast< JAOT, TFOT::JF_t >(jfo); \
482 CAOT & cao = Target< JAOT, CAOT >::convert(s, jao, env); \
485 #define TARGET_CONV_END \
486 Target< JAOT, CAOT >::release(cao, jao, env); \
489 #define RESULT_CONV \
490 jar = Result< JART, CART >::convert(car, env);
492 #define RESULT_CAST \
493 cast< JFRT, JART >(jar);
506 TRACE(SJFRT
" gget(" SJET
", " SJCT
")");
521 TRACE(SJFRT
" gget(" SJET
", " SJFOT
")");
536 gset(JEPD, JCPD, JFPD(1))
538 TRACE(
"void" " gset(" SJET
", " SJCT
", " STRING(SJFPT(1))
")");
551 gset(JEPD, JFOPD CPL1(JFPD))
553 TRACE(
"void" " gset(" SJET
", " SJFOT
", " STRING(SJFPT(1))
")");
568 template< CTL##n(TFPTD) \
569 void F(CSL##n(CFPT)) > \
571 gcall_fv(JEPD, JCPD CPL##n(JFPD)) \
573 TRACE("void" " gcall_fv(" SJET ", " SJCT SCPL##n(SJFPT) ")"); \
574 (void)env; (void)cls; \
576 BSL##n(PARAM_CONV_BEGIN); \
578 RBSL##n(PARAM_CONV_END); \
611 CFRT F(CSL##n(CFPT)) > \
613 gcall_fr(JEPD, JCPD CPL##n(JFPD)) \
615 TRACE(SJFRT " gcall_fr(" SJET ", " SJCT SCPL##n(SJFPT) ")"); \
619 BSL##n(PARAM_CONV_BEGIN); \
620 CARD = F( CSL##n(CAP) ); \
622 RBSL##n(PARAM_CONV_END); \
623 return RESULT_CAST; \
665 void (SCFOT::*F)(CSL##n(CFPT)) > \
667 gcall_mfv(JEPD, JFOPD CPL##n(JFPD)) \
669 TRACE("void" " gcall_mfv(" SJET ", " SJFOT SCPL##n(SJFPT) ")"); \
672 BSL##n(PARAM_CONV_BEGIN); \
673 ((cao).*F)( CSL##n(CAP) ); \
674 RBSL##n(PARAM_CONV_END); \
718 CFRT (SCFOT::*F)(CSL##n(CFPT)) > \
720 gcall_mfr(JEPD, JFOPD CPL##n(JFPD)) \
722 TRACE(SJFRT " gcall_mfr(" SJET ", " SJFOT SCPL##n(SJFPT) ")"); \
726 BSL##n(PARAM_CONV_BEGIN); \
727 CARD = ((cao).*F)( CSL##n(CAP) ); \
729 RBSL##n(PARAM_CONV_END); \
731 return RESULT_CAST; \
763 template< typename C > struct ArrayHelper;
765 template< typename C >
766 struct ArrayHelper< C * > {
769 TRACE(
"void ArrayHelper::cdelete(C *)");
774 ccreate(int32_t p0) {
775 TRACE(
"C * ArrayHelper::ccreate(int32_t)");
781 cat(C * p0, int32_t
i) {
782 TRACE(
"C * ArrayHelper::cat(C *)");
787 template<
typename C >
791 TRACE(
"void ArrayHelper::cdelete(C &)");
792 ArrayHelper< C * >::cdelete(&p0);
796 ccreate(int32_t p0) {
797 TRACE(
"C & ArrayHelper::ccreate(int32_t)");
798 return *ArrayHelper< C * >::ccreate(p0);
802 cat(C & p0, int32_t
i) {
803 TRACE(
"C & ArrayHelper::cat(C &)");
804 return *ArrayHelper< C * >::cat(&p0, i);
811 template<
typename C >
struct Destructor;
813 template<
typename C >
817 TRACE(
"void Destructor::cdelete(C *)");
822 template<
typename C >
826 TRACE(
"void Destructor::cdelete(C &)");
827 Destructor< C * >::cdelete(&p0);
832 #define CC_TFPT(n) P##n##_CF_t
835 #define CC_TFPTD(n) typename CC_TFPT(n)
838 #define CC_CFPT(n) CC_TFPT(n)
841 #define CC_CFP(n) cfp##n
844 #define CC_CFPD(n) CC_CFPT(n) CC_CFP(n)
848 template< typename C CPL##n(CC_TFPTD) > struct Constructor##n; \
850 template< typename C CPL##n(CC_TFPTD) > \
851 struct Constructor##n< C * CPL##n(CC_TFPT) > { \
853 ccreate(CSL##n(CC_CFPD)) { \
854 TRACE("C * ccreate(" SCSL##n(CC_TFPT) ")"); \
855 return new C(CSL##n(CC_CFP)); \
859 template< typename C CPL##n(CC_TFPTD) > \
860 struct Constructor##n< C & CPL##n(CC_TFPT) > { \
862 ccreate(CSL##n(CC_CFPD)) { \
863 TRACE("C & ccreate(" SCSL##n(CC_TFPT) ")"); \
864 return *Constructor##n< C * CPL##n(CC_TFPT) > \
865 ::ccreate(CSL##n(CC_CFP)); \
899 gdeleteArray(JEPD, JCPD, JFPD(1))
901 TRACE(
"void gdeleteArray(" SJET
", " SJCT
", " STRING(SJFPT(1))
")");
906 #ifdef JTIE_OBJECT_CLEAR_ADDRESS_UPON_DELETE
907 detachWrapper(jap1, env);
908 #endif // JTIE_OBJECT_CLEAR_ADDRESS_UPON_DELETE
909 ArrayHelper< CFPT(1) >::cdelete(CAP(1));
914 template< TFRTD, TFPTD(1) >
917 gcreateArray(JEPD, JCPD, JFPD(1))
919 TRACE(SJFRT
" gcreateArray(" SJET
", " SJCT
", " STRING(SJFPT(1))
")");
920 return gcall_fr< RT, TFPT(1),
921 &ArrayHelper< CFRT >::ccreate
926 template< TFRTD, TFPTD(1), TFPTD(2) >
929 gat(JEPD, JCPD, JFPD(1), JFPD(2))
931 TRACE(SJFRT
" gat(" SJET
", " SJCT
", " STRING(SJFPT(1))
", " STRING(SJFPT(2))
")");
932 return gcall_fr< RT, TFPT(1), TFPT(2),
933 &ArrayHelper< CFRT >::cat
934 >(env, cls, JFP(1), JFP(2));
943 gdelete(JEPD, JCPD, JFPD(1))
945 TRACE(
"void gdelete(" SJET
", " SJCT
", " STRING(SJFPT(1))
")");
950 #ifdef JTIE_OBJECT_CLEAR_ADDRESS_UPON_DELETE
951 detachWrapper(jap1, env);
952 #endif // JTIE_OBJECT_CLEAR_ADDRESS_UPON_DELETE
953 Destructor< CFPT(1) >::cdelete(CAP(1));
959 template< TFRTD CPL##n(TFPTD) > \
961 gcreate(JEPD, JCPD CPL##n(JFPD)) \
963 TRACE(SJFRT " gcreate(" SJET ", " SJCT SCSL##n(SJFPT) ")"); \
964 return gcall_fr< RT, CTL##n(TFPT) \
965 &Constructor##n< CFRT CPL##n(CFPT) >::ccreate \
966 >(env, cls CPL##n(JFP)); \
993 #endif // jtie_gcalls_hpp