If the table does not have a tocom tag method (for Lua 4) or
__tocom metamethod (for Lua 5), LuaCOM first checks if the
table can be describing a variant. A table is a variant if it has a
Type field. This field must have a string that tells how the
Value field of the table must be converted. Possible values
for Type are string, bool, error,
null, currency, decimal, double,
float, int8, uint8, int4, uint4,
int2, uint2, int1, verb+uint1+, int, and
uint. Each corresponds to a variant type.
If the table is not describing a variant, then it may be describing
a date. A table is a date if it has one of those fields: Day,
DayOfWeek, Month, Year, Hour,
Minute, Second, Milliseconds. LuaCOM
initializes the date with the fields that are present; the others
are kept at their default values.
If the table is not a date, LuaCOM converts Lua tables to SAFEARRAY's and vice-versa. To be converted, Lua tables must be ``array-like'', that is, all of its elements must be or ``scalars'' or tables of the same length. These tables must also be ``array-like''. Here are some samples of how is this conversion done:
| Lua table | Safe Array | |
table = {"name", "phone"} |
|
|
table = {{1,2},{4,9}} |
|
If the table has the conversion tag/metamethod, LuaCOM uses it
to guide the conversion. If the tag/metamethod is a method, LuaCOM
calls it, passing the table and the COM type. The method should return a COM object
that LuaCOM will pass on. If the tag/metamethod is a table, LuaCOM will
look for a typelib field, an interfacefield , and a coclass field,
and pass those as arguments to the ImplInterfaceFromTypelib API call. If the table
does not have a typelib field, LuaCOM will look for a progid field and
an interface field, and pass those to the ImplInterface API call. Either way,
LuaCOM will pass the returned object to COM.