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:
committed by
Facebook Github Bot
parent
ac4d0ab2a1
commit
d1c555fede
@@ -68,14 +68,21 @@ static CSSSize _jniMeasureFunc(CSSNodeRef node,
|
||||
return CSSSize{measuredWidth, measuredHeight};
|
||||
}
|
||||
|
||||
struct JCSSLogLevel : public JavaClass<JCSSLogLevel> {
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/csslayout/CSSLogLevel;";
|
||||
};
|
||||
|
||||
static global_ref<jobject> *jLogger;
|
||||
static int _jniLog(CSSLogLevel level, const char *format, va_list args) {
|
||||
char buffer[256];
|
||||
int result = vsnprintf(buffer, sizeof(buffer), format, args);
|
||||
|
||||
static auto logFunc =
|
||||
findClassLocal("com/facebook/csslayout/CSSLogger")->getMethod<void(jint, jstring)>("log");
|
||||
logFunc(jLogger->get(), static_cast<jint>(level), Environment::current()->NewStringUTF(buffer));
|
||||
findClassLocal("com/facebook/csslayout/CSSLogger")->getMethod<void(local_ref<JCSSLogLevel>, jstring)>("log");
|
||||
|
||||
static auto logLevelFromInt = JCSSLogLevel::javaClassStatic()->getStaticMethod<JCSSLogLevel::javaobject(jint)>("fromInt");
|
||||
|
||||
logFunc(jLogger->get(), logLevelFromInt(JCSSLogLevel::javaClassStatic(), static_cast<jint>(level)), Environment::current()->NewStringUTF(buffer));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user