Skip to content

Commit

Permalink
headers: Add utility headers
Browse files Browse the repository at this point in the history
  • Loading branch information
bwrsandman committed Sep 24, 2024
1 parent 37dc0fc commit 87f5629
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/headers/bw1_decomp_gen/generate_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,19 @@ def get_path(name):
wrote_headers += 1
wrote_bytes += f.write(cw.code)

copied_headers = 0
copied_bytes = 0
for file in (Path(__file__).parent / "src").glob('*'):
dest_file = output_path / file.name
result = shutil.copy2(file, dest_file)
copied_headers += 1
copied_bytes += result.stat().st_size

toc = time.perf_counter()
print(f"Wrote {wrote_headers} headers({wrote_bytes} bytes) in {output_path}, took {toc - tic:0.4f} seconds")
print(f"Copied {copied_headers} headers({copied_bytes} bytes) in {output_path}")
print(f"Wrote {wrote_headers} headers({wrote_bytes} bytes) in {output_path}")
print(f"Ignored {len(to_ignore)} entries")
print(f"Took {toc - tic:0.4f} seconds")

if len(remainder_functions) + len(remainder_primitives) + len(remainder) > 0:
print(f"There are still {len(remainder_functions)} orphan functions")
Expand Down
9 changes: 9 additions & 0 deletions scripts/headers/bw1_decomp_gen/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
"D3DTLVERTEX": "d3dtypes.h"
}

UTILITY_HEADER_IMPORT_MAP = {
"bool32_t": "reversing_utils.h",
}


def strip_pointers_arrays_and_modifiers(c_type):
c_type = re.sub(r'\*', '', c_type)
Expand Down Expand Up @@ -85,6 +89,11 @@ def build_include_list(self, local_header_import_map: dict[str, Path]):
i = self.includes.get(header, self.Include(Path(header), set(), True))
i.dependencies.add(t)
self.includes[header] = i
elif t in UTILITY_HEADER_IMPORT_MAP:
header = UTILITY_HEADER_IMPORT_MAP[t]
i = self.includes.get(header, self.Include(Path(header), set(), False))
i.dependencies.add(t)
self.includes[header] = i
elif t in local_header_import_map:
header = local_header_import_map[t]
if header == self.path:
Expand Down
8 changes: 8 additions & 0 deletions scripts/headers/bw1_decomp_gen/src/reversing_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef BW1_DECOMP_REVERSING_UTILS_INCLUDED_H
#define BW1_DECOMP_REVERSING_UTILS_INCLUDED_H

#include <stdint.h> /* For uint32_t */

typedef uint32_t bool32_t;

#endif // BW1_DECOMP_REVERSING_UTILS_INCLUDED_H
37 changes: 37 additions & 0 deletions scripts/headers/bw1_decomp_gen/src/rtti.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef BW1_DECOMP_RTTI_INCLUDED_H
#define BW1_DECOMP_RTTI_INCLUDED_H

struct RTTIBaseClassDescriptor {
struct TypeDescriptor* pTypeDescriptor;
unsigned long numContainedBases;
unsigned where;
unsigned long attributes;
};

struct RTTIBaseClassArray {
struct RTTIBaseClassDescriptor* arrayOfBaseClassDescriptors[0];
};

struct RTTIClassHierarchyDescriptor {
unsigned long signature;
unsigned long attributes;
unsigned long numBaseClasses;
struct RTTIBaseClassArray* pBaseClassArray;
};

struct TypeDescriptor {
const void* pVFTable;
void* spare;
const char name[];
};

struct RTTICompleteObjectLocator {
unsigned long signature;
unsigned long offset;
unsigned long cdOffset;
struct TypeDescriptor* pTypeDescriptor;
struct RTTIClassHierarchyDescriptor* pClassDescriptor;
};


#endif // BW1_DECOMP_RTTI_INCLUDED_H

0 comments on commit 87f5629

Please sign in to comment.