Transform the Count enum values into private constants

Summary:
Hides implementation details for the C, Objective-C and Swift APIs.
Closes https://github.com/facebook/yoga/pull/292

Differential Revision: D4351523

Pulled By: emilsjolander

fbshipit-source-id: 18a1149d169f0d52bd078714295000b5d07434dd
This commit is contained in:
David Hart
2016-12-22 02:57:19 -08:00
committed by Facebook Github Bot
parent ed765fe508
commit ff1a0e1eb8
3 changed files with 16 additions and 23 deletions

View File

@@ -111,22 +111,22 @@ 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')
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('typedef enum YG%s {\n' % name)
for value in values:
if isinstance(value, tuple):
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')