Autogenerate enum defenitions for all languages

Summary: Keeping enums in sync between all the different bindings is tedious and error prone. Getting one of the values in the incorrect order could lead to many hours of debugging as they are passed as ints to C. This diff adds a simple python script to generate these enums for all languages. This also makes it much easier to add support for more languages in the future

Reviewed By: gkassabli

Differential Revision: D4174263

fbshipit-source-id: 478961a8f683e196704d3c6ea1505a05c85fcb10
This commit is contained in:
Emil Sjolander
2016-11-15 08:42:33 -08:00
committed by Facebook Github Bot
parent ac4d0ab2a1
commit d1c555fede
34 changed files with 699 additions and 166 deletions

View File

@@ -0,0 +1,47 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
public enum CSSEdge {
LEFT(0),
TOP(1),
RIGHT(2),
BOTTOM(3),
START(4),
END(5),
HORIZONTAL(6),
VERTICAL(7),
ALL(8);
private int mIntValue;
CSSEdge(int intValue) {
mIntValue = intValue;
}
public int intValue() {
return mIntValue;
}
public static CSSEdge fromInt(int value) {
switch (value) {
case 0: return LEFT;
case 1: return TOP;
case 2: return RIGHT;
case 3: return BOTTOM;
case 4: return START;
case 5: return END;
case 6: return HORIZONTAL;
case 7: return VERTICAL;
case 8: return ALL;
default: throw new IllegalArgumentException("Unkown enum value: " + value);
}
}
}