Compare commits
2 Commits
150ad7b9ac
...
b15e039d61
Author | SHA1 | Date |
---|---|---|
Alpyne | b15e039d61 | |
Alpyne | d444a36785 |
|
@ -77,7 +77,7 @@ def extract_array_count(value, name=''):
|
|||
return count
|
||||
return None
|
||||
|
||||
def get_type_info(types, typename):
|
||||
def get_type_info(types, typename, serverbound=None):
|
||||
name = extract_array_type(typename)
|
||||
|
||||
if not name in types:
|
||||
|
@ -86,14 +86,25 @@ def get_type_info(types, typename):
|
|||
type: name
|
||||
}
|
||||
|
||||
tp = types[name]
|
||||
tp = types[name].copy()
|
||||
|
||||
# apply serverbound or clientbound specific info, if relevant (serverbound=None means don't care)
|
||||
|
||||
if serverbound and 'severbound' in tp:
|
||||
sbdata = tp['serverbound']
|
||||
for key in sbdata:
|
||||
tp[key] = sbdata[key]
|
||||
|
||||
elif serverbound == False and 'clientbound' in tp:
|
||||
cbdata = tp['clientbound']
|
||||
for key in cbdata:
|
||||
tp[key] = cbdata[key]
|
||||
|
||||
if 'alias' in tp:
|
||||
alias = tp['alias']
|
||||
enum = tp['enum'] if 'enum' in tp else False
|
||||
|
||||
tp = tp.copy()
|
||||
realtype = get_type_info(types, tp['alias'])
|
||||
realtype = get_type_info(types, tp['alias'], serverbound)
|
||||
# copy certain properties from real type
|
||||
if 'generic' in realtype: tp['generic'] = realtype['generic']
|
||||
if 'method' in realtype: tp['method'] = realtype['method']
|
||||
|
@ -132,14 +143,14 @@ def resolve_name(types, name, value, decl=False):
|
|||
|
||||
return name
|
||||
|
||||
def resolve_type(types, value):
|
||||
def resolve_type(types, value, serverbound=None):
|
||||
if isinstance(value, dict):
|
||||
warn('WARNING: Attempted to call resolve_type on object type')
|
||||
return ""
|
||||
|
||||
typename = value
|
||||
|
||||
tp = get_type_info(types, typename)
|
||||
tp = get_type_info(types, typename, serverbound)
|
||||
if 'type' in tp:
|
||||
return tp['type']
|
||||
else:
|
||||
|
@ -378,7 +389,7 @@ def print_definition(types, name, value, serverbound):
|
|||
unindent()
|
||||
add_text('}} {};', resolved_name)
|
||||
else:
|
||||
resolved_type = resolve_type(types, value)
|
||||
resolved_type = resolve_type(types, value, serverbound)
|
||||
add_text('{} {};', resolved_type, resolved_name)
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
}
|
||||
|
||||
string: {
|
||||
type: std::string_view
|
||||
type: std::string
|
||||
clientbound: {type: 'const std::string&'}
|
||||
|
||||
method: String
|
||||
// requires count: e.g. string[256]
|
||||
// generated C type will not be an array
|
||||
|
|
Loading…
Reference in New Issue