More commits to sync working copy
[gnome.introspection-doc-generator] / JSDOC / Token.js
1 //<Script type="text/javascript">
2
3 imports['Object.js'].load(Object);
4 JSDOC   = imports['JSDOC.js'].JSDOC;
5 console = imports['console.js'].console;
6 /**
7         @constructor
8 */
9
10 Token = Object.define(
11     function(data, type, name) {
12         this.data = data;
13         this.type = type;
14         this.name = name;
15         this.prefix = '';
16     }, 
17     Object, 
18     {
19         
20         toRaw : function(lvl)
21         {
22             lvl = lvl || 0;
23             
24             var ret =  this.data ;
25             if (this.items) {
26                 var ar = [];
27                 Roo.each(this.items, function(ai) {
28                     
29                     var str = '';
30                     Roo.each(ai, function(it) {
31                         str += it.toRaw(lvl + 1);
32                     })
33                     ar.push(str);
34                     
35                 })
36                 ret +=   ar.join('');
37                 
38             }
39             if (this.props) {
40                 for (var i in this.props) {
41                     ret += this.props[i].key.toRaw(lvl+1) + ' : ';
42                     Roo.each(this.props[i].val, function(e) {
43                         ret+=e.toRaw(lvl+1);
44                     })
45                     
46                 }
47             }
48             
49             
50             
51             return this.prefix +   ret;
52              
53         },
54
55         toJS : function() {
56             
57             try {
58                 var _tmp = '';
59                 eval( "_tmp = " + this.data);
60                 return _tmp;
61             } catch( e) {
62                 return "ERROR unparsable" + this.data;
63             }
64         },
65          
66                         
67
68         is : function(what) {
69             return this.name === what || this.type === what;
70         }
71 });
72