transform the Count enum values into private constants

This commit is contained in:
David Hart
2016-12-19 20:09:50 +01:00
parent 74fb205083
commit ad3a2c68b7
4 changed files with 43 additions and 21 deletions

View File

@@ -111,9 +111,9 @@ def to_java_upper(symbol):
return out
root = os.path.dirname(__file__)
root = os.path.dirname(os.path.abspath(__file__))
# write out C header
# write out C headers
with open(root + '/yoga/YGEnums.h', 'w') as f:
f.write(LICENSE)
f.write('#pragma once\n\n')
@@ -126,11 +126,20 @@ with open(root + '/yoga/YGEnums.h', 'w') as f:
f.write(' YG%s%s = %d,\n' % (name, value[0], value[1]))
else:
f.write(' YG%s%s,\n' % (name, value))
f.write(' YG%sCount,\n' % name)
f.write('} YG%s;\n' % name)
f.write('\n')
f.write('YG_EXTERN_C_END\n')
with open(root + '/yoga/YGEnums-Private.h', 'w') as f:
f.write(LICENSE)
f.write('#pragma once\n\n')
f.write('#include "YGMacros.h"\n\n')
f.write('YG_EXTERN_C_BEGIN\n\n')
for name, values in ENUMS.items():
f.write('#define YG%sCount %s\n' % (name, len(values)))
f.write('\n')
f.write('YG_EXTERN_C_END\n')
# write out java files
for name, values in ENUMS.items():
with open(root + '/java/com/facebook/yoga/Yoga%s.java' % name, 'w') as f: