~ubuntu-branches/ubuntu/raring/ubufox/raring-proposed

« back to all changes in this revision

Viewing changes to res/libs/glib.jsm

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-11-12 13:27:26 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20121112132726-ssrixfmjgibo8f3s
Tags: 2.6-0ubuntu1
* New upstream release.
  - Translation updates, thanks to Adolfo Jayme Barrientos and David Planella

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 *
37
37
 * ***** END LICENSE BLOCK ***** */
38
38
 
 
39
const { utils: Cu } = Components;
 
40
 
39
41
var EXPORTED_SYMBOLS = [ "glib" ];
40
42
 
41
43
const GLIB_LIBNAME = "glib-2.0";
42
44
const GLIB_ABIS = [ 0 ];
43
45
 
44
 
const Cu = Components.utils;
45
 
 
46
46
Cu.import("resource://gre/modules/ctypes.jsm");
47
 
Cu.import("resource://ubufox/libs/ctypes-utils.jsm");
 
47
Cu.import("resource://ubufox/modules/utils.jsm");
 
48
 
 
49
function getString(aWrappee) {
 
50
  let res = aWrappee.apply(null, Array.prototype.slice.call(arguments, 1));
 
51
  return res.isNull() ? null : res.readString();
 
52
}
48
53
 
49
54
function glib_defines(lib) {
50
55
  // Enums
51
56
 
52
57
  // Types
53
 
  this.gpointer = ctypes.voidptr_t;
54
 
  this.gchar = ctypes.char;
55
 
  this.gint = ctypes.int;
56
 
  this.gint32 = ctypes.int32_t;
57
 
  this.guint32 = ctypes.uint32_t;
58
 
  this.gulong = ctypes.unsigned_long;
59
 
  this.GQuark = this.guint32;
60
 
  this.GError = ctypes.StructType("GError",
61
 
                                  [{'domain': this.GQuark},
62
 
                                   {'code': this.gint},
63
 
                                   {'message': this.gchar.ptr}]);
64
 
  this.GVariant = ctypes.StructType("GVariant");
65
 
  this.GVariantBuilder = ctypes.StructType("GVariantBuilder", [{'x': ctypes.size_t.array(16)}]);
66
 
  // XXX: Is this right?
67
 
  this.GVariantType = ctypes.char;
 
58
  CTypesUtils.defineSimple(this, "gpointer", ctypes.voidptr_t);
 
59
  CTypesUtils.defineSimple(this, "gchar", ctypes.char);
 
60
  CTypesUtils.defineSimple(this, "gint", ctypes.int);
 
61
  CTypesUtils.defineSimple(this, "gint32", ctypes.int32_t);
 
62
  CTypesUtils.defineSimple(this, "guint32", ctypes.uint32_t);
 
63
  CTypesUtils.defineSimple(this, "gulong", ctypes.unsigned_long);
 
64
  CTypesUtils.defineSimple(this, "GQuark", this.guint32);
 
65
  CTypesUtils.defineSimple(this, "GError",
 
66
                           ctypes.StructType("GError",
 
67
                                             [{'domain': this.GQuark},
 
68
                                              {'code': this.gint},
 
69
                                              {'message': this.gchar.ptr}]));
 
70
  CTypesUtils.defineSimple(this, "GVariant", ctypes.StructType("GVariant"));
 
71
  CTypesUtils.defineSimple(this, "GVariantBuilder",
 
72
                           ctypes.StructType("GVariantBuilder",
 
73
                                             [{'x': ctypes.size_t.array(16)}]));
 
74
  CTypesUtils.defineSimple(this, "GVariantType", ctypes.char);
68
75
 
69
76
  // Templates
70
77
 
71
78
  // Functions
72
 
  lib.lazy_bind("g_error_free", ctypes.void_t, this.GError.ptr);
73
 
  lib.lazy_bind("g_free", ctypes.void_t, this.gpointer);
 
79
  lib.lazy_bind("g_error_free", ctypes.void_t, [this.GError.ptr]);
 
80
  lib.lazy_bind("g_free", ctypes.void_t, [this.gpointer]);
74
81
  lib.lazy_bind("g_variant_builder_new", this.GVariantBuilder.ptr,
75
 
                this.GVariantType.ptr);
76
 
  lib.lazy_bind("g_variant_builder_add", ctypes.void_t, this.GVariantBuilder.ptr,
77
 
                this.gchar.ptr, "...");
 
82
                [this.GVariantType.ptr]);
 
83
  lib.lazy_bind("g_variant_builder_add", ctypes.void_t, [this.GVariantBuilder.ptr,
 
84
                this.gchar.ptr, "..."]);
78
85
  lib.lazy_bind("g_variant_builder_add_value", ctypes.void_t,
79
 
                this.GVariantBuilder.ptr, this.GVariant.ptr);
 
86
                [this.GVariantBuilder.ptr, this.GVariant.ptr]);
80
87
  lib.lazy_bind("g_variant_builder_end", this.GVariant.ptr,
81
 
                this.GVariantBuilder.ptr);
 
88
                [this.GVariantBuilder.ptr]);
82
89
  lib.lazy_bind("g_variant_builder_unref", ctypes.void_t,
83
 
                this.GVariantBuilder.ptr);
 
90
                [this.GVariantBuilder.ptr]);
84
91
  lib.lazy_bind("g_variant_builder_init", ctypes.void_t,
85
 
                this.GVariantBuilder.ptr, this.GVariantType.ptr);
 
92
                [this.GVariantBuilder.ptr, this.GVariantType.ptr]);
86
93
  lib.lazy_bind("g_variant_builder_clear", ctypes.void_t,
87
 
                this.GVariantBuilder.ptr);
88
 
  lib.lazy_bind("g_variant_unref", ctypes.void_t, this.GVariant.ptr);
89
 
  lib.lazy_bind("g_variant_get_string", this.gchar.ptr, this.GVariant.ptr,
90
 
                ctypes.size_t.ptr);
91
 
  lib.lazy_bind("g_variant_get", ctypes.void_t, this.GVariant.ptr,
92
 
                this.gchar.ptr, "...");
93
 
  lib.lazy_bind("g_variant_get_int32", this.gint32, this.GVariant.ptr);
94
 
  lib.lazy_bind("g_variant_new", this.GVariant.ptr, this.gchar.ptr, "...");
 
94
                [this.GVariantBuilder.ptr]);
 
95
  lib.lazy_bind("g_variant_unref", ctypes.void_t, [this.GVariant.ptr]);
 
96
  lib.lazy_bind_with_wrapper("g_variant_get_string", getString, this.gchar.ptr,
 
97
                             [this.GVariant.ptr, ctypes.size_t.ptr]);
 
98
  lib.lazy_bind("g_variant_get", ctypes.void_t, [this.GVariant.ptr,
 
99
                this.gchar.ptr, "..."]);
 
100
  lib.lazy_bind("g_variant_get_int32", this.gint32, [this.GVariant.ptr]);
 
101
  lib.lazy_bind("g_variant_new", this.GVariant.ptr, [this.gchar.ptr, "..."]);
95
102
}
96
103
 
97
 
new ctypes_library(GLIB_LIBNAME, GLIB_ABIS, glib_defines, this);
 
104
var glib = new CTypesUtils.newLibrary(GLIB_LIBNAME, GLIB_ABIS, glib_defines);