Lucian Brănescu-Mihăilă avatar Lucian Brănescu-Mihăilă committed 4318bd9

Probably fixed find_method and invoke. Fix a test in instance.t.

Comments (0)

Files changed (5)

objects/src/instance.winxed

     }
 
     function invoke[vtable](var p [slurpy], var n [slurpy,named]) {
-        var sub;
-
-        if(self.__class__ != null)
-            sub = self.__class__.__call__;
+        var sub = self.__call__;
 
         // if sub is a parrot Sub, it'll get executed
         // if sub is an instance with __call__, this invoke will get called,
 
     function find_method[vtable](string name) {
         // likely broken
-        var method = self.__dict__[name];
+        using Python.instance.get_pmc_keyed_str;
+        var method = self.*get_pmc_keyed_str(name);
 
         // closure to soak up the obj
         return function(var obj, var p[slurpy], var n[slurpy,named]) {
         if(exists dict['__class__']) {
             var cls = dict['__class__'];
 
-            for(var i in get_mro(cls)) {
+            for(var i in get_mro(cls))
                 if(exists i.__dict__['__getattribute__'])
                     return i.__dict__['__getattribute__'](self, name);
-            }
         }
 
         return dict[name];

objects/src/object.winxed

     t.__init__ = function(obj) {};
 
     t.__call__ = function() {
-        var f = t.__new__;
-        var n = f(t);
-        //f = n.__init__;
-        //f(n);
+        say('creating object instance');
+        var n = t.__new__(t);
         n.__init__(n);
+
         return n;
     };
 

objects/src/type.winxed

     };
 
     t.__call__ = function(obj) {
+        say('creating type instance');
         return obj.__class__;
     };
 

objects/t/instance.t

 
     function call() {
         var i = new Python.instance;
-        var c = new Python.instance;
 
-        i.__class__ = c;
-        c.__call__ = function(self){return 42;};
+        i.__call__ = function(obj){return 42;};
 
         self.assert.equal(i(), 42);
     }
         :(var t, var o) = boot();
 
         var i = o();
-        say(i.__class__.__name__);
         
-        //self.assert.same(i.__class__, o);
+        self.assert.same(i.__class__, o); // it's t instead of o for some reason
     }
         
     function instance_get() {
-        self.status.todo('__getattribute__ broken for now.');
-
         :(var t, var o) = boot();
 
         var func = o.__new__;
     function instance_set_attr() {
         :(var t, var o) = boot();
 
-        var func = o.__new__;    
-        var i = func(o);
+        var i = o.__new__(o);
         i.foo = 'bar';
+
         self.assert.equal(i.foo, 'bar');
     }
 
     function non_data_descriptor() {
         :(var t, var o) = boot();
-        var f = o.__new__;
-        var i = f(o);
-    
-        i.__get__ = function(attr, obj) {return 42;};
 
+        var i = o.__new__(o);
+        i.__get__ = function(obj, attr) {return 42;};
         t.i = i;
+
         self.assert.equal(t.i, 42);
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.