Skip to content

Commit

Permalink
Fix passing objects without a toJS method by value on Emscripten target.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrv committed Dec 5, 2016
1 parent 7369db5 commit 3c81065
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/em/BindClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export namespace _nbind {
}

wireRead = (arg: number) => popValue(arg, this.ptrType);
wireWrite = pushValue;
wireWrite = (arg: any) => pushPointer(arg, this.ptrType, true);

// Optional type conversion code
// makeWireWrite = (expr: string) => '_nbind.pushValue(' + expr + ')';
Expand Down Expand Up @@ -237,8 +237,12 @@ export namespace _nbind {
return(ptr ? new type.proto(ptrMarker, type.flags, ptr) : null);
}

export function pushPointer(obj: Wrapper, type: BindClassPtr) {
if(!(obj instanceof Wrapper)) throw(new Error('Type mismatch'));
export function pushPointer(obj: Wrapper, type: BindClassPtr, tryValue?: boolean) {
if(!(obj instanceof Wrapper)) {
if(tryValue) {
return(pushValue(obj));
} else throw(new Error('Type mismatch'));
}

let ptr = obj.__nbindPtr;
let objType = (obj.__nbindType).classType;
Expand Down

0 comments on commit 3c81065

Please sign in to comment.