I have Global Variables which the user configures in the UI. These variables are not declared in the script the use writes, they are to be generated by the application before building the script. Often, these variables link to objects which already exist in the application.
These Global Variables are typically handles (or constant handles) to reference types. I do not register a factory for these types, because I do not wish for the user to be able to create his own instances of these objects (they would have no meaning unless they were properly linked to the application).
I have been creating an independent section for the declarations of these handles. I add that section to the module with the user's section, and then I build the module without initializing global variables. I then get a pointer to those handles and set them to point to the correct objects. The problem is that if the user declares a handle to one of these types and initializes it in the global section, it will be invalid.
// Secret Global Section
const MyLinkedType@ v1;
// User section
const MyLinkedType@ u1 = v1
int main()
{
const MyLinkedType@ u2 = v1
if (u1 is v1)
return 1;
else if (u2 is v1)
return 2; // This is what returns.
else
return 0;
}
The user's global variable u1 is initialized to the initial value of v1, which is null. Then I set the value of v1, so by the time main is called later u2 is properly initialized to point to v1.
If I defer global initialization and set the value of v1 before calling "ResetGlobalVars" then v1 gets reset to null during initialization.
Does anybody have suggestions as to how I might include these variables in the module so that they are available to the user's script when it is built?