Skip to content

Commit

Permalink
Merge pull request #2010 from marchant/montage-data-converters#1
Browse files Browse the repository at this point in the history
Montage data converters#1
  • Loading branch information
marchant authored Aug 11, 2019
2 parents 9dcf38f + ccb6fcf commit 0246d8a
Show file tree
Hide file tree
Showing 28 changed files with 1,507 additions and 714 deletions.
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ log.txt

## jsdoc
/doc

### SublimeText ###
*.sublime-project
*.sublime-workspace

### Intellij IDE ###
.idea/
atlassian-ide-plugin.xml

### VisualStudioCode ###
.vscode/*
.vscode-upload.json

.eslintrc.json

### TextMate ###
*.tmproj
*.tmproject
tmtags

### Node ###
npm-debug.log*
.npmignore
Expand Down
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
language: node_js
node_js:
- 4
- 6
- 8
- 10
services:
- xvfb
script: npm run $COMMAND
env:
- COMMAND=test
- COMMAND=test:karma-travis
- COMMAND=integration MONTAGE_VERSION=. MOP_VERSION="#feature/npm3"
before_install:
- export CHROME_BIN=chromium-browser
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:0
jobs:
include:
- stage: lint
Expand Down
24 changes: 12 additions & 12 deletions core/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ Object.defineProperty(Montage.prototype, _serializableAttributeProperties, {
var ObjectAttributeProperties = new Map();
function getAttributeProperties(proto, attributeName, privateAttributeName) {
var attributePropertyName = privateAttributeName || (
attributeName === SERIALIZABLE ?
_serializableAttributeProperties :
attributeName === SERIALIZABLE ?
_serializableAttributeProperties :
(UNDERSCORE + attributeName + ATTRIBUTE_PROPERTIES));

if(proto !== Object.prototype) {
Expand Down Expand Up @@ -422,7 +422,7 @@ valuePropertyDescriptor.value = function Montage_defineProperty(obj, prop, descr
if (! (typeof obj === "object" || typeof obj === FUNCTION) || obj === null) {
throw new TypeError("Object must be an object, not '" + obj + "'");
}

var isValueDescriptor = (VALUE in descriptor);

// reset defaults appropriately for framework.
Expand Down Expand Up @@ -548,8 +548,8 @@ function __findSuperMethodImplementation( method, classFn, isFunctionSuper, meth
if(!methodPropertyName) {
//If methodPropertyNameArg is passed as an argument, we know what to look for,
//But it may not be there...
propertyNames = methodPropertyNameArg ?
(_propertyNames[0] = methodPropertyNameArg) && _propertyNames :
propertyNames = methodPropertyNameArg ?
(_propertyNames[0] = methodPropertyNameArg) && _propertyNames :
Object.getOwnPropertyNames(context);

//As we start, we don't really know which property name points to method, we're going to find out:
Expand Down Expand Up @@ -675,29 +675,29 @@ function __super(callerFn, methodPropertyName, isValue, isGetter, isSetter) {
*/
function _super() {
// Figure out which function called us.
var callerFn = ( _super && _super.caller ) ? _super.caller : arguments.callee.caller,
var callerFn = ( _super && _super.caller ) ? _super.caller : arguments.callee.caller,
superFn = __super.call(this,callerFn);
return superFn ? superFn.apply(this, arguments) : undefined;
}

function _superForValue(methodName) {
var callerFn = ( _superForValue && _superForValue.caller ) ? _superForValue.caller : arguments.callee.caller,
var callerFn = ( _superForValue && _superForValue.caller ) ? _superForValue.caller : arguments.callee.caller,
superFn = __super.call(this, callerFn, methodName, true, false, false);

//We may need to cache that at some point if it gets called too often
return superFn ? superFn.bind(this) : Function.noop;
}

function _superForGet(methodName) {
var callerFn = ( _superForGet && _superForGet.caller ) ? _superForGet.caller : arguments.callee.caller,
var callerFn = ( _superForGet && _superForGet.caller ) ? _superForGet.caller : arguments.callee.caller,
superFn = __super.call(this, callerFn, methodName, false, true, false);

//We may need to cache that at some point if it gets called too often
return superFn ? superFn.bind(this) : Function.noop;
}

function _superForSet(methodName) {
var callerFn = ( _superForSet && _superForSet.caller ) ? _superForSet.caller : arguments.callee.caller,
var callerFn = ( _superForSet && _superForSet.caller ) ? _superForSet.caller : arguments.callee.caller,
superFn = __super.call(this,callerFn,methodName,false,false,true);

//We may need to cache that at some point if it gets called too often
Expand Down Expand Up @@ -828,7 +828,7 @@ Montage.defineProperty(Montage, "getPropertyAttributes", {value: function (anObj
for (var name in attributes) {
if (hasProperty.call(attributes, name)) {
attributeValues[name] = attributes[name];
// should return the inherited defined attribute values
// should return the inherited defined attribute values
} else {
attributeValues[name] = attributes[name];
}
Expand Down Expand Up @@ -979,7 +979,7 @@ Montage.defineProperty(Montage.prototype, "callDelegateMethod", {

var delegateFunctionName = this.identifier + name.toCapitalized();
if (
typeof this.identifier === "string" &&
typeof this.identifier === "string" &&
typeof delegate[delegateFunctionName] === FUNCTION
) {
delegateFunction = delegate[delegateFunctionName];
Expand Down Expand Up @@ -1666,7 +1666,7 @@ exports._objectDescriptorDescriptor = {
get: function () {
var info = Montage.getInfoForObject(this),
self = info && !info.isInstance ? this : this.constructor;

if (!Object.getOwnPropertyDescriptor(self, "_objectDescriptor") ||
!self._objectDescriptor
) {
Expand Down
18 changes: 18 additions & 0 deletions core/meta/module-object-descriptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ var ModuleObjectDescriptor = exports.ModuleObjectDescriptor = ObjectDescriptor.s
this.super(serializer);
this._setPropertyWithDefaults(serializer, "module", this.module);
this._setPropertyWithDefaults(serializer, "exportName", this.exportName);
if(this.object) {
this._setPropertyWithDefaults(serializer, "object", this.object);
}
}
},

Expand All @@ -82,6 +85,12 @@ var ModuleObjectDescriptor = exports.ModuleObjectDescriptor = ObjectDescriptor.s
if (!this.exportName) {
throw new Error("Cannot deserialize object descriptor without an exportName");
}

value = deserializer.getProperty("object");
if (value !== void 0) {
this.object = value;
}

}
},

Expand All @@ -93,6 +102,15 @@ var ModuleObjectDescriptor = exports.ModuleObjectDescriptor = ObjectDescriptor.s
value: null
},

/**
* A reference to the actual object that this object descriptor is for.
* @type {Object}
*/
object: {
value: null
},


/**
* The name of the export this object descriptor is for.
* @type {string}
Expand Down
26 changes: 17 additions & 9 deletions core/serialization/deserializer/montage-deserializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,31 @@ var MontageDeserializer = exports.MontageDeserializer = Montage.specialize({
},

init: {
value: function (serialization, _require, objectRequires, locationId, isSync) {
value: function (serialization, _require, objectRequires, module, isSync) {
if (typeof serialization === "string") {
this._serializationString = serialization;
} else {
this._serializationString = JSON.stringify(serialization);
}
this._require = _require;
this._locationId = locationId ? locationId.indexOf(_require.location) === 0 ? locationId : _require.location + locationId : locationId;
this._module = module;
var locationId = module && _require.location + module.id;
this._locationId = locationId;

this._reviver = new MontageReviver().init(
_require, objectRequires, this.constructor, isSync
_require, objectRequires, this, isSync, locationId
);
this._isSync = isSync;

return this;
}
},

_isSync: {value: false},
isSync: {
get: function() {
return this._isSync;
}
},

/**
* @param {Object} instances Map-like object of external user objects to
Expand All @@ -55,7 +62,7 @@ var MontageDeserializer = exports.MontageDeserializer = Montage.specialize({
*/
deserialize: {
value: function (instances, element) {
var context = this._locationId && MontageDeserializer.moduleContexts.get(this._locationId),
var context = this._module && MontageDeserializer.moduleContexts.get(this._module),
circularError;
if (context) {
if (context._objects.root) {
Expand All @@ -79,7 +86,7 @@ var MontageDeserializer = exports.MontageDeserializer = Montage.specialize({
context = new MontageContext()
.init(serialization, this._reviver, instances, element, this._require, this._isSync);
if (this._locationId) {
MontageDeserializer.moduleContexts.set(this._locationId, context);
MontageDeserializer.moduleContexts.set(this._module, context);
}
try {
return context.getObjects();
Expand All @@ -102,9 +109,10 @@ var MontageDeserializer = exports.MontageDeserializer = Montage.specialize({

deserializeObject: {
value: function(objects) {
return this.deserialize(objects).then(function(objects) {
return objects.root;
});
return (this._isSync ? this.deserialize(objects).root
: this.deserialize(objects).then(function(objects) {
return objects.root;
}));
}
},

Expand Down
Loading

0 comments on commit 0246d8a

Please sign in to comment.