@@ -614,6 +614,112 @@ bool MCScriptEnsureModuleIsUsable(MCScriptModuleRef self)
614614
615615// //////////////////////////////////////////////////////////////////////////////
616616
617+ bool MCScriptCopyDependenciesOfModule (MCScriptModuleRef self, /* copy */ MCProperListRef& r_module_names)
618+ {
619+ MCAutoProperListRef t_modules;
620+ if (!MCProperListCreateMutable (&t_modules))
621+ return false ;
622+
623+ for (uindex_t i = 0 ; i < self -> dependency_count; i++)
624+ if (!MCProperListPushElementOntoBack (*t_modules, self -> dependencies[i] . name))
625+ return false ;
626+
627+ if (!MCProperListCopy (*t_modules, r_module_names))
628+ return false ;
629+
630+ return true ;
631+ }
632+
633+ bool MCScriptCopyPropertiesOfModule (MCScriptModuleRef self, /* copy */ MCProperListRef& r_property_names)
634+ {
635+ MCAutoProperListRef t_props;
636+ if (!MCProperListCreateMutable (&t_props))
637+ return false ;
638+
639+ for (uindex_t i = 0 ; i < self -> exported_definition_count; i++)
640+ if (self -> definitions[self -> exported_definitions[i] . index] -> kind == kMCScriptDefinitionKindProperty )
641+ if (!MCProperListPushElementOntoBack (*t_props, self -> exported_definitions[i] . name))
642+ return false ;
643+
644+ if (!MCProperListCopy (*t_props, r_property_names))
645+ return false ;
646+
647+ return true ;
648+ }
649+
650+ bool MCScriptQueryPropertyOfModule (MCScriptModuleRef self, MCNameRef p_property, /* get */ MCTypeInfoRef& r_getter, /* get */ MCTypeInfoRef& r_setter)
651+ {
652+ MCScriptPropertyDefinition *t_def;
653+
654+ if (!self -> is_usable)
655+ return false ; // TODO - throw error
656+
657+ if (!MCScriptLookupPropertyDefinitionInModule (self, p_property, t_def))
658+ return false ; // TODO - throw error
659+
660+ MCScriptDefinition *t_getter;
661+ t_getter = t_def -> getter != 0 ? self -> definitions[t_def -> getter - 1 ] : nil;
662+
663+ if (t_getter != nil)
664+ {
665+ if (t_getter -> kind == kMCScriptDefinitionKindVariable )
666+ r_getter = self -> types[static_cast <MCScriptVariableDefinition *>(t_getter) -> type] -> typeinfo;
667+ else
668+ r_getter = MCHandlerTypeInfoGetReturnType (self -> types[static_cast <MCScriptHandlerDefinition *>(t_getter) -> type] -> typeinfo);
669+ }
670+ else
671+ r_getter = nil;
672+
673+ MCScriptDefinition *t_setter;
674+ t_setter = t_def -> setter != 0 ? self -> definitions[t_def -> setter - 1 ] : nil;
675+
676+ if (t_setter != nil)
677+ {
678+ if (t_setter -> kind == kMCScriptDefinitionKindVariable )
679+ r_setter = self -> types[static_cast <MCScriptVariableDefinition *>(t_setter) -> type] -> typeinfo;
680+ else
681+ r_setter = MCHandlerTypeInfoGetParameterType (self -> types[static_cast <MCScriptHandlerDefinition *>(t_setter) -> type] -> typeinfo, 0 );
682+ }
683+ else
684+ r_setter = nil;
685+
686+ return true ;
687+ }
688+
689+ bool MCScriptCopyEventsOfModule (MCScriptModuleRef self, /* copy */ MCProperListRef& r_event_names)
690+ {
691+ MCAutoProperListRef t_events;
692+ if (!MCProperListCreateMutable (&t_events))
693+ return false ;
694+
695+ for (uindex_t i = 0 ; i < self -> exported_definition_count; i++)
696+ if (self -> definitions[self -> exported_definitions[i] . index] -> kind == kMCScriptDefinitionKindEvent )
697+ if (!MCProperListPushElementOntoBack (*t_events, self -> exported_definitions[i] . name))
698+ return false ;
699+
700+ if (!MCProperListCopy (*t_events, r_event_names))
701+ return false ;
702+
703+ return true ;
704+ }
705+
706+ bool MCScriptQueryEventOfModule (MCScriptModuleRef self, MCNameRef p_event, /* get */ MCTypeInfoRef& r_signature)
707+ {
708+ MCScriptEventDefinition *t_def;
709+
710+ if (!self -> is_usable)
711+ return false ; // TODO - throw error
712+
713+ if (!MCScriptLookupEventDefinitionInModule (self, p_event, t_def))
714+ return false ; // TODO - throw error
715+
716+ r_signature = self -> types[t_def -> type] -> typeinfo;
717+
718+ return true ;
719+ }
720+
721+ // //////////////////////////////////////////////////////////////////////////////
722+
617723bool MCScriptWriteRawModule (MCStreamRef stream, MCScriptModule *p_module)
618724{
619725 return MCPickleWrite (stream, kMCScriptModulePickleInfo , p_module);
@@ -650,6 +756,25 @@ bool MCScriptLookupPropertyDefinitionInModule(MCScriptModuleRef self, MCNameRef
650756 return false ;
651757}
652758
759+ bool MCScriptLookupEventDefinitionInModule (MCScriptModuleRef self, MCNameRef p_property, MCScriptEventDefinition*& r_definition)
760+ {
761+ __MCScriptValidateObjectAndKind__ (self, kMCScriptObjectKindModule );
762+
763+ for (uindex_t i = 0 ; i < self -> exported_definition_count; i++)
764+ {
765+ if (self -> definitions[self -> exported_definitions[i] . index] -> kind != kMCScriptDefinitionKindEvent )
766+ continue ;
767+
768+ if (!MCNameIsEqualTo (p_property, self -> exported_definitions[i] . name))
769+ continue ;
770+
771+ r_definition = static_cast <MCScriptEventDefinition *>(self -> definitions[self -> exported_definitions[i] . index]);
772+ return true ;
773+ }
774+
775+ return false ;
776+ }
777+
653778bool MCScriptLookupHandlerDefinitionInModule (MCScriptModuleRef self, MCNameRef p_handler, MCScriptHandlerDefinition*& r_definition)
654779{
655780 __MCScriptValidateObjectAndKind__ (self, kMCScriptObjectKindModule );
0 commit comments