File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ function demangle(exports, baseModule) {
265265 let classElem = curr [ className ] ;
266266 if ( typeof classElem === "undefined" || ! classElem . prototype ) {
267267 let ctor = function ( ...args ) {
268- return ctor . wrap ( ctor . prototype . constructor ( ...args ) ) ;
268+ return ctor . wrap ( ctor . prototype . constructor ( 0 , ...args ) ) ;
269269 } ;
270270 ctor . prototype = { } ;
271271 ctor . wrap = function ( thisValue ) {
@@ -289,7 +289,16 @@ function demangle(exports, baseModule) {
289289 } ) ;
290290 }
291291 } else {
292- curr [ name ] = wrapFunction ( elem , setargc ) ;
292+ if ( name === 'constructor' ) {
293+ curr [ name ] = wrapFunction ( elem , setargc ) ;
294+ } else { // for methods
295+ Object . defineProperty ( curr , name , {
296+ value : function ( ...args ) {
297+ setargc ( args . length ) ;
298+ return elem ( this . this , ...args ) ;
299+ }
300+ } ) ;
301+ }
293302 }
294303 } else {
295304 if ( / ^ ( g e t | s e t ) : / . test ( name ) ) {
Original file line number Diff line number Diff line change @@ -60,5 +60,14 @@ assert.strictEqual(fn(2), 4);
6060ptr = module . newFunction ( module . varadd ) ;
6161assert . strictEqual ( module . calladd ( ptr , 2 , 3 ) , 5 ) ;
6262
63+ // should be able to use a class
64+ var car = new module . Car ( 5 ) ;
65+ assert . strictEqual ( car . numDoors , 5 ) ;
66+ assert . strictEqual ( car . isDoorsOpen , 0 ) ;
67+ car . openDoors ( ) ;
68+ assert . strictEqual ( car . isDoorsOpen , 1 ) ;
69+ car . closeDoors ( ) ;
70+ assert . strictEqual ( car . isDoorsOpen , 0 ) ;
71+
6372// should be able to use trace
64- module . dotrace ( 42 ) ;
73+ module . dotrace ( 42 ) ;
You can’t perform that action at this time.
0 commit comments