Moderator
Posts: 2329 from 2003/2/24
I hope to have the general API figured out so if there are any complaints/suggestions now is the time:
Code:
abox = {}
abox.Types = {{"ULONG",4},{"LONG",4},{"APTR",4},{"STRPTR",4},{"UWORD",2},{"WORD",2}}
mui.MUI_MinMax =
{
name = "MUI_MinMax",
{"WORD", "MinWidth"},
{"WORD", "MinHeight"},
{"WORD", "MaxWidth"},
{"WORD", "MaxHeight"},
{"WORD", "DefWidth"},
{"WORD", "DefHeight"}
}
mui.MinMax =
{
{"WORD", "MinWidth"},
{"WORD", "MinHeight"},
{"WORD", "MaxWidth"},
{"WORD", "MaxHeight"},
{"WORD", "DefWidth"},
{"WORD", "DefHeight"}
}
mui.MUIP_AskMinMax =
{
name = "MUIP_AskMinMax",
{"ULONG","MethodID"},
{"APTR","MinMaxInfo"}
}
mui.opSet =
{
name = "opSet",
{"ULONG", "MethodID"},
{"APTR", "ops_AttrList"},
{"APTR", "ops_GInfo"}
}
mui.TagItem =
{
name = "TagItem",
{"ULONG", "ti_Tag"},
{"ULONG", "ti_Data"}
}
mui.OM_NEW = 0x101
mui.OM_DISPOSE = 0x102
mui.OM_SET = 0x103
mui.OM_GET = 0x104
mui.OM_ADDTAIL = 0x105
mui.OM_REMOVE = 0x106
mui.OM_NOTIFY = 0x107
mui.OM_UPDATE = 0x108
mui.OM_ADDMEMBER = 0x109
This is how C-structures will look from the LUA side, obviously most of this code would be in a separate (autogenerated) file, but for now it's in my test-script.
Code:
function areaamm(cl,obj,msg)
muip = struct.new(msg,mui.MUIP_AskMinMax)
amm = struct.new(amma,mui.MUI_MinMax)
amm.MinHeight = 100
amm.MinWidth = 100
amm.DefHeight = 110
amm.DefWidth = 150
amm.MaxHeight = 500
amm.MaxWidth = 500
end
The MUIM_AskMinMax method for my class. "cl" is just the C-pointer and of no use as of now, "obj" is the LUA-muiobj (userdata containing the C-pointer), "msg" is again just the C-pointer but I hope to change that before release.
1st line of code creates a userdata-object of type "struct" pointing to the address of "msg" and being described as MUIP_AskMinMax. This step will be eliminated.
"amm" is again a userdata object pointing to the MUI_MinMax field in "msg".
The following lines directly manipulate the values there (at the same address as a C function would do, so no need to write anything back or so). Now proper MUI-code would do "amm.MaxWidth = amm.MaxWidth +500" but it's good enough for now.
Code:
area_dis = {{mui.MUIM_AskMinMax,areaamm,mui.PreSuper,areaamm,mui.MUIP_AskMinMax},
{mui.OM_SET, areaset,mui.PreSuper,mui.opSet}}
The dispatcher, as simple as gets, last part not (yet) used (see above). The mui.PreSuper is something that might go away depending on how costly calling "DoSuperMethod()" from LUA might turn out to be.
Code:
a_class = mui.createcostumclass(mui.MUIC_Area,area_dis,area_data)
area = mui.new(a_class, mui.MUIA_String_Contents,"bababba" )
Create a class and object. "area_data" not yet implemented and obviosly no point in sending MUIA_String_Contents to an Area object, but it does work when baseclass is MUIC_String.
[ Edited by Kronos 09.11.2019 - 11:16 ]