Skip to content

Commit

Permalink
Publish version 0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ghillairet committed Nov 25, 2014
1 parent 9fae39c commit 40a3af0
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bower.json
@@ -1,7 +1,7 @@
{
"name": "ecore.js",
"main": "dist/ecore.js",
"version": "0.4.5",
"version": "0.4.6",
"homepage": "https://github.com/ghillairet/ecore.js",
"authors": [
"ghillairet <g.hillairet@gmail.com>"
Expand All @@ -20,6 +20,6 @@
"tests"
],
"dependencies": {
"underscore": "~1.5.2"
"underscore": "~1.7.0"
}
}
56 changes: 43 additions & 13 deletions dist/ecore.js
Expand Up @@ -6,6 +6,8 @@

(function() {

"use strict";

// The root object, `window` in the browser, or `global` on the server.
var root = this;

Expand Down Expand Up @@ -476,17 +478,36 @@ Ecore.EObjectPrototype = {
eContents: function() {
if (!this.eClass) return [];

var eAllFeatures = this.eClass.get('eAllStructuralFeatures'),
eContainments = _.filter(eAllFeatures, function(feature) {
if (_.isUndefined(this.__updateContents)) {
this.__updateContents = true;

var resource = this.eResource();
if (resource) {
var me = this;
resource.on('add remove', function() {
me.__updateContents = true;
})
}
}

if (this.__updateContents) {
var eAllFeatures = this.eClass.get('eAllStructuralFeatures');
var eContainments = _.filter(eAllFeatures, function(feature) {
return feature.isTypeOf('EReference') &&
feature.get('containment') &&
this.isSet(feature.get('name'));
}, this);

return _.flatten(_.map(eContainments, function(c) {
var value = this.get(c.get('name'));
return value instanceof Ecore.EList ? value.array() : value;
}, this));
var value = null;
this.__eContents = _.flatten(_.map(eContainments, function(c) {
value = this.get(c.get('name'));
return value ? (value.array ? value.array() : value) : [];
}, this));

this.__updateContents = false;
}

return this.__eContents;
},

// Returns the URI of the EObject.
Expand Down Expand Up @@ -1894,11 +1915,7 @@ var EClassResource = Ecore.Resource = Ecore.EClass.create({
_: function(fragment) {
if (!fragment) return null;

if (this.__index == null) {
this.__index = buildIndex(this);
}

return this.__index[fragment];
return this._index()[fragment];
}
},
{
Expand Down Expand Up @@ -1992,7 +2009,20 @@ var EClassResource = Ecore.Resource = Ecore.EClass.create({
name: '_index',
eType: JSObject,
_: function() {
return buildIndex(this);
if (_.isUndefined(this.__updateIndex)) {
var res = this;
res.__updateIndex = true;
res.on('add remove', function() {
res.__updateIndex = true;
})
}

if (this.__updateIndex) {
this.__index = buildIndex(this);
this.__updateIndex = false;
}

return this.__index;
}
}
]
Expand Down Expand Up @@ -2499,5 +2529,5 @@ Ecore.Edit = {
}


})();
}.call(this));

2 changes: 1 addition & 1 deletion dist/ecore.min.js

Large diffs are not rendered by default.

56 changes: 43 additions & 13 deletions dist/ecore.xmi.js
Expand Up @@ -6,6 +6,8 @@

(function() {

"use strict";

// The root object, `window` in the browser, or `global` on the server.
var root = this;

Expand Down Expand Up @@ -476,17 +478,36 @@ Ecore.EObjectPrototype = {
eContents: function() {
if (!this.eClass) return [];

var eAllFeatures = this.eClass.get('eAllStructuralFeatures'),
eContainments = _.filter(eAllFeatures, function(feature) {
if (_.isUndefined(this.__updateContents)) {
this.__updateContents = true;

var resource = this.eResource();
if (resource) {
var me = this;
resource.on('add remove', function() {
me.__updateContents = true;
})
}
}

if (this.__updateContents) {
var eAllFeatures = this.eClass.get('eAllStructuralFeatures');
var eContainments = _.filter(eAllFeatures, function(feature) {
return feature.isTypeOf('EReference') &&
feature.get('containment') &&
this.isSet(feature.get('name'));
}, this);

return _.flatten(_.map(eContainments, function(c) {
var value = this.get(c.get('name'));
return value instanceof Ecore.EList ? value.array() : value;
}, this));
var value = null;
this.__eContents = _.flatten(_.map(eContainments, function(c) {
value = this.get(c.get('name'));
return value ? (value.array ? value.array() : value) : [];
}, this));

this.__updateContents = false;
}

return this.__eContents;
},

// Returns the URI of the EObject.
Expand Down Expand Up @@ -1894,11 +1915,7 @@ var EClassResource = Ecore.Resource = Ecore.EClass.create({
_: function(fragment) {
if (!fragment) return null;

if (this.__index == null) {
this.__index = buildIndex(this);
}

return this.__index[fragment];
return this._index()[fragment];
}
},
{
Expand Down Expand Up @@ -1992,7 +2009,20 @@ var EClassResource = Ecore.Resource = Ecore.EClass.create({
name: '_index',
eType: JSObject,
_: function() {
return buildIndex(this);
if (_.isUndefined(this.__updateIndex)) {
var res = this;
res.__updateIndex = true;
res.on('add remove', function() {
res.__updateIndex = true;
})
}

if (this.__updateIndex) {
this.__index = buildIndex(this);
this.__updateIndex = false;
}

return this.__index;
}
}
]
Expand Down Expand Up @@ -2864,5 +2894,5 @@ function formatXml(xml) {
}


})();
}.call(this));

2 changes: 1 addition & 1 deletion dist/ecore.xmi.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "ecore",
"description": "Ecore (EMOF) JavaScript Implementation",
"version": "0.4.5",
"version": "0.4.6",
"author": "Guillaume Hillairet <g.hillairet@gmail.com>",
"repository": {
"type": "git",
Expand Down

0 comments on commit 40a3af0

Please sign in to comment.