mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Generate module definition on demand
Reviewed By: astreet Differential Revision: D2707977 fb-gh-sync-id: fb2baa464a23df82e8b48a91a84c98370517d311
This commit is contained in:
1 parent
c25c98c00c
commit
30a5eb51f8
3 files changed
+44
-68
No files matched your search
@@ -10,12 +10,10 @@
|
||||
package com.facebook.react.bridge;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonFactory;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
||||
/**
|
||||
@@ -33,23 +31,14 @@ public class JavaScriptModulesConfig {
|
||||
return mModules;
|
||||
}
|
||||
|
||||
/*package*/ String moduleDescriptions() {
|
||||
JsonFactory jsonFactory = new JsonFactory();
|
||||
StringWriter writer = new StringWriter();
|
||||
try {
|
||||
JsonGenerator jg = jsonFactory.createGenerator(writer);
|
||||
jg.writeStartObject();
|
||||
for (JavaScriptModuleRegistration registration : mModules) {
|
||||
jg.writeObjectFieldStart(registration.getName());
|
||||
appendJSModuleToJSONObject(jg, registration);
|
||||
jg.writeEndObject();
|
||||
}
|
||||
/*package*/ void writeModuleDescriptions(JsonGenerator jg) throws IOException {
|
||||
jg.writeStartObject();
|
||||
for (JavaScriptModuleRegistration registration : mModules) {
|
||||
jg.writeObjectFieldStart(registration.getName());
|
||||
appendJSModuleToJSONObject(jg, registration);
|
||||
jg.writeEndObject();
|
||||
jg.close();
|
||||
} catch (IOException ioe) {
|
||||
throw new RuntimeException("Unable to serialize JavaScript module declaration", ioe);
|
||||
}
|
||||
return writer.getBuffer().toString();
|
||||
jg.writeEndObject();
|
||||
}
|
||||
|
||||
private void appendJSModuleToJSONObject(
|
||||
|
||||
Reference in new issue
Block a user