Represents information about a global variable declared using $var in the Xc++ language.
$struct+ ReflectedGlobalVariable
{
$ConstStringZ GetName() const { return m_name; }
$void* GetAddress() const { return m_address; }
//////////////// State //////////////////
ConstStringZ m_name;
void* m_address;
const octet_t* m_bc;
ConstStringZ const* m_stringTable;
};
ConstStringZ m_name
The fully qualified name of the global variable represented as a pointer to a UTF-8 encoded null-terminated string (see ConstStringZ).
void* m_address
The address in memory of the global variable.
const octet_t* m_bc
Pointer to an array of octets which is the byte code defining the type of the global variable.
ConstStringZ const* m_stringTable
The address of an array of pointers to UTF-8 encoded null-terminated strings (see ConstStringZ), which is the string table associated with the byte code defining the type of the global variable. May be null if no string table is required.
The following is a definition of a reflected global variable in xc++
namespace ns
{
$var+ int32 x = 10;
}
A global variable must be defined only once. Therefore definitions of global variables appear in cpp files not header files.
This definition is translated to the following C++
namespace ns
{
ceda::int32 x = 10;
}
and produces the following registration code:
//### $var+ ns::x
namespace ceda { XTarget* Ceda_Core_Object_exObject_GetXTarget(); }
namespace ns
{
void _Register_x()
{
static const ceda::octet_t x_type[] =
{
0x04
};
static const ceda::ReflectedGlobalVariable x_var =
{
"ns::x",
&x,
x_type,
0
};
cxVerify(ceda::RegisterReflectedGlobalVariable(&x_var,ceda::Ceda_Core_Object_exObject_GetXTarget()) == ceda::NSE_OK);
}
} // ns
Declarations of global variables in header files are qualified with extern
.
For example:
namespace ns
{
$var+ extern int32 x;
}
For a windows dll __declspec(dllexport)
or __declspec(dllimport)
are
applied as required to both declarations and definitions of global variables.