Skip to content

Commit

Permalink
Remove legacy bridge config conversion
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D3741859

fbshipit-source-id: b678b3a2bbed4f7ed386e10db19553c8beef7366
  • Loading branch information
lexs authored and Facebook Github Bot 3 committed Aug 22, 2016
1 parent 38a14ff commit 61b21bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 108 deletions.
48 changes: 1 addition & 47 deletions Libraries/Utilities/MessageQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class MessageQueue {

lazyProperty(this, 'RemoteModules', () => {
const {remoteModuleConfig} = configProvider();
const modulesConfig = this._genModulesConfig(remoteModuleConfig);
const modulesConfig = remoteModuleConfig;
const modules = this._genModules(modulesConfig);

if (__DEV__) {
Expand Down Expand Up @@ -276,52 +276,6 @@ class MessageQueue {
* Private helper methods
*/

/**
* Converts the old, object-based module structure to the new
* array-based structure. TODO (t8823865) Removed this
* function once Android has been updated.
*/
_genModulesConfig(modules /* array or object */) {
if (Array.isArray(modules)) {
return modules;
} else {
const moduleArray = [];
const moduleNames = Object.keys(modules);
for (var i = 0, l = moduleNames.length; i < l; i++) {
const moduleName = moduleNames[i];
const moduleConfig = modules[moduleName];
const module = [moduleName];
if (moduleConfig.constants) {
module.push(moduleConfig.constants);
}
const methodsConfig = moduleConfig.methods;
if (methodsConfig) {
const methods = [];
const asyncMethods = [];
const syncHooks = [];
const methodNames = Object.keys(methodsConfig);
for (var j = 0, ll = methodNames.length; j < ll; j++) {
const methodName = methodNames[j];
const methodConfig = methodsConfig[methodName];
methods[methodConfig.methodID] = methodName;
if (methodConfig.type === MethodTypes.remoteAsync) {
asyncMethods.push(methodConfig.methodID);
} else if (methodConfig.type === MethodTypes.syncHook) {
syncHooks.push(methodConfig.methodID);
}
}
if (methods.length) {
module.push(methods);
module.push(asyncMethods);
module.push(syncHooks);
}
}
moduleArray[moduleConfig.moduleID] = module;
}
return moduleArray;
}
}

_genLookupTables(modulesConfig, moduleTable, methodTable) {
modulesConfig.forEach((config, moduleID) => {
this._genLookup(config, moduleID, moduleTable, methodTable);
Expand Down
65 changes: 4 additions & 61 deletions Libraries/Utilities/__mocks__/MessageQueueTestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,69 +9,12 @@
* These don't actually exist anywhere in the code.
*/
'use strict';
var remoteModulesConfig = {
'RemoteModule1': {
'moduleID':0,
'methods':{
'remoteMethod1':{
'type':'remote',
'methodID':0
},
'remoteMethod2':{
'type':'remote',
'methodID':1
}
}
},
'RemoteModule2':{
'moduleID':1,
'methods':{
'remoteMethod1':{
'type':'remote',
'methodID':0
},
'remoteMethod2':{
'type':'remote',
'methodID':1
}
}
}
};

/**
* These actually exist in the __tests__ folder.
*/
var localModulesConfig = {
'MessageQueueTestModule1': {
'moduleID':'MessageQueueTestModule1',
'methods':{
'testHook1':{
'type':'local',
'methodID':'testHook1'
},
'testHook2':{
'type':'local',
'methodID':'testHook2'
}
}
},
'MessageQueueTestModule2': {
'moduleID':'MessageQueueTestModule2',
'methods': {
'runLocalCode':{
'type':'local',
'methodID':'runLocalCode'
},
'runLocalCode2':{
'type':'local',
'methodID':'runLocalCode2'
}
}
}
};
var remoteModulesConfig = [
['RemoteModule1',['remoteMethod1','remoteMethod2'],[],[]],
['RemoteModule2',['remoteMethod1','remoteMethod2'],[],[]],
];

var MessageQueueTestConfig = {
localModuleConfig: localModulesConfig,
remoteModuleConfig: remoteModulesConfig,
};

Expand Down

0 comments on commit 61b21bc

Please sign in to comment.