Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Get rid of jackson (mostly)
Browse files Browse the repository at this point in the history
Reviewed By: astreet

Differential Revision: D3041362

fb-gh-sync-id: a7027a08a63730b98dc766b86921820fa3624953
shipit-source-id: a7027a08a63730b98dc766b86921820fa3624953
  • Loading branch information
lexs authored and Facebook Github Bot 8 committed Mar 17, 2016
1 parent 1455506 commit d329570
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

package com.facebook.react.bridge;

import com.fasterxml.jackson.core.JsonGenerator;

import com.facebook.infer.annotation.Assertions;
import com.facebook.systrace.Systrace;

Expand Down Expand Up @@ -325,20 +323,18 @@ public final Map<String, NativeMethod> getMethods() {
}

@Override
public final void writeConstantsField(JsonGenerator jg, String fieldName) throws IOException {
public final void writeConstantsField(JsonWriter writer, String fieldName) throws IOException {
Map<String, Object> constants = getConstants();
if (constants == null || constants.isEmpty()) {
return;
}

jg.writeObjectFieldStart(fieldName);
writer.name(fieldName).beginObject();
for (Map.Entry<String, Object> constant : constants.entrySet()) {
JsonGeneratorHelper.writeObjectField(
jg,
constant.getKey(),
constant.getValue());
writer.name(constant.getKey());
JsonWriterHelper.value(writer, constant.getValue());
}
jg.writeEndObject();
writer.endObject();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import com.facebook.systrace.Systrace;
import com.facebook.systrace.TraceListener;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;

/**
* This provides an implementation of the public CatalystInstance instance. It is public because
* it is built by ReactInstanceManager which is in a different package.
Expand Down Expand Up @@ -358,21 +355,24 @@ public void setGlobalVariable(String propName, String jsonValue) {
private String buildModulesConfigJSONProperty(
NativeModuleRegistry nativeModuleRegistry,
JavaScriptModulesConfig jsModulesConfig) {
JsonFactory jsonFactory = new JsonFactory();
StringWriter writer = new StringWriter();
StringWriter stringWriter = new StringWriter();
JsonWriter writer = new JsonWriter(stringWriter);
try {
JsonGenerator jg = jsonFactory.createGenerator(writer);
jg.writeStartObject();
jg.writeFieldName("remoteModuleConfig");
nativeModuleRegistry.writeModuleDescriptions(jg);
jg.writeFieldName("localModulesConfig");
jsModulesConfig.writeModuleDescriptions(jg);
jg.writeEndObject();
jg.close();
writer.beginObject();
writer.name("remoteModuleConfig");
nativeModuleRegistry.writeModuleDescriptions(writer);
writer.name("localModulesConfig");
jsModulesConfig.writeModuleDescriptions(writer);
writer.endObject();
return stringWriter.toString();
} catch (IOException ioe) {
throw new RuntimeException("Unable to serialize JavaScript module declaration", ioe);
} finally {
try {
writer.close();
} catch (IOException ignored) {
}
}
return writer.getBuffer().toString();
}

private void incrementPendingJSCalls() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.core.JsonGenerator;

/**
* Class stores configuration of javascript modules that can be used across the bridge
*/
Expand All @@ -31,29 +29,29 @@ public List<JavaScriptModuleRegistration> getModuleDefinitions() {
return mModules;
}

public void writeModuleDescriptions(JsonGenerator jg) throws IOException {
jg.writeStartObject();
public void writeModuleDescriptions(JsonWriter writer) throws IOException {
writer.beginObject();
for (JavaScriptModuleRegistration registration : mModules) {
jg.writeObjectFieldStart(registration.getName());
appendJSModuleToJSONObject(jg, registration);
jg.writeEndObject();
writer.name(registration.getName()).beginObject();
appendJSModuleToJSONObject(writer, registration);
writer.endObject();
}
jg.writeEndObject();
writer.endObject();
}

private void appendJSModuleToJSONObject(
JsonGenerator jg,
JsonWriter writer,
JavaScriptModuleRegistration registration) throws IOException {
jg.writeObjectField("moduleID", registration.getModuleId());
jg.writeObjectFieldStart("methods");
writer.name("moduleID").value(registration.getModuleId());
writer.name("methods").beginObject();
for (Method method : registration.getMethods()) {
jg.writeObjectFieldStart(method.getName());
jg.writeObjectField("methodID", registration.getMethodId(method));
jg.writeEndObject();
writer.name(method.getName()).beginObject();
writer.name("methodID").value(registration.getMethodId(method));
writer.endObject();
}
jg.writeEndObject();
writer.endObject();
if (registration.getModuleInterface().isAnnotationPresent(SupportsWebWorkers.class)) {
jg.writeBooleanField("supportsWebWorkers", true);
writer.name("supportsWebWorkers").value(true);
}
}

Expand Down

This file was deleted.

Loading

0 comments on commit d329570

Please sign in to comment.