REALcontrol and its subclass embedded in a module

Creating a namespace to a control is fine, but I am experiencing problems with a subclass, also defined in the plugin, which is put in the same module. Trying to update a sample project does not provide a choice when you want to choose the subclass. It is not listed. You can manually type it but then it says the superclass already implemented the event. Not sure what to think of this.

Further, if classes and controls live in a module, it appears that events of a control, having an argument to a class type belonging to the same namespace as the control, need to be changed to explicitly provide the namespace of this type. However, an event of a control, having an argument of another control type in the same namespace does not need to be modified. Is this difference intentional?

[code]REALclassDefinition* BasicScriptClasses[] = {
&ScriptLocationClass, // is mentioned in events of the control ProcessClass
&PostKeyboardClass, // a subclass of the control ProcessClass
&PostMouseClass, // a subclass of the control ProcessClass

&DelegateHandler,
&DelegateClass,       // has a property type of the control ProcessClass

&TaskClass,
&ThreadNotRunningException,
&ThreadAllreadyWaitingException,
&ThreadSafeClass,
&BasClass,

};

REALcontrol* BasicScriptControls[] = {
&RBObjectClass, // has a property type of the control ProcessClass
&ProcessClass, // has events with argument types of ScriptLocationClass <-- needs the namespace
// and RBObjectClass <-- no need
};

REALmoduleDefinition Scripting = {
kCurrentREALControlVersion,
PLUGIN_NAME, // name of the module
nil,// // list of public module methods
0,// // number of entries in the method list
nil, // list of constants
0, // number of constants in the list
nil, // REALproperty *properties;
0,
nil, //REALstructure *structures;
0, //size_t structureCount;
nil, //REALenum *enums;
0, //size_t enumCount;
nil, //REALattribute *attributes;
0, //size_t attributeCount;
nil, //REALdelegate *delegates;
0, //size_t delegateCount;
BasicScriptClasses, //REALclassDefinition **classes;
_countof(BasicScriptClasses),
nil, //REALinterfaceDefinition *interfaces;// Assumes this module’s namespace
0, //size_t interfaceCount;
nil, //struct REALmoduleDefinition **modules;// Assumes this module’s namespace
0, //size_t moduleCount;
BasicScriptControls, //REALcontrol **controls; // Assumes this module’s namespace
_countof(BasicScriptControls) //size_t controlCount;

};
[/code]

A class that defines an event instance is not resolved when it resides in a module namespace, but is resolved when not part of a module. Is there a trick that will make it possible to have such a class in a module?

The relevant code is [code]

#define AS_MODULE 0 /* set to 0 to compile as global classes */
#if AS_MODULE
#define PLUGIN_NAME “ScriptThreadSafeGUIGlue”
#define PLUGIN_NAME_DOT “ScriptThreadSafeGUIGlue.”
#else
#define PLUGIN_NAME “”
#define PLUGIN_NAME_DOT “”
#endif

extern REALclassDefinition BasClass;
typedef struct BasData
{
REALobject self;
void (*_CompilerErr)(REALobject, REALobject location);

} BasData;
BasData* gBasFirst = NULL;
BasData* gBasLast = NULL;

REALevent BasEvents[] = {
/0/ { “CompilerErr(location As “PLUGIN_NAME_DOT” BasicLocation)” },
};

void ResolveBasEvents(REALobject instance)
{
dlog(cc"in ResolveBasEvents");
ClassData(BasClass, instance, BasData, data);
data->_CompilerErr = (void(*)(REALobject, REALobject))REALGetEventInstance((REALcontrolInstance)instance, &BasEvents[0]);
if (data->_CompilerErr) dlog(cc"Resolved BasEvents");
else dlog(cc"Did not resolve BasEvents");
}
[/code]

ResolveBasEvents is call in the constructor of this class or later. For completeness:

REALclassDefinition BasClass = {
    kCurrentREALControlVersion,                             //uint32_t version;
    "Basic",                                                //const char *name;
    nil,                                                    //const char *superName;
    sizeof(BasData),                                        //size_t dataSize;
    0,                                                      //RBInteger forSystemUse;
    (REALproc)Bas_Initializer, (REALproc)Bas_Finalizer,
    nil, 0, //properties
    BasClassMethods, sizeof(BasClassMethods) / sizeof(REALmethodDefinition),
    BasEvents, sizeof(BasEvents) / sizeof(REALevent), // events
    nil, 0, // eventInstances
    nil,	// interfaces
    nil, 0,	// attributes
    nil, 0,	// constants
    REALconsoleSafe | REALScopeGlobal,		// mFlags
    nil, 0,	// sharedProperties
    SharedBasClassMethods, sizeof(SharedBasClassMethods)/sizeof(REALmethodDefinition), // sharedMethods
};