condense function member names

This commit is contained in:
Cooliokid956 2025-11-29 10:01:22 -06:00
parent 5f108f382d
commit ea96704f53
7 changed files with 2048 additions and 2056 deletions

View file

@ -996,7 +996,7 @@ def build_functions(processed_files):
def build_bind(function):
fid = function['identifier']
s = 'smlua_bind_function(L, "%s", smlua_func_%s);' % (fid, fid)
s = 'BIND_FUNCTION(%s);' % fid
if function['implemented']:
s = ' ' + s
# There is no point in adding the ifndef statement if the function is commented out here anyways.

View file

@ -550,26 +550,26 @@ def build_struct(struct):
endStr += '\n#endif'
startStr += ' { '
if ftype == cobject_function_identifier:
row.append(startStr )
row.append('"%s", ' % fid )
row.append('%s, ' % lvt )
row.append('(size_t) FUNCTION__%s, ' % (field['function']))
row.append('%s, ' % fimmutable )
row.append('%s, ' % lot )
row.append('%s, ' % size )
row.append('sizeof(const char *)' )
row.append(endStr )
row.append(startStr )
row.append('"%s", ' % fid )
row.append('%s, ' % lvt )
row.append('(size_t) "%s", ' % field['function'] )
row.append('%s, ' % fimmutable )
row.append('%s, ' % lot )
row.append('%s, ' % size )
row.append('sizeof(const char *)' )
row.append(endStr )
field_functions.append(field['function'])
else:
row.append(startStr )
row.append('"%s", ' % fid )
row.append('%s, ' % lvt )
row.append(startStr )
row.append('"%s", ' % fid )
row.append('%s, ' % lvt )
row.append('offsetof(%s%s, %s), ' % (struct_str, name, field['identifier']))
row.append('%s, ' % fimmutable )
row.append('%s, ' % lot )
row.append('%s, ' % size )
row.append('sizeof(%s)' % ftype )
row.append(endStr )
row.append('%s, ' % fimmutable )
row.append('%s, ' % lot )
row.append('%s, ' % size )
row.append('sizeof(%s)' % ftype )
row.append(endStr )
field_table.append(row)
field_table_str, field_count = table_to_string(field_table)
@ -577,10 +577,6 @@ def build_struct(struct):
struct_lot = 'LOT_%s' % sid.upper()
s = ''
if field_functions:
for field_function in field_functions:
s += 'static const char FUNCTION__%s[] = "%s";\n' % (field_function, field_function)
s += '\n'
s += "#define %s $[STRUCTFIELDCOUNT]\n" % field_count_define
s += "static struct LuaObjectField s%sFields[%s] = {\n" % (sid, field_count_define)

View file

@ -70,38 +70,39 @@ bool smlua_valid_lvt(u16 lvt) {
static const char *sLuaLvtNames[] = {
[LVT_BOOL] = "bool",
[LVT_BOOL_P] = "bool Pointer",
[LVT_BOOL_P] = "bool pointer",
[LVT_U8] = "u8",
[LVT_U8_P] = "u8 Pointer",
[LVT_U8_P] = "u8 pointer",
[LVT_U16] = "u16",
[LVT_U16_P] = "u16 Pointer",
[LVT_U16_P] = "u16 pointer",
[LVT_U32] = "u32",
[LVT_U32_P] = "u32 Pointer",
[LVT_U32_P] = "u32 pointer",
[LVT_S8] = "s8",
[LVT_S8_P] = "s8 Pointer",
[LVT_S8_P] = "s8 pointer",
[LVT_S16] = "s16",
[LVT_S16_P] = "s16 Pointer",
[LVT_S16_P] = "s16 pointer",
[LVT_S32] = "s32",
[LVT_S32_P] = "s32 Pointer",
[LVT_S32_P] = "s32 pointer",
[LVT_F32] = "f32",
[LVT_F32_P] = "f32 Pointer",
[LVT_F32_P] = "f32 pointer",
[LVT_U64] = "u64",
[LVT_U64_P] = "u64 Pointer",
[LVT_U64_P] = "u64 pointer",
[LVT_COBJECT] = "CObject",
[LVT_COBJECT_P] = "CObject Pointer",
[LVT_COBJECT_P] = "CObject pointer",
[LVT_STRING] = "string",
[LVT_STRING_P] = "string Pointer",
[LVT_BEHAVIORSCRIPT_P] = "BehaviorScript Pointer",
[LVT_OBJECTANIMPOINTER_P] = "ObjectAnimPointer Pointer",
[LVT_COLLISION_P] = "Collision Pointer",
[LVT_LEVELSCRIPT_P] = "LevelScript Pointer",
[LVT_TRAJECTORY_P] = "Trajectory Pointer",
[LVT_TEXTURE_P] = "Texture Pointer",
[LVT_STRING_P] = "string pointer",
[LVT_BEHAVIORSCRIPT_P] = "BehaviorScript pointer",
[LVT_OBJECTANIMPOINTER_P] = "ObjectAnimPointer pointer",
[LVT_COLLISION_P] = "Collision pointer",
[LVT_LEVELSCRIPT_P] = "LevelScript pointer",
[LVT_TRAJECTORY_P] = "Trajectory pointer",
[LVT_TEXTURE_P] = "Texture pointer",
[LVT_LUAFUNCTION] = "LuaFunction",
[LVT_LUATABLE] = "LuaTable",
[LVT_POINTER] = "Pointer",
[LVT_FUNCTION] = "Function",
[LVT_MAX] = "Max",
[LVT_POINTER] = "pointer",
[LVT_FUNCTION] = "function",
[LVT_FIELD] = "field",
[LVT_MAX] = "unknown",
};
const char *smlua_get_lvt_name(u16 lvt) {

View file

@ -1498,83 +1498,52 @@ static struct LuaObjectField sModAudioFields[LUA_MOD_AUDIO_FIELD_COUNT] = {
{ "loaded", LVT_BOOL, offsetof(struct ModAudio, loaded), true, LOT_NONE, 1, sizeof(bool) },
};
static const char FUNCTION__mod_fs_clear[] = "mod_fs_clear";
static const char FUNCTION__mod_fs_copy_file[] = "mod_fs_copy_file";
static const char FUNCTION__mod_fs_create_file[] = "mod_fs_create_file";
static const char FUNCTION__mod_fs_delete[] = "mod_fs_delete";
static const char FUNCTION__mod_fs_delete_file[] = "mod_fs_delete_file";
static const char FUNCTION__mod_fs_get_file[] = "mod_fs_get_file";
static const char FUNCTION__mod_fs_get_filename[] = "mod_fs_get_filename";
static const char FUNCTION__mod_fs_move_file[] = "mod_fs_move_file";
static const char FUNCTION__mod_fs_save[] = "mod_fs_save";
static const char FUNCTION__mod_fs_set_public[] = "mod_fs_set_public";
#define LUA_MOD_FS_FIELD_COUNT 15
static struct LuaObjectField sModFsFields[LUA_MOD_FS_FIELD_COUNT] = {
{ "clear", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_clear, true, LOT_NONE, 1, sizeof(const char *) },
{ "copy_file", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_copy_file, true, LOT_NONE, 1, sizeof(const char *) },
{ "create_file", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_create_file, true, LOT_NONE, 1, sizeof(const char *) },
{ "delete", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_delete, true, LOT_NONE, 1, sizeof(const char *) },
{ "delete_file", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_delete_file, true, LOT_NONE, 1, sizeof(const char *) },
{ "get_file", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_get_file, true, LOT_NONE, 1, sizeof(const char *) },
{ "get_filename", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_get_filename, true, LOT_NONE, 1, sizeof(const char *) },
{ "isPublic", LVT_BOOL, offsetof(struct ModFs, isPublic), true, LOT_NONE, 1, sizeof(bool) },
{ "mod", LVT_COBJECT_P, offsetof(struct ModFs, mod), true, LOT_MOD, 1, sizeof(struct Mod*) },
{ "modPath", LVT_STRING, offsetof(struct ModFs, modPath), true, LOT_NONE, 1, sizeof(char) },
{ "move_file", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_move_file, true, LOT_NONE, 1, sizeof(const char *) },
{ "numFiles", LVT_U16, offsetof(struct ModFs, numFiles), true, LOT_NONE, 1, sizeof(u16) },
{ "save", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_save, true, LOT_NONE, 1, sizeof(const char *) },
{ "set_public", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_set_public, true, LOT_NONE, 1, sizeof(const char *) },
{ "totalSize", LVT_U32, offsetof(struct ModFs, totalSize), true, LOT_NONE, 1, sizeof(u32) },
{ "clear", LVT_FUNCTION, (size_t) "mod_fs_clear", true, LOT_NONE, 1, sizeof(const char *) },
{ "copy_file", LVT_FUNCTION, (size_t) "mod_fs_copy_file", true, LOT_NONE, 1, sizeof(const char *) },
{ "create_file", LVT_FUNCTION, (size_t) "mod_fs_create_file", true, LOT_NONE, 1, sizeof(const char *) },
{ "delete", LVT_FUNCTION, (size_t) "mod_fs_delete", true, LOT_NONE, 1, sizeof(const char *) },
{ "delete_file", LVT_FUNCTION, (size_t) "mod_fs_delete_file", true, LOT_NONE, 1, sizeof(const char *) },
{ "get_file", LVT_FUNCTION, (size_t) "mod_fs_get_file", true, LOT_NONE, 1, sizeof(const char *) },
{ "get_filename", LVT_FUNCTION, (size_t) "mod_fs_get_filename", true, LOT_NONE, 1, sizeof(const char *) },
{ "isPublic", LVT_BOOL, offsetof(struct ModFs, isPublic), true, LOT_NONE, 1, sizeof(bool) },
{ "mod", LVT_COBJECT_P, offsetof(struct ModFs, mod), true, LOT_MOD, 1, sizeof(struct Mod*) },
{ "modPath", LVT_STRING, offsetof(struct ModFs, modPath), true, LOT_NONE, 1, sizeof(char) },
{ "move_file", LVT_FUNCTION, (size_t) "mod_fs_move_file", true, LOT_NONE, 1, sizeof(const char *) },
{ "numFiles", LVT_U16, offsetof(struct ModFs, numFiles), true, LOT_NONE, 1, sizeof(u16) },
{ "save", LVT_FUNCTION, (size_t) "mod_fs_save", true, LOT_NONE, 1, sizeof(const char *) },
{ "set_public", LVT_FUNCTION, (size_t) "mod_fs_set_public", true, LOT_NONE, 1, sizeof(const char *) },
{ "totalSize", LVT_U32, offsetof(struct ModFs, totalSize), true, LOT_NONE, 1, sizeof(u32) },
};
static const char FUNCTION__mod_fs_file_erase[] = "mod_fs_file_erase";
static const char FUNCTION__mod_fs_file_fill[] = "mod_fs_file_fill";
static const char FUNCTION__mod_fs_file_is_eof[] = "mod_fs_file_is_eof";
static const char FUNCTION__mod_fs_file_read_bool[] = "mod_fs_file_read_bool";
static const char FUNCTION__mod_fs_file_read_bytes[] = "mod_fs_file_read_bytes";
static const char FUNCTION__mod_fs_file_read_integer[] = "mod_fs_file_read_integer";
static const char FUNCTION__mod_fs_file_read_line[] = "mod_fs_file_read_line";
static const char FUNCTION__mod_fs_file_read_number[] = "mod_fs_file_read_number";
static const char FUNCTION__mod_fs_file_read_string[] = "mod_fs_file_read_string";
static const char FUNCTION__mod_fs_file_rewind[] = "mod_fs_file_rewind";
static const char FUNCTION__mod_fs_file_seek[] = "mod_fs_file_seek";
static const char FUNCTION__mod_fs_file_set_public[] = "mod_fs_file_set_public";
static const char FUNCTION__mod_fs_file_set_text_mode[] = "mod_fs_file_set_text_mode";
static const char FUNCTION__mod_fs_file_write_bool[] = "mod_fs_file_write_bool";
static const char FUNCTION__mod_fs_file_write_bytes[] = "mod_fs_file_write_bytes";
static const char FUNCTION__mod_fs_file_write_integer[] = "mod_fs_file_write_integer";
static const char FUNCTION__mod_fs_file_write_line[] = "mod_fs_file_write_line";
static const char FUNCTION__mod_fs_file_write_number[] = "mod_fs_file_write_number";
static const char FUNCTION__mod_fs_file_write_string[] = "mod_fs_file_write_string";
#define LUA_MOD_FS_FILE_FIELD_COUNT 25
static struct LuaObjectField sModFsFileFields[LUA_MOD_FS_FILE_FIELD_COUNT] = {
{ "erase", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_erase, true, LOT_NONE, 1, sizeof(const char *) },
{ "filepath", LVT_STRING, offsetof(struct ModFsFile, filepath), true, LOT_NONE, 1, sizeof(char) },
{ "fill", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_fill, true, LOT_NONE, 1, sizeof(const char *) },
{ "isPublic", LVT_BOOL, offsetof(struct ModFsFile, isPublic), true, LOT_NONE, 1, sizeof(bool) },
{ "isText", LVT_BOOL, offsetof(struct ModFsFile, isText), true, LOT_NONE, 1, sizeof(bool) },
{ "is_eof", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_is_eof, true, LOT_NONE, 1, sizeof(const char *) },
{ "modFs", LVT_COBJECT_P, offsetof(struct ModFsFile, modFs), true, LOT_MODFS, 1, sizeof(struct ModFs*) },
{ "offset", LVT_U32, offsetof(struct ModFsFile, offset), true, LOT_NONE, 1, sizeof(u32) },
{ "read_bool", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_bool, true, LOT_NONE, 1, sizeof(const char *) },
{ "read_bytes", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_bytes, true, LOT_NONE, 1, sizeof(const char *) },
{ "read_integer", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_integer, true, LOT_NONE, 1, sizeof(const char *) },
{ "read_line", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_line, true, LOT_NONE, 1, sizeof(const char *) },
{ "read_number", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_number, true, LOT_NONE, 1, sizeof(const char *) },
{ "read_string", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_read_string, true, LOT_NONE, 1, sizeof(const char *) },
{ "rewind", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_rewind, true, LOT_NONE, 1, sizeof(const char *) },
{ "seek", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_seek, true, LOT_NONE, 1, sizeof(const char *) },
{ "set_public", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_set_public, true, LOT_NONE, 1, sizeof(const char *) },
{ "set_text_mode", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_set_text_mode, true, LOT_NONE, 1, sizeof(const char *) },
{ "size", LVT_U32, offsetof(struct ModFsFile, size), true, LOT_NONE, 1, sizeof(u32) },
{ "write_bool", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_bool, true, LOT_NONE, 1, sizeof(const char *) },
{ "write_bytes", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_bytes, true, LOT_NONE, 1, sizeof(const char *) },
{ "write_integer", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_integer, true, LOT_NONE, 1, sizeof(const char *) },
{ "write_line", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_line, true, LOT_NONE, 1, sizeof(const char *) },
{ "write_number", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_number, true, LOT_NONE, 1, sizeof(const char *) },
{ "write_string", LVT_FUNCTION, (size_t) FUNCTION__mod_fs_file_write_string, true, LOT_NONE, 1, sizeof(const char *) },
{ "erase", LVT_FUNCTION, (size_t) "mod_fs_file_erase", true, LOT_NONE, 1, sizeof(const char *) },
{ "filepath", LVT_STRING, offsetof(struct ModFsFile, filepath), true, LOT_NONE, 1, sizeof(char) },
{ "fill", LVT_FUNCTION, (size_t) "mod_fs_file_fill", true, LOT_NONE, 1, sizeof(const char *) },
{ "isPublic", LVT_BOOL, offsetof(struct ModFsFile, isPublic), true, LOT_NONE, 1, sizeof(bool) },
{ "isText", LVT_BOOL, offsetof(struct ModFsFile, isText), true, LOT_NONE, 1, sizeof(bool) },
{ "is_eof", LVT_FUNCTION, (size_t) "mod_fs_file_is_eof", true, LOT_NONE, 1, sizeof(const char *) },
{ "modFs", LVT_COBJECT_P, offsetof(struct ModFsFile, modFs), true, LOT_MODFS, 1, sizeof(struct ModFs*) },
{ "offset", LVT_U32, offsetof(struct ModFsFile, offset), true, LOT_NONE, 1, sizeof(u32) },
{ "read_bool", LVT_FUNCTION, (size_t) "mod_fs_file_read_bool", true, LOT_NONE, 1, sizeof(const char *) },
{ "read_bytes", LVT_FUNCTION, (size_t) "mod_fs_file_read_bytes", true, LOT_NONE, 1, sizeof(const char *) },
{ "read_integer", LVT_FUNCTION, (size_t) "mod_fs_file_read_integer", true, LOT_NONE, 1, sizeof(const char *) },
{ "read_line", LVT_FUNCTION, (size_t) "mod_fs_file_read_line", true, LOT_NONE, 1, sizeof(const char *) },
{ "read_number", LVT_FUNCTION, (size_t) "mod_fs_file_read_number", true, LOT_NONE, 1, sizeof(const char *) },
{ "read_string", LVT_FUNCTION, (size_t) "mod_fs_file_read_string", true, LOT_NONE, 1, sizeof(const char *) },
{ "rewind", LVT_FUNCTION, (size_t) "mod_fs_file_rewind", true, LOT_NONE, 1, sizeof(const char *) },
{ "seek", LVT_FUNCTION, (size_t) "mod_fs_file_seek", true, LOT_NONE, 1, sizeof(const char *) },
{ "set_public", LVT_FUNCTION, (size_t) "mod_fs_file_set_public", true, LOT_NONE, 1, sizeof(const char *) },
{ "set_text_mode", LVT_FUNCTION, (size_t) "mod_fs_file_set_text_mode", true, LOT_NONE, 1, sizeof(const char *) },
{ "size", LVT_U32, offsetof(struct ModFsFile, size), true, LOT_NONE, 1, sizeof(u32) },
{ "write_bool", LVT_FUNCTION, (size_t) "mod_fs_file_write_bool", true, LOT_NONE, 1, sizeof(const char *) },
{ "write_bytes", LVT_FUNCTION, (size_t) "mod_fs_file_write_bytes", true, LOT_NONE, 1, sizeof(const char *) },
{ "write_integer", LVT_FUNCTION, (size_t) "mod_fs_file_write_integer", true, LOT_NONE, 1, sizeof(const char *) },
{ "write_line", LVT_FUNCTION, (size_t) "mod_fs_file_write_line", true, LOT_NONE, 1, sizeof(const char *) },
{ "write_number", LVT_FUNCTION, (size_t) "mod_fs_file_write_number", true, LOT_NONE, 1, sizeof(const char *) },
{ "write_string", LVT_FUNCTION, (size_t) "mod_fs_file_write_string", true, LOT_NONE, 1, sizeof(const char *) },
};
#define LUA_NAMETAGS_SETTINGS_FIELD_COUNT 2

File diff suppressed because it is too large Load diff

View file

@ -221,7 +221,7 @@ void* smlua_to_cpointer(lua_State* L, int index, u16 lvt) {
CPointer *cpointer = luaL_checkudata(L, index, "CPointer");
if (lvt != cpointer->lvt) {
LOG_LUA_LINE("smlua_to_cpointer received improper LOT. Expected '%s', received '%s'", smlua_get_lvt_name(lvt), smlua_get_lvt_name(cpointer->lvt));
LOG_LUA_LINE("smlua_to_cpointer received improper LVT. Expected '%s', received '%s'", smlua_get_lvt_name(lvt), smlua_get_lvt_name(cpointer->lvt));
gSmLuaConvertSuccess = false;
return NULL;
}

View file

@ -20,6 +20,8 @@ s16* smlua_get_vec4s_from_buffer(void);
u8* smlua_get_color_from_buffer(void);
void smlua_bind_function(lua_State* L, const char* name, void* func);
#define BIND_FUNCTION(name) smlua_bind_function(L, #name, smlua_func_ ## name)
bool smlua_is_table_empty(int index);
bool smlua_to_boolean(lua_State* L, int index);