Introspect/Constant.js
[gnome.introspection-doc-generator] / Introspect / Constant.js
1 //<script type="text/javascript">
2 //Gtk = imports.gi.Gtk;
3 GI      = imports.gi.GIRepository;
4 GLib    = imports.gi.GLib;
5 xml     = imports.libxml;
6
7
8 XObject     = imports.XObject.XObject;
9 console     = imports.console.console;
10 NameSpace   = imports.NameSpace.NameSpace;
11
12 Basic        = imports.Basic.Basic;
13
14  
15  
16
17 /**
18  * Constant
19  *
20  *    <union name="Argument" c:type="GIArgument">
21
22  * NEEDS <function name="constant_info_get_value"
23               c:identifier="g_constant_info_get_value"
24               introspectable="1">
25
26  */
27
28
29 Constant = XObject.define(
30     function(prop, memberOf, saveto, keylist) {
31           
32         this.name  =  prop.get_name();
33         var tif    = GI.constant_info_get_type(prop);
34         var ty = GI.type_tag_to_string( GI.type_info_get_tag(tif));
35         this.type  = this.typeToName(GI.constant_info_get_type(prop));
36         
37         ///this.flags =  GI.property_info_get_flags(prop),
38         
39         
40         this.value= 'UNKNOWN';
41         
42         
43         if (ty != 'interface') {
44             
45             var argm = new GI._Argument();
46             GI.constant_info_get_value ?
47                 GI.constant_info_get_value ( prop ,argm) :
48                 prop.get_value(argm);
49                 
50             if (ty != 'utf8') {
51                 this.value = argm.v_long;
52             } else {
53                 this.value = argm.v_string;
54             }
55         } 
56         
57         this.desc = NameSpace.doc(memberOf.alias + '.' + this.name)
58         
59         memberOf[saveto].push(this);
60         keylist.push(this.name);
61     },
62     Basic,
63     { }
64 );