Skip to content

Commit

Permalink
Merge pull request #26 from powerlang/adding-id-to-objectWrapper
Browse files Browse the repository at this point in the history
Adding id to object wrapper
  • Loading branch information
melkyades authored Jan 11, 2024
2 parents df4cc63 + fb9c5ac commit f85d3b8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
12 changes: 10 additions & 2 deletions runtime/js/webside/PowerlangObjectWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let PowerlangObjectWrapper = class {
constructor() {
this._wrappee = nil;
this._runtime = nil;
this.id = nil;
return new Proxy(this, {
get(target, p) {
if (p in target) {
Expand All @@ -43,6 +44,12 @@ let PowerlangObjectWrapper = class {

initialize() {}

static on_runtime_id_(anLMRObject, aPowerlangLMR, anIID) {
let res = this.on_runtime_(anLMRObject, aPowerlangLMR);
res.id = anIID;
return res;
}

static on_runtime_(anLMRObject, aPowerlangLMR) {
let res = this.new();
res.wrappee_(anLMRObject);
Expand Down Expand Up @@ -76,7 +83,7 @@ let PowerlangObjectWrapper = class {

asWebsideJson() {
let species = this.objectClass();
let variable = species.isVariable().asLocalObject();
let variable = species.isVariable();
let name = species.name();
let printed;
//This check should be removed once we solve Recurson exception in Collection printing...
Expand All @@ -88,7 +95,8 @@ let PowerlangObjectWrapper = class {
: this._runtime
.sendLocal_to_("printString", this._wrappee)
.asLocalString();
return {
return {
id: this.id,
class: name,
indexable: variable,
size: variable ? this.size().wrappee().value() : 0,
Expand Down
4 changes: 4 additions & 0 deletions runtime/js/webside/PowerlangSpeciesWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ let PowerlangSpeciesWrapper = class extends PowerlangObjectWrapper {
return this.send("includesSelector:", [symbol]).asLocalObject();
}

isVariable() {
return this.send("isVariable").asLocalObject();
}

methodFor_(aSymbol) {
let symbol;
symbol = cachedSymbols[aSymbol];
Expand Down
6 changes: 5 additions & 1 deletion runtime/js/webside/WebsideAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class WebsideAPI extends Object {
object = this.runtime.sendLocal_to_("doIt", this.runtime.nil());
console.log(object.toString())
//this.runtime.sendLocal_to_with_("removeSelector:", species, [selector]);
object = this.wrap(object);
object = this.wrapWithId(object, id);
if (!sync || pin) {
this.server.pinnedObjects[id] = object;
}
Expand Down Expand Up @@ -425,6 +425,10 @@ class WebsideAPI extends Object {
}

//Private...
wrapWithId(object, id) {
return PowerlangObjectWrapper.on_runtime_id_(object, this.runtime, id);
}

wrap(object) {
return PowerlangObjectWrapper.on_runtime_(object, this.runtime);
}
Expand Down

0 comments on commit f85d3b8

Please sign in to comment.