@@ -489,4 +489,99 @@ MCScriptForeignPrimitiveType MCScriptQueryForeignHandlerParameterTypeInModule(MC
489489
490490////////////////////////////////////////////////////////////////////////////////
491491
492+ enum MCJavaCallType {
493+ MCJavaCallTypeInstance ,
494+ MCJavaCallTypeStatic ,
495+ MCJavaCallTypeNonVirtual ,
496+ MCJavaCallTypeConstructor ,
497+ MCJavaCallTypeInterfaceProxy ,
498+ MCJavaCallTypeGetter ,
499+ MCJavaCallTypeSetter ,
500+ MCJavaCallTypeStaticGetter ,
501+ MCJavaCallTypeStaticSetter ,
502+
503+ /* This value is used to indicate that the call type was not known - it is
504+ * only used internally in libscript. */
505+ MCJavaCallTypeUnknown = -1 ,
506+ };
507+
508+ /* MCScriptForeignHandlerLanguage describes the type of foreign handler which
509+ * has been bound - based on language. */
510+ enum MCScriptForeignHandlerLanguage
511+ {
512+ /* The handler has not yet been bound, or failed to bind */
513+ kMCScriptForeignHandlerLanguageUnknown ,
514+
515+ /* The handler should be called using libffi */
516+ kMCScriptForeignHandlerLanguageC ,
517+
518+ /* The handler has a lc-compile generated shim, so can be called directly */
519+ kMCScriptForeignHandlerLanguageBuiltinC ,
520+
521+ /* The handler should be called using objc_msgSend */
522+ kMCScriptForeignHandlerLanguageObjC ,
523+
524+ /* The handler should be called using the JNI */
525+ kMCScriptForeignHandlerLanguageJava ,
526+ };
527+
528+ /* MCScriptThreadAffinity describes which thread a foreign handler should be
529+ * executed on. This applies to Android and iOS, where a handler can either be
530+ * run on the default (engine) thread, or the UI (main) thread. */
531+ enum MCScriptThreadAffinity
532+ {
533+ kMCScriptThreadAffinityDefault ,
534+ kMCScriptThreadAffinityUI ,
535+ };
536+
537+ /* MCScriptForeignHandlerObjcCallType describes how to call the objective-c
538+ * method. */
539+ enum MCScriptForeignHandlerObjcCallType
540+ {
541+ /* Call the method using method_invoke on the instance (on the default
542+ * thread) */
543+ kMCScriptForeignHandlerObjcCallTypeInstanceMethod ,
544+
545+ /* Call the method using method_invoke on the class instance (on the default
546+ * thread) */
547+ kMCScriptForeignHandlerObjcCallTypeClassMethod ,
548+ };
549+
550+ struct MCScriptForeignHandlerInfo
551+ {
552+ MCScriptForeignHandlerLanguage language : 8 ;
553+ MCScriptThreadAffinity thread_affinity : 8 ;
554+ union
555+ {
556+ struct
557+ {
558+ int call_type ;
559+ MCStringRef library ;
560+ MCStringRef function ;
561+ } c ;
562+ struct
563+ {
564+ MCScriptForeignHandlerObjcCallType call_type : 8 ;
565+ MCStringRef library ;
566+ MCStringRef class_name ;
567+ MCStringRef method_name ;
568+ } objc ;
569+ struct
570+ {
571+ MCJavaCallType call_type : 8 ;
572+ MCStringRef class_name ;
573+ MCStringRef method_name ;
574+ MCStringRef arguments ;
575+ MCStringRef return_type ;
576+ } java ;
577+ };
578+ };
579+
580+ typedef struct MCScriptForeignHandlerInfo * MCScriptForeignHandlerInfoRef ;
581+
582+ bool MCScriptForeignHandlerInfoParse (MCStringRef p_binding , MCScriptForeignHandlerInfoRef & r_info );
583+ void MCScriptForeignHandlerInfoRelease (MCScriptForeignHandlerInfoRef p_info );
584+
585+ ////////////////////////////////////////////////////////////////////////////////
586+
492587#endif
0 commit comments