mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-19 00:15:30 +00:00
DEVTOOLS: DIRECTOR: Update XTRA generation
In D5 XTRAs have the property "name". Adds the code generation for XTRAs to have this property. According to Director 5 Lingo Dictionary the name is gettable and settable. Occording to my tests in D5-win, it's only gettable. When opening the XTRA, register the XTRA on the _openXtras array. There's a check if the object is an XTRA when registering. This way the generated code works when generation Xobj's as well.
This commit is contained in:
parent
ff35717ec7
commit
2ef049b509
@ -67,7 +67,7 @@ namespace Director {{
|
||||
|
||||
class {xobject_class} : public Object<{xobject_class}> {{
|
||||
public:
|
||||
{xobject_class}(ObjectType objType);
|
||||
{xobject_class}(ObjectType objType);{xtra_props_h}
|
||||
}};
|
||||
|
||||
namespace {xobj_class} {{
|
||||
@ -132,11 +132,13 @@ static BuiltinProto xlibBuiltins[] = {{
|
||||
|
||||
{xobject_class}::{xobject_class}(ObjectType ObjectType) :Object<{xobject_class}>("{name}") {{
|
||||
_objType = ObjectType;
|
||||
}}
|
||||
}}{xtra_props}
|
||||
|
||||
void {xobj_class}::open(ObjectType type, const Common::Path &path) {{
|
||||
{xobject_class}::initMethods(xlibMethods);
|
||||
{xobject_class} *xobj = new {xobject_class}(type);
|
||||
if (type == kXtraObj)
|
||||
g_lingo->_openXtras.push_back(xlibName);
|
||||
g_lingo->exposeXObject(xlibName, xobj);
|
||||
g_lingo->initBuiltIns(xlibBuiltins);
|
||||
}}
|
||||
@ -162,6 +164,26 @@ XLIB_NEW_TEMPLATE = """void {xobj_class}::m_new(int nargs) {{
|
||||
}}"""
|
||||
|
||||
|
||||
# XTRA PROPS TEMPLATE and Header contains extra newline at the beginning.
|
||||
# This keeps the newlines correct when `TEMPLATE` is used for xlibs.
|
||||
XTRA_PROPS_TEMPLATE = """
|
||||
|
||||
bool {xobject_class}::hasProp(const Common::String &propName) {{
|
||||
return (propName == "name");
|
||||
}}
|
||||
|
||||
Datum {xobject_class}::getProp(const Common::String &propName) {{
|
||||
if (propName == "name")
|
||||
return Datum({xobj_class}::xlibName);
|
||||
warning("{xobj_class}::getProp: unknown property '%s'", propName.c_str());
|
||||
return Datum();
|
||||
}}"""
|
||||
|
||||
XTRA_PROPS_H = """
|
||||
|
||||
bool hasProp(const Common::String &propName) override;
|
||||
Datum getProp(const Common::String &propName) override;"""
|
||||
|
||||
|
||||
XCMD_TEMPLATE_H = (
|
||||
LEGAL
|
||||
@ -718,6 +740,7 @@ def generate_xobject_stubs(
|
||||
for x in meths
|
||||
]
|
||||
),
|
||||
xtra_props="",
|
||||
xobj_new=XLIB_NEW_TEMPLATE.format(xobj_class=xobj_class),
|
||||
xobj_stubs="\n".join(
|
||||
[
|
||||
@ -742,6 +765,7 @@ def generate_xobject_stubs(
|
||||
slug_upper=slug.upper(),
|
||||
xobject_class=xobject_class,
|
||||
xobj_class=xobj_class,
|
||||
xtra_props_h="",
|
||||
methlist="\n".join([TEMPLATE_HEADER_METH.format(**x) for x in meths]),
|
||||
)
|
||||
if dry_run:
|
||||
@ -888,6 +912,8 @@ def generate_xtra_stubs(
|
||||
director_version=director_version,
|
||||
methtype="HBLTIN",
|
||||
) for x in meths if x["functype"] == "toplevel"]),
|
||||
xtra_props=XTRA_PROPS_TEMPLATE.format(xobj_class=xobj_class,
|
||||
xobject_class=xobject_class),
|
||||
xobj_new=XLIB_NEW_TEMPLATE.format(xobj_class=xobj_class),
|
||||
xobj_stubs="\n".join(
|
||||
[
|
||||
@ -910,6 +936,7 @@ def generate_xtra_stubs(
|
||||
slug_upper=slug.upper(),
|
||||
xobject_class=xobject_class,
|
||||
xobj_class=xobj_class,
|
||||
xtra_props_h=XTRA_PROPS_H,
|
||||
methlist="\n".join([TEMPLATE_HEADER_METH.format(**x) for x in meths]),
|
||||
)
|
||||
if dry_run:
|
||||
|
Loading…
x
Reference in New Issue
Block a user