devided ops/types

This commit is contained in:
DadaMonad
2015-02-19 10:41:34 +00:00
parent 1aacc0e967
commit 792440a71d
19 changed files with 29625 additions and 29722 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -2,11 +2,11 @@ var __slice = [].slice,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
module.exports = function(HB) {
var execution_listener, types;
types = {};
module.exports = function() {
var execution_listener, ops;
ops = {};
execution_listener = [];
types.Operation = (function() {
ops.Operation = (function() {
function Operation(uid) {
this.is_deleted = false;
this.garbage_collected = false;
@@ -37,7 +37,7 @@ module.exports = function(HB) {
};
Operation.prototype["delete"] = function() {
(new types.Delete(void 0, this)).execute();
(new ops.Delete(void 0, this)).execute();
return null;
};
@@ -69,13 +69,13 @@ module.exports = function(HB) {
this.is_deleted = true;
if (garbagecollect) {
this.garbage_collected = true;
return HB.addToGarbageCollector(this);
return this.HB.addToGarbageCollector(this);
}
}
};
Operation.prototype.cleanup = function() {
HB.removeOperation(this);
this.HB.removeOperation(this);
return this.deleteAllObservers();
};
@@ -117,10 +117,10 @@ module.exports = function(HB) {
var l, _i, _len;
this.is_executed = true;
if (this.uid == null) {
this.uid = HB.getNextOperationIdentifier();
this.uid = this.HB.getNextOperationIdentifier();
}
if (this.uid.noOperation == null) {
HB.addOperation(this);
this.HB.addOperation(this);
for (_i = 0, _len = execution_listener.length; _i < _len; _i++) {
l = execution_listener[_i];
l(this._encode());
@@ -149,7 +149,7 @@ module.exports = function(HB) {
_ref = this.unchecked;
for (name in _ref) {
op_uid = _ref[name];
op = HB.getOperation(op_uid);
op = this.HB.getOperation(op_uid);
if (op) {
this[name] = op;
} else {
@@ -167,7 +167,7 @@ module.exports = function(HB) {
return Operation;
})();
types.Delete = (function(_super) {
ops.Delete = (function(_super) {
__extends(Delete, _super);
function Delete(uid, deletes) {
@@ -200,13 +200,13 @@ module.exports = function(HB) {
return Delete;
})(types.Operation);
types.Delete.parse = function(o) {
})(ops.Operation);
ops.Delete.parse = function(o) {
var deletes_uid, uid;
uid = o['uid'], deletes_uid = o['deletes'];
return new this(uid, deletes_uid);
};
types.Insert = (function(_super) {
ops.Insert = (function(_super) {
__extends(Insert, _super);
function Insert(content, uid, prev_cl, next_cl, origin, parent) {
@@ -257,7 +257,7 @@ module.exports = function(HB) {
if ((_ref = this.prev_cl) != null ? _ref.isDeleted() : void 0) {
this.prev_cl.applyDelete();
}
if (this.content instanceof types.Operation) {
if (this.content instanceof ops.Operation) {
this.content.applyDelete();
}
return delete this.content;
@@ -303,7 +303,7 @@ module.exports = function(HB) {
if (!this.validateSavedOperations()) {
return false;
} else {
if (this.content instanceof types.Operation) {
if (this.content instanceof ops.Operation) {
this.content.insert_parent = this;
}
if (this.parent != null) {
@@ -389,7 +389,7 @@ module.exports = function(HB) {
position = 0;
prev = this.prev_cl;
while (true) {
if (prev instanceof types.Delimiter) {
if (prev instanceof ops.Delimiter) {
break;
}
if (!prev.isDeleted()) {
@@ -424,8 +424,8 @@ module.exports = function(HB) {
return Insert;
})(types.Operation);
types.Insert.parse = function(json) {
})(ops.Operation);
ops.Insert.parse = function(json) {
var content, next, origin, parent, prev, uid;
content = json['content'], uid = json['uid'], prev = json['prev'], next = json['next'], origin = json['origin'], parent = json['parent'];
if (typeof content === "string") {
@@ -433,7 +433,7 @@ module.exports = function(HB) {
}
return new this(content, uid, prev, next, origin, parent);
};
types.ImmutableObject = (function(_super) {
ops.ImmutableObject = (function(_super) {
__extends(ImmutableObject, _super);
function ImmutableObject(uid, _at_content) {
@@ -459,13 +459,13 @@ module.exports = function(HB) {
return ImmutableObject;
})(types.Operation);
types.ImmutableObject.parse = function(json) {
})(ops.Operation);
ops.ImmutableObject.parse = function(json) {
var content, uid;
uid = json['uid'], content = json['content'];
return new this(uid, content);
};
types.Delimiter = (function(_super) {
ops.Delimiter = (function(_super) {
__extends(Delimiter, _super);
function Delimiter(prev_cl, next_cl, origin) {
@@ -529,14 +529,14 @@ module.exports = function(HB) {
return Delimiter;
})(types.Operation);
types.Delimiter.parse = function(json) {
})(ops.Operation);
ops.Delimiter.parse = function(json) {
var next, prev, uid;
uid = json['uid'], prev = json['prev'], next = json['next'];
return new this(uid, prev, next);
};
return {
'types': types,
'operations': ops,
'execution_listener': execution_listener
};
};

View File

@@ -1,14 +1,14 @@
var text_types_uninitialized,
var text_ops_uninitialized,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
text_types_uninitialized = require("./TextTypes");
text_ops_uninitialized = require("./Text");
module.exports = function(HB) {
var text_types, types;
text_types = text_types_uninitialized(HB);
types = text_types.types;
types.Object = (function(_super) {
module.exports = function() {
var ops, text_ops;
text_ops = text_ops_uninitialized();
ops = text_ops.operations;
ops.Object = (function(_super) {
__extends(Object, _super);
function Object() {
@@ -35,11 +35,11 @@ module.exports = function(HB) {
json = {};
for (name in val) {
o = val[name];
if (o instanceof types.Object) {
if (o instanceof ops.Object) {
json[name] = o.toJson(transform_to_value);
} else if (o instanceof types.ListManager) {
} else if (o instanceof ops.ListManager) {
json[name] = o.toJson(transform_to_value);
} else if (transform_to_value && o instanceof types.Operation) {
} else if (transform_to_value && o instanceof ops.Operation) {
json[name] = o.val();
} else {
json[name] = o;
@@ -66,7 +66,7 @@ module.exports = function(HB) {
_results = [];
for (_i = 0, _len = events.length; _i < _len; _i++) {
event = events[_i];
if (event.created_ !== HB.getUserId()) {
if (event.created_ !== this.HB.getUserId()) {
notifier = Object.getNotifier(that.bound_json);
oldVal = that.bound_json[event.name];
if (oldVal != null) {
@@ -107,7 +107,7 @@ module.exports = function(HB) {
var args, i, o, type, _i, _ref;
if ((name != null) && arguments.length > 1) {
if ((content != null) && (content.constructor != null)) {
type = types[content.constructor.name];
type = ops[content.constructor.name];
if ((type != null) && (type.create != null)) {
args = [];
for (i = _i = 1, _ref = arguments.length; 1 <= _ref ? _i < _ref : _i > _ref; i = 1 <= _ref ? ++_i : --_i) {
@@ -135,24 +135,24 @@ module.exports = function(HB) {
return Object;
})(types.MapManager);
types.Object.parse = function(json) {
})(ops.MapManager);
ops.Object.parse = function(json) {
var uid;
uid = json['uid'];
return new this(uid);
};
types.Object.create = function(content, mutable) {
ops.Object.create = function(content, mutable) {
var json, n, o;
json = new types.Object().execute();
json = new ops.Object().execute();
for (n in content) {
o = content[n];
json.val(n, o, mutable);
}
return json;
};
types.Number = {};
types.Number.create = function(content) {
ops.Number = {};
ops.Number.create = function(content) {
return content;
};
return text_types;
return text_ops;
};

View File

@@ -1,14 +1,14 @@
var basic_types_uninitialized,
var basic_ops_uninitialized,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
basic_types_uninitialized = require("./BasicTypes");
basic_ops_uninitialized = require("./Basic");
module.exports = function(HB) {
var basic_types, types;
basic_types = basic_types_uninitialized(HB);
types = basic_types.types;
types.MapManager = (function(_super) {
module.exports = function() {
var basic_ops, ops;
basic_ops = basic_ops_uninitialized();
ops = basic_ops.operations;
ops.MapManager = (function(_super) {
__extends(MapManager, _super);
function MapManager(uid) {
@@ -77,7 +77,7 @@ module.exports = function(HB) {
sub: property_name,
alt: this
};
rm = new types.ReplaceManager(event_properties, event_this, rm_uid);
rm = new ops.ReplaceManager(event_properties, event_this, rm_uid);
this.map[property_name] = rm;
rm.setParent(this, property_name);
rm.execute();
@@ -87,13 +87,13 @@ module.exports = function(HB) {
return MapManager;
})(types.Operation);
types.ListManager = (function(_super) {
})(ops.Operation);
ops.ListManager = (function(_super) {
__extends(ListManager, _super);
function ListManager(uid) {
this.beginning = new types.Delimiter(void 0, void 0);
this.end = new types.Delimiter(this.beginning, void 0);
this.beginning = new ops.Delimiter(void 0, void 0);
this.end = new ops.Delimiter(this.beginning, void 0);
this.beginning.next_cl = this.end;
this.beginning.execute();
this.end.execute();
@@ -125,11 +125,11 @@ module.exports = function(HB) {
_results = [];
for (o = _i = 0, _len = val.length; _i < _len; o = ++_i) {
i = val[o];
if (o instanceof types.Object) {
if (o instanceof ops.Object) {
_results.push(o.toJson(transform_to_value));
} else if (o instanceof types.ListManager) {
} else if (o instanceof ops.ListManager) {
_results.push(o.toJson(transform_to_value));
} else if (transform_to_value && o instanceof types.Operation) {
} else if (transform_to_value && o instanceof ops.Operation) {
_results.push(o.val());
} else {
_results.push(o);
@@ -198,7 +198,7 @@ module.exports = function(HB) {
var o;
if (pos != null) {
o = this.getOperationByPosition(pos + 1);
if (!(o instanceof types.Delimiter)) {
if (!(o instanceof ops.Delimiter)) {
return o.val();
} else {
throw new Error("this position does not exist");
@@ -212,7 +212,7 @@ module.exports = function(HB) {
var o;
o = this.beginning;
while (true) {
if (o instanceof types.Delimiter && (o.prev_cl != null)) {
if (o instanceof ops.Delimiter && (o.prev_cl != null)) {
o = o.prev_cl;
while (o.isDeleted() && (o.prev_cl != null)) {
o = o.prev_cl;
@@ -239,7 +239,7 @@ module.exports = function(HB) {
createContent = function(content, options) {
var type;
if ((content != null) && (content.constructor != null)) {
type = types[content.constructor.name];
type = ops[content.constructor.name];
if ((type != null) && (type.create != null)) {
return type.create(content, options);
} else {
@@ -254,12 +254,12 @@ module.exports = function(HB) {
right = right.next_cl;
}
left = right.prev_cl;
if (content instanceof types.Operation) {
(new types.Insert(content, void 0, left, right)).execute();
if (content instanceof ops.Operation) {
(new ops.Insert(content, void 0, left, right)).execute();
} else {
for (_i = 0, _len = content.length; _i < _len; _i++) {
c = content[_i];
tmp = (new types.Insert(createContent(c, options), void 0, left, right)).execute();
tmp = (new ops.Insert(createContent(c, options), void 0, left, right)).execute();
left = tmp;
}
}
@@ -277,12 +277,12 @@ module.exports = function(HB) {
o = this.getOperationByPosition(position + 1);
delete_ops = [];
for (i = _i = 0; 0 <= length ? _i < length : _i > length; i = 0 <= length ? ++_i : --_i) {
if (o instanceof types.Delimiter) {
if (o instanceof ops.Delimiter) {
break;
}
d = (new types.Delete(void 0, o)).execute();
d = (new ops.Delete(void 0, o)).execute();
o = o.next_cl;
while ((!(o instanceof types.Delimiter)) && o.isDeleted()) {
while ((!(o instanceof ops.Delimiter)) && o.isDeleted()) {
o = o.next_cl;
}
delete_ops.push(d._encode());
@@ -301,17 +301,17 @@ module.exports = function(HB) {
return ListManager;
})(types.Operation);
types.ListManager.parse = function(json) {
})(ops.Operation);
ops.ListManager.parse = function(json) {
var uid;
uid = json['uid'];
return new this(uid);
};
types.Array = function() {};
types.Array.create = function(content, mutable) {
ops.Array = function() {};
ops.Array.create = function(content, mutable) {
var ith, list;
if (mutable === "mutable") {
list = new types.ListManager().execute();
list = new ops.ListManager().execute();
ith = list.getOperationByPosition(0);
list.insertAfter(ith, content);
return list;
@@ -321,7 +321,7 @@ module.exports = function(HB) {
throw new Error("Specify either \"mutable\" or \"immutable\"!!");
}
};
types.ReplaceManager = (function(_super) {
ops.ReplaceManager = (function(_super) {
__extends(ReplaceManager, _super);
function ReplaceManager(_at_event_properties, _at_event_this, uid, beginning, end) {
@@ -368,7 +368,7 @@ module.exports = function(HB) {
ReplaceManager.prototype.replace = function(content, replaceable_uid) {
var o, relp;
o = this.getLastOperation();
relp = (new types.Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
relp = (new ops.Replaceable(content, this, replaceable_uid, o, o.next_cl)).execute();
return void 0;
};
@@ -377,7 +377,7 @@ module.exports = function(HB) {
};
ReplaceManager.prototype.deleteContent = function() {
(new types.Delete(void 0, this.getLastOperation().uid)).execute();
(new ops.Delete(void 0, this.getLastOperation().uid)).execute();
return void 0;
};
@@ -400,8 +400,8 @@ module.exports = function(HB) {
return ReplaceManager;
})(types.ListManager);
types.Replaceable = (function(_super) {
})(ops.ListManager);
ops.Replaceable = (function(_super) {
__extends(Replaceable, _super);
function Replaceable(content, parent, uid, prev, next, origin, is_deleted) {
@@ -494,7 +494,7 @@ module.exports = function(HB) {
} else if (this.origin !== this.prev_cl) {
json.origin = this.origin.getUid();
}
if (this.content instanceof types.Operation) {
if (this.content instanceof ops.Operation) {
json['content'] = this.content.getUid();
} else {
if ((this.content != null) && (this.content.creator != null)) {
@@ -507,11 +507,11 @@ module.exports = function(HB) {
return Replaceable;
})(types.Insert);
types.Replaceable.parse = function(json) {
})(ops.Insert);
ops.Replaceable.parse = function(json) {
var content, is_deleted, next, origin, parent, prev, uid;
content = json['content'], parent = json['parent'], uid = json['uid'], prev = json['prev'], next = json['next'], origin = json['origin'], is_deleted = json['is_deleted'];
return new this(content, parent, uid, prev, next, origin, is_deleted);
};
return basic_types;
return basic_ops;
};

View File

@@ -1,15 +1,14 @@
var structured_types_uninitialized,
var structured_ops_uninitialized,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
structured_types_uninitialized = require("./StructuredTypes");
structured_ops_uninitialized = require("./Structured");
module.exports = function(HB) {
var parser, structured_types, types;
structured_types = structured_types_uninitialized(HB);
types = structured_types.types;
parser = structured_types.parser;
types.String = (function(_super) {
module.exports = function() {
var ops, structured_ops;
structured_ops = structured_ops_uninitialized();
ops = structured_ops.operations;
ops.String = (function(_super) {
__extends(String, _super);
function String(uid) {
@@ -300,16 +299,16 @@ module.exports = function(HB) {
return String;
})(types.ListManager);
types.String.parse = function(json) {
})(ops.ListManager);
ops.String.parse = function(json) {
var uid;
uid = json['uid'];
return new this(uid);
};
types.String.create = function(content, mutable) {
ops.String.create = function(content, mutable) {
var word;
if (mutable === "mutable") {
word = new types.String().execute();
word = new ops.String().execute();
word.insert(0, content);
return word;
} else if ((mutable == null) || (mutable === "immutable")) {
@@ -318,5 +317,5 @@ module.exports = function(HB) {
throw new Error("Specify either \"mutable\" or \"immutable\"!!");
}
};
return structured_types;
return structured_ops;
};

View File

@@ -1,8 +1,6 @@
var Engine, HistoryBuffer, adaptConnector, createY, json_types_uninitialized,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
__hasProp = {}.hasOwnProperty;
var Engine, HistoryBuffer, adaptConnector, createY, json_ops_uninitialized;
json_types_uninitialized = require("./Types/JsonTypes");
json_ops_uninitialized = require("./Operations/Json");
HistoryBuffer = require("./HistoryBuffer");
@@ -11,7 +9,7 @@ Engine = require("./Engine");
adaptConnector = require("./ConnectorAdapter");
createY = function(connector) {
var HB, Y, type_manager, types, user_id;
var HB, engine, ops, ops_manager, user_id;
user_id = null;
if (connector.user_id != null) {
user_id = connector.user_id;
@@ -23,28 +21,16 @@ createY = function(connector) {
};
}
HB = new HistoryBuffer(user_id);
type_manager = json_types_uninitialized(HB);
types = type_manager.types;
Y = (function(_super) {
__extends(Y, _super);
function Y() {
this.connector = connector;
this.HB = HB;
this.types = types;
this.engine = new Engine(this.HB, type_manager.types);
adaptConnector(this.connector, this.engine, this.HB, type_manager.execution_listener);
Y.__super__.constructor.apply(this, arguments);
}
Y.prototype.getConnector = function() {
return this.connector;
};
return Y;
})(types.Object);
return new Y(HB.getReservedUniqueIdentifier()).execute();
ops_manager = json_ops_uninitialized(HB, this.constructor);
ops = ops_manager.operations;
engine = new Engine(HB, ops);
adaptConnector(connector, engine, HB, ops_manager.execution_listener);
ops.Operation.prototype.HB = HB;
ops.Operation.prototype.operations = ops;
ops.Operation.prototype.engine = engine;
ops.Operation.prototype.connector = connector;
ops.Operation.prototype.custom_ops = this.constructor;
return new ops.Object(HB.getReservedUniqueIdentifier()).execute();
};
module.exports = createY;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long