@@ -225,25 +225,43 @@ Object.defineProperties(MachineType.prototype, {
225225Object . defineProperties ( this , {
226226
227227 Void : { value : new MachineType ( { width :0 } ) } ,
228- VarArg :{ value : new MachineType ( { width :MachineType . ptrSize , vararg :true } ) } ,
229228
230- Int8 : { value : new MachineType ( { width :1 , signed :true } ) } ,
231- Int16 : { value : new MachineType ( { width :2 , signed :true } ) } ,
232- Int32 : { value : new MachineType ( { width :4 , signed :true } ) } ,
233- Int64 : { value : new MachineType ( { width :8 , signed :true } ) } ,
229+ Bool : { value : new MachineType ( { width : 1 , boolean : true } ) } ,
230+
231+ Char : { value : new MachineType ( { width :1 , signed :true } ) } ,
232+ UChar : { value : new MachineType ( { width :1 } ) } ,
233+
234+ Short : { value : new MachineType ( { width :2 , signed :true } ) } ,
235+ UShort : { value : new MachineType ( { width :2 } ) } ,
236+
237+ Int : { value : new MachineType ( { width :MachineType . intSize , signed :true } ) } , // platform sized signed int
238+ UInt : { value : new MachineType ( { width :MachineType . intSize } ) } , // platform sized int
234239
240+ Long : { value : new MachineType ( { width :4 , signed :true } ) } ,
241+ ULong : { value : new MachineType ( { width :4 } ) } ,
242+
243+ LongLong : { value : new MachineType ( { width :8 , signed :true } ) } ,
244+ ULongLong : { value : new MachineType ( { width :8 } ) } ,
245+
246+ Float : { value : new MachineType ( { width :4 , floating :true } ) } ,
247+ Double : { value : new MachineType ( { width :8 , floating :true } ) } ,
248+
249+ Int8 : { value : new MachineType ( { width :1 , signed :true } ) } ,
235250 UInt8 : { value : new MachineType ( { width :1 } ) } ,
251+
252+ Int16 : { value : new MachineType ( { width :2 , signed :true } ) } ,
236253 UInt16 : { value : new MachineType ( { width :2 } ) } ,
254+
255+ Int32 : { value : new MachineType ( { width :4 , signed :true } ) } ,
237256 UInt32 : { value : new MachineType ( { width :4 } ) } ,
238- UInt64 : { value : new MachineType ( { width :8 } ) } ,
239257
240- UIntPtr : { value : new MachineType ( { width :MachineType . ptrSize } ) } ,
241- IntSize : { value : new MachineType ( { width :MachineType . intSize } ) } ,
258+ Int64 : { value : new MachineType ( { width :8 , signed : true } ) } ,
259+ UInt64 : { value : new MachineType ( { width :8 } ) } ,
242260
243- Float : { value : new MachineType ( { width :4 , floating : true } ) } ,
244- Double : { value : new MachineType ( { width :8 , floating : true } ) } ,
261+ UIntPtr : { value : new MachineType ( { width :MachineType . ptrSize } ) } , // platform sized pointer
262+ IntSize : { value : new MachineType ( { width :MachineType . intSize } ) } , // analog: size_t
245263
246- Bool : { value : new MachineType ( { width : 1 , boolean : true } ) }
264+ VarArg : { value : new MachineType ( { width :MachineType . ptrSize , vararg : true } ) }
247265
248266} ) ;
249267
@@ -399,11 +417,9 @@ Object.defineProperties(SharedLibrary.prototype, {
399417 constructor :{ value :SharedLibrary }
400418} ) ;
401419
402- SharedFunction . create = function ( lib , name , type ) {
403- this . library = lib ,
404- this . name = name ,
405- this . returns = type ,
406- this . pointer = lib [ name ] ,
420+ SharedFunction . create = function ( lib , type , name ) {
421+ this . library = lib , this . returns = type , this . name = name ,
422+ this . pointer = lib [ name ] ,
407423 this . parameter = Array . apply ( Array , arguments ) . slice ( 3 ) ;
408424 return this ;
409425} ;
@@ -423,8 +439,7 @@ Object.defineProperties(SharedFunction.prototype, {
423439} ) ;
424440
425441FunctionCallback . create = function ( object , type , _function ) {
426- this . object = object ;
427- this . returns = type ,
442+ this . object = object , this . returns = type ,
428443 this . function = _function ,
429444 this . parameter = Array . apply ( Array , arguments ) . slice ( 3 ) ;
430445 return this ;
@@ -442,3 +457,18 @@ Object.defineProperties(FunctionCallback.prototype, {
442457 return String . fromCharCode . apply ( String , a ) ;
443458 } }
444459} ) ;
460+
461+ var lib = {
462+ glib2 : new SharedLibrary ( 'libglib-2.0.so' ) ,
463+ gtk3 : new SharedLibrary ( 'libgtk-3.so' )
464+ } ;
465+
466+ var Glib = {
467+ free : new SharedFunction ( lib . glib2 , Void , "g_free" , Pointer ) ,
468+ base64 : {
469+ encode : new SharedFunction ( lib . glib2 , Pointer , "g_base64_encode" , Pointer , IntSize ) ,
470+ decode : new SharedFunction ( lib . glib2 , Pointer , "g_base64_decode" , Pointer , IntSize . toPointer ( ) )
471+ }
472+ } ;
473+
474+ var Gtk = { } ;
0 commit comments