Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

- `typeMap` attribute of Node made lazy

- rolled back previous hack in TypeMap
  • Loading branch information...
commit cb673839ba93d1a6acd54b86b72bb34b44fd6edd 1 parent a22732e
authored September 06, 2010
2  lib/KiokuJS/Collapser/Encoder.js
@@ -23,7 +23,7 @@ Class('KiokuJS.Collapser.Encoder', {
23 23
         encodeEntry : function (entry, node) {
24 24
             entry = this.visit(entry)
25 25
             
26  
-            if (node.isFirstClass() || !node.typeMap.passThrough) { 
  26
+            if (node.isFirstClass() || !node.getTypeMap().passThrough) { 
27 27
                 entry.$entry = true
28 28
                  
29 29
                 return entry
19  lib/KiokuJS/Node.js
@@ -19,7 +19,10 @@ Class('KiokuJS.Node', {
19 19
         // arbitrary data about object
20 20
         objectData  : null,
21 21
         
22  
-        typeMap     : null,
  22
+        typeMap     : {
  23
+            is      : 'ro',
  24
+            lazy    : function () { return this.getTypeMapFor(this.className) }
  25
+        },
23 26
         
24 27
         resolver    : {
25 28
             is          : 'rw',
@@ -47,7 +50,7 @@ Class('KiokuJS.Node', {
47 50
             
48 51
             if (!className) this.className = this.getClassNameFor(object)
49 52
             
50  
-            this.typeMap = this.getTypeMapFor(this.className)
  53
+//            this.getTypeMap() = this.getTypeMapFor(this.className)
51 54
         },
52 55
         
53 56
         
@@ -62,7 +65,7 @@ Class('KiokuJS.Node', {
62 65
         
63 66
         
64 67
         isIntrinsic : function () {
65  
-            return this.intrinsic || this.typeMap.intrinsic
  68
+            return this.intrinsic || this.getTypeMap().intrinsic
66 69
         },
67 70
         
68 71
         
@@ -80,7 +83,7 @@ Class('KiokuJS.Node', {
80 83
                 return
81 84
             }
82 85
             
83  
-            this.ID = this.typeMap.acquireID(this, desiredId)
  86
+            this.ID = this.getTypeMap().acquireID(this, desiredId)
84 87
         },
85 88
         
86 89
         
@@ -93,7 +96,7 @@ Class('KiokuJS.Node', {
93 96
         clearInstance : function () {
94 97
             if (!this.object) throw "Node [" + this + "] doesn't contain an object instance to clear"
95 98
             
96  
-            this.typeMap.clearInstance(this)
  99
+            this.getTypeMap().clearInstance(this)
97 100
         },
98 101
         
99 102
         
@@ -116,7 +119,7 @@ Class('KiokuJS.Node', {
116 119
         
117 120
 
118 121
         collapse : function (collapser) {
119  
-            this.data = this.typeMap.collapse(this, collapser)
  122
+            this.data = this.getTypeMap().collapse(this, collapser)
120 123
         },
121 124
         
122 125
         
@@ -128,14 +131,14 @@ Class('KiokuJS.Node', {
128 131
         createEmptyInstance : function () {
129 132
             if (this.object) throw "Node [" + this + "] already contain an object instance"
130 133
             
131  
-            return this.object = this.typeMap.createEmptyInstance(this)
  134
+            return this.object = this.getTypeMap().createEmptyInstance(this)
132 135
         },
133 136
         
134 137
         
135 138
         populate : function (expander) {
136 139
             if (!this.object) throw "Node [" + this + "] doesn't contain the object - can't be expanded"
137 140
             
138  
-            this.typeMap.populate(this, expander)
  141
+            this.getTypeMap().populate(this, expander)
139 142
             
140 143
             return this.object
141 144
         }
16  lib/KiokuJS/TypeMap.js
@@ -41,18 +41,10 @@ Class('KiokuJS.TypeMap', {
41 41
             
42 42
             if (this.inherit) {
43 43
                 
44  
-                // XXX
45  
-                try {
46  
-                    var classConstructor        = eval(className)
47  
-                    var forClass                = eval(this.forClass)
48  
-                    
49  
-                    if (classConstructor.meta) return classConstructor.meta.isa(forClass)
50  
-                    
51  
-                } catch (e) {
52  
-                    
53  
-                    // XXX
54  
-                    return true
55  
-                }
  44
+                var classConstructor        = eval(className)
  45
+                var forClass                = eval(this.forClass)
  46
+                
  47
+                if (classConstructor.meta) return classConstructor.meta.isa(forClass)
56 48
             }
57 49
             
58 50
             return false

0 notes on commit cb67383

Please sign in to comment.
Something went wrong with that request. Please try again.