mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
autogen implement structs with name after definition
This commit is contained in:
parent
bb768ef55b
commit
5a2e060c2d
6 changed files with 31 additions and 3 deletions
|
|
@ -260,7 +260,9 @@ def table_to_string(table):
|
|||
|
||||
def parse_struct(struct_str, sortFields = True):
|
||||
struct = {}
|
||||
identifier = struct_str.split(' ')[1]
|
||||
match = re.match(r"struct\s*(\w+)?\s*{(.*?)}\s*(\w+)?\s*", struct_str.replace("typedef ", ""), re.DOTALL)
|
||||
struct_name, body, trailing_name = match.groups()
|
||||
identifier = struct_name if struct_name else trailing_name
|
||||
struct['identifier'] = identifier
|
||||
|
||||
body = struct_str.split('{', 1)[1].rsplit('}', 1)[0]
|
||||
|
|
@ -277,7 +279,9 @@ def parse_struct(struct_str, sortFields = True):
|
|||
field_type, field_id = field_str.strip().rsplit('*', 1)
|
||||
field_type = field_type.strip() + '*'
|
||||
else:
|
||||
field_type, field_id = field_str.strip().rsplit(' ', 1)
|
||||
split_parts = re.split(r'\s+', field_str.strip())
|
||||
field_type = ' '.join(split_parts[:-1])
|
||||
field_id = split_parts[-1]
|
||||
|
||||
if '[' in field_id:
|
||||
array_str = '[' + field_id.split('[', 1)[1]
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ def extract_structs(filename):
|
|||
continue
|
||||
if ';' not in line:
|
||||
continue
|
||||
if not line.startswith('struct '):
|
||||
if not line.startswith('struct ') and not line.startswith('typedef struct '):
|
||||
continue
|
||||
txt += line + '\n'
|
||||
|
||||
|
|
|
|||
|
|
@ -2302,6 +2302,10 @@
|
|||
--- @field public posPitch integer
|
||||
--- @field public posYaw integer
|
||||
|
||||
--- @class Vtx_Interp
|
||||
--- @field public n string
|
||||
--- @field public ob Array_number
|
||||
|
||||
--- @class WallCollisionData
|
||||
--- @field public normalAddition Vec3f
|
||||
--- @field public normalCount integer
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@
|
|||
- [Vec3s](#Vec3s)
|
||||
- [Vec4f](#Vec4f)
|
||||
- [Vec4s](#Vec4s)
|
||||
- [Vtx_Interp](#Vtx_Interp)
|
||||
- [WallCollisionData](#WallCollisionData)
|
||||
- [WarpNode](#WarpNode)
|
||||
- [WarpTransition](#WarpTransition)
|
||||
|
|
@ -3197,6 +3198,17 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [Vtx_Interp](#Vtx_Interp)
|
||||
|
||||
| Field | Type | Access |
|
||||
| ----- | ---- | ------ |
|
||||
| n | `string` | |
|
||||
| ob | `Array` <`number`> | |
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [WallCollisionData](#WallCollisionData)
|
||||
|
||||
| Field | Type | Access |
|
||||
|
|
|
|||
|
|
@ -2679,6 +2679,12 @@ static struct LuaObjectField sTransitionInfoFields[LUA_TRANSITION_INFO_FIELD_COU
|
|||
{ "posYaw", LVT_S16, offsetof(struct TransitionInfo, posYaw), false, LOT_NONE, 1, sizeof(s16) },
|
||||
};
|
||||
|
||||
#define LUA_VTX__INTERP_FIELD_COUNT 2
|
||||
static struct LuaObjectField sVtx_InterpFields[LUA_VTX__INTERP_FIELD_COUNT] = {
|
||||
{ "n", LVT_STRING, offsetof(struct Vtx_Interp, n), false, LOT_NONE, 1, sizeof(signed char) },
|
||||
{ "ob", LVT_FLOAT, offsetof(struct Vtx_Interp, ob), false, LOT_NONE, 3, sizeof(float) },
|
||||
};
|
||||
|
||||
#define LUA_WALL_COLLISION_DATA_FIELD_COUNT 10
|
||||
static struct LuaObjectField sWallCollisionDataFields[LUA_WALL_COLLISION_DATA_FIELD_COUNT] = {
|
||||
{ "normalAddition", LVT_COBJECT, offsetof(struct WallCollisionData, normalAddition), true, LOT_VEC3F, 1, sizeof(Vec3f) },
|
||||
|
|
@ -2854,6 +2860,7 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN]
|
|||
{ LOT_SURFACE, sSurfaceFields, LUA_SURFACE_FIELD_COUNT },
|
||||
{ LOT_TEXTUREINFO, sTextureInfoFields, LUA_TEXTURE_INFO_FIELD_COUNT },
|
||||
{ LOT_TRANSITIONINFO, sTransitionInfoFields, LUA_TRANSITION_INFO_FIELD_COUNT },
|
||||
{ LOT_VTX_INTERP, sVtx_InterpFields, LUA_VTX__INTERP_FIELD_COUNT },
|
||||
{ LOT_WALLCOLLISIONDATA, sWallCollisionDataFields, LUA_WALL_COLLISION_DATA_FIELD_COUNT },
|
||||
{ LOT_WARPNODE, sWarpNodeFields, LUA_WARP_NODE_FIELD_COUNT },
|
||||
{ LOT_WARPTRANSITION, sWarpTransitionFields, LUA_WARP_TRANSITION_FIELD_COUNT },
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ enum LuaObjectAutogenType {
|
|||
LOT_SURFACE,
|
||||
LOT_TEXTUREINFO,
|
||||
LOT_TRANSITIONINFO,
|
||||
LOT_VTX_INTERP,
|
||||
LOT_WALLCOLLISIONDATA,
|
||||
LOT_WARPNODE,
|
||||
LOT_WARPTRANSITION,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue