1 //<script type="text/javascript">
2 //Gtk = imports.gi.Gtk;
3 GI = imports.gi.GIRepository;
4 GLib = imports.gi.GLib;
6 //GObject = imports.gi.GObject;
8 XObject = imports.XObject.XObject;
9 console = imports.console.console;
11 NameSpace = imports.NameSpace.NameSpace;
12 Introspect = imports['JSDOC/Introspect.js'].Introspect;
17 * Base class for Properties, functions, methods etc.
21 Basic = XObject.define(
28 typeToName : function (type_info) {
29 var ty = GI.type_tag_to_string( GI.type_info_get_tag(type_info));
31 if ((ty == 'void') && GI.type_info_is_pointer(type_info)) {
32 return 'void*'; // it's a fake string?!?!!? - slightly naughty...
36 var param_type = GI.type_info_get_param_type (type_info, 0);
37 var atype = GI.type_info_get_tag(param_type);
38 if (atype == GI.ITypeTag.UINT8) {
45 if (ty != 'interface') {
48 var interface_info = GI.type_info_get_interface (type_info);
49 var interface_type = GI.base_info_get_type (interface_info);
50 if (interface_type == GI.IInfoType.CALLBACK) {
52 var Callback = Introspect.Callback ;
53 var ret= new Callback(interface_info, this, false, false);
54 ret.alias = GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
60 return GI.base_info_get_namespace(interface_info) + '.' + GI.base_info_get_name(interface_info);
64 directions : [ "in", "out"," inout"],
66 argsToArrays : function(m, returnArray)
69 var outIntoReturn = false;
70 if (returnArray && returnArray.length == 1 && returnArray[0].type == 'void') {
79 be_null : true, // in theory..
80 desc : "Return Object, use an empty Object, and the properties will get set as follows",
86 for(var a_i =0; a_i < GI.callable_info_get_n_args(m); a_i++) {
87 var arg = GI.callable_info_get_arg(m, a_i);
89 var direction = this.directions[GI.arg_info_get_direction(arg)];
92 name : GI.base_info_get_name(arg),
93 ns : GI.base_info_get_namespace(arg),
94 type : this.typeToName(GI.arg_info_get_type(arg)),
95 direction : direction,
96 be_null : GI.arg_info_may_be_null(arg) || GI.arg_info_is_optional(arg),
97 desc : GI.base_info_get_attribute(arg, 'doc') || ''
101 add.alias = add.ns + '.' + add.name;
103 if (direction == 'out') {
104 firstOut = firstOut > -1 ? firstOut : a_i;
106 returnArray.push(add);
108 outArg.properties.push(add);
116 // drop all the 'out args from the end of args..
123 var l = args.pop(); // drop!
124 if (l.direction == 'out') {
128 args.push(l); // put it back in (it's not a out).
133 if (outArg.properties.length) {
134 // put the out arg in there...
135 if (firstOut >= args.length) {
138 args[firstOut] = outArg;
143 // remove void return....
145 if (returnArray && returnArray.length > 1 && returnArray[0].type == 'void') {