Browse Source

pas2js: extend external: class function NewInstance: check $class and set pascal class properties

git-svn-id: trunk@45697 -
Mattias Gaertner 5 years ago
parent
commit
bbd0dc3726
1 changed files with 12 additions and 5 deletions
  1. 12 5
      utils/pas2js/dist/rtl.js

+ 12 - 5
utils/pas2js/dist/rtl.js

@@ -353,21 +353,28 @@ var rtl = {
       var o = null;
       var o = null;
       if (newinstancefnname.length>0){
       if (newinstancefnname.length>0){
         o = this[newinstancefnname](fn,args);
         o = this[newinstancefnname](fn,args);
+        if (!o.$class){
+          o.$class = this;
+          o.$classname = this.$classname;
+          o.$name = this.$name;
+          o.$fullname = this.$fullname;
+          o.$ancestor = this.$ancestor;
+        }
       } else {
       } else {
         o = Object.create(this);
         o = Object.create(this);
       }
       }
-      if (o.$init) o.$init();
+      if (this.$init) this.$init.call(o);
       try{
       try{
         if (typeof(fn)==="string"){
         if (typeof(fn)==="string"){
-          o[fn].apply(o,args);
+          this[fn].apply(o,args);
         } else {
         } else {
           fn.apply(o,args);
           fn.apply(o,args);
         };
         };
-        if (o.AfterConstruction) o.AfterConstruction();
+        if (this.AfterConstruction) this.call.AfterConstruction(o);
       } catch($e){
       } catch($e){
         // do not call BeforeDestruction
         // do not call BeforeDestruction
-        if (o.Destroy) o.Destroy();
-        if (o.$final) this.$final();
+        if (this.Destroy) this.Destroy.call(o);
+        if (this.$final) this.$final.call(o);
         throw $e;
         throw $e;
       }
       }
       return o;
       return o;