mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-22 07:20:06 +00:00
misc. refactoring
This commit is contained in:
parent
3f4ce93f9f
commit
20af006566
@ -89,7 +89,7 @@ class StructTranspiler:
|
|||||||
# all strings in fusionfall are utf16, in a uint16 array
|
# all strings in fusionfall are utf16, in a uint16 array
|
||||||
self.size = int(marshal[(marshal.find("SizeConst = ") + len("SizeConst = ")):marshal.find(")]")])
|
self.size = int(marshal[(marshal.find("SizeConst = ") + len("SizeConst = ")):marshal.find(")]")])
|
||||||
self.type = "string"
|
self.type = "string"
|
||||||
self.tags += "size:\"%d\"" % self.size
|
self.addTag("size:\"%d\"" % self.size) # special tag to tell our decoder/encoder the size of the uint16[] array
|
||||||
self.ctype = "short"
|
self.ctype = "short"
|
||||||
self.cname += "[%d]" % self.size
|
self.cname += "[%d]" % self.size
|
||||||
self.size *= 2
|
self.size *= 2
|
||||||
@ -124,6 +124,12 @@ class StructTranspiler:
|
|||||||
self.ctype = sanitizeName(type)
|
self.ctype = sanitizeName(type)
|
||||||
self.needsPatching = True
|
self.needsPatching = True
|
||||||
|
|
||||||
|
def addTag(self, tag: str) -> None:
|
||||||
|
if len(self.tags) > 0: # if there's already a tag defined, make sure there's a space separating them
|
||||||
|
self.tags += " "
|
||||||
|
|
||||||
|
self.tags += tag
|
||||||
|
|
||||||
def __init__(self, lines: list[str]) -> None:
|
def __init__(self, lines: list[str]) -> None:
|
||||||
self.name = "UnknownStruct"
|
self.name = "UnknownStruct"
|
||||||
self.size = 0
|
self.size = 0
|
||||||
@ -219,9 +225,7 @@ class StructTranspiler:
|
|||||||
|
|
||||||
if field.padding > 0:
|
if field.padding > 0:
|
||||||
currentSize += field.padding
|
currentSize += field.padding
|
||||||
if len(field.tags) > 0: # if there's already a tag defined, make sure there's a space separating them
|
field.addTag("pad:\"%d\"" % field.padding)
|
||||||
field.tags += " "
|
|
||||||
field.tags += "pad:\"%d\"" % field.padding
|
|
||||||
|
|
||||||
source += "\n\t" + field.name + " " + field.type
|
source += "\n\t" + field.name + " " + field.type
|
||||||
if len(field.tags) > 0:
|
if len(field.tags) > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user