Codebase list ruby-fxruby / ddfc60e swig-interfaces / ruby-typemaps.i
ddfc60e

Tree @ddfc60e (Download .tar.gz)

ruby-typemaps.i @ddfc60eraw · history · blame

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
/***********************************************************************
 * FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
 * Copyright (c) 2001-2009 by Lyle Johnson. All Rights Reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * For further information please contact the author by e-mail
 * at "[email protected]".
 ***********************************************************************/

%include constraints.i

%apply Pointer NONNULL {
  FXApp* APP,
  FXApp* a,
  FXApp* app,
  FXApp* application,
  FXComposite* PARENT,
  FXComposite* p,
  FXWindow* OWNER,
  FXWindow* own,
  FXWindow* owner
}

%typemap(in) FXchar "$1 = NUM2INT($input);";
%typemap(in) FXuchar "$1 = NUM2UINT($input);";
%typemap(in) FXshort "$1 = NUM2INT($input);";
%typemap(in) FXushort "$1 = NUM2UINT($input);";
%typemap(in) FXint "$1 = NUM2INT($input);";
%typemap(in) FXuint "$1 = NUM2UINT($input);";
%typemap(in) FXlong "$1 = NUM2LONG($input);";
%typemap(in) FXulong "$1 = NUM2ULONG($input);";

%typecheck(SWIG_TYPECHECK_INTEGER) FXchar, FXuchar, FXshort, FXushort, FXint, FXuint, FXlong, FXulong {
  $1 = (TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM) ? 1 : 0;
}

/* Type-checking rules */
%typecheck(SWIG_TYPECHECK_STRING) const FXString&, FXuchar *data {
  $1 = (NIL_P($input) || TYPE($input) == T_STRING) ? 1 : 0;
}

%typecheck(SWIG_TYPECHECK_POINTER) void *ITEMDATA {
  $1 = 1;
}

%typecheck(SWIG_TYPECHECK_BOOL) FXbool {
  $1 = ($input == Qtrue || $input == Qfalse) ? 1 : 0;
}

/* Convert Ruby object to FXColor */
%{
inline FXColor to_FXColor(VALUE obj){
  if(TYPE(obj)==T_STRING){
    return fxcolorfromname(StringValuePtr(obj));
    }
  else if(TYPE(obj)==T_SYMBOL){
    return fxcolorfromname(rb_id2name(SYM2ID(obj)));
    }
  else{
    return NUM2ULONG(obj);
    }
  }
%}
%typemap(in) FXColor "$1 = to_FXColor($input);";

/* Convert Ruby VALUE to VALUE */
%typemap(out) VALUE "$result = $1;";

/* Convert Ruby String to FXString */
%{
inline FXString to_FXString(VALUE obj){
  if(!NIL_P(obj)){
    Check_Type(obj,T_STRING);
    return FXString(StringValuePtr(obj));
    }
  else{
    return FXString::null;
    }
  }
%}

/* Convert Ruby string to FXString */
%typemap(in) FXString "$1 = to_FXString($input);";

/* Convert Ruby string to const FXString& */
%typemap(in) const FXString& (SwigValueWrapper<FXString> p) "p = to_FXString($input); $1 = &p;";

/* Convert either a String or nil to an FXchar* */
%typemap(in) const FXchar* "$1 = NIL_P($input) ? 0 : StringValuePtr($input);";

/* Convert Ruby true and false to FXbool inputs */
%{
inline FXbool to_FXbool(VALUE obj){
  if (obj == Qtrue || obj == Qfalse){
    return (obj == Qtrue) ? TRUE : FALSE;
    }
  else{
    return static_cast<FXbool>(NUM2UINT(obj));
    }
  }
%}

%typemap(in) FXbool "$1 = to_FXbool($input);";

/* Convert FXbool return types */
%typemap(out) FXbool "$result = $1 ? Qtrue : Qfalse;";

/* Convert FXString struct members to Ruby strings */
%typemap(out) FXString * "$result = to_ruby($1->text());";

/* Convert FXString return values to Ruby strings */
%typemap(out) FXString "$result = to_ruby($1.text());";

/* Convert const FXString& return values to Ruby strings */
%typemap(out) const FXString& "$result = to_ruby($1->text());";

/**
 * Used by constructors for icons and images that require an array
 * of bytes as input; accepts a Ruby string instance instead. Also
 * accepts "nil" in place of a NULL pointer.
 */
%typemap(in) const void* pix {
  if ($input != Qnil) {
    Check_Type($input, T_STRING);
    $1 = reinterpret_cast<$1_ltype>(RSTRING_PTR($input));
  } else {
    $1 = NULL;
  }
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) const void * pix {
  $1 = (NIL_P($input) || TYPE($input) == T_STRING) ? 1 : 0;
}

/**
 * Used by constructors for icons and images that require an array
 * of FXColor values as input; accepts a Ruby array of Integers instead. Also
 * accepts "nil" in place of a NULL pointer.
 */
%typemap(in) const FXColor* PIXELS {
  $1=NULL;
  if($input!=Qnil){
    Check_Type($input,T_ARRAY);
    if(FXMALLOC(&$1,FXColor,RARRAY_LEN($input))){
      for(long i=0; i<RARRAY_LEN($input); i++){
        $1[i]=static_cast<FXColor>(NUM2UINT(rb_ary_entry($input,i)));
      }
    }
  }
}

/**
 * Free-up the temporary array allocated above.
 */
%typemap(freearg) const FXColor* PIXELS "FXFREE(&$1);";

/**
 * Used by constructors for FXXPMIcon and FXXPMImage, which require an array
 * of strings as input; uses a Ruby list of strings instead. Also accepts "nil"
 * in place of a NULL pointer.
 */
%typemap(in) const FXchar** pix {
  $1 = NULL;
  if ($input != Qnil) {
    Check_Type($input, T_ARRAY);
    if (FXMALLOC(&$1, FXchar *, RARRAY_LEN($input))) {
      for (long i = 0; i < RARRAY_LEN($input); i++) {
        VALUE e = rb_ary_entry($input, i);
        $1[i] = (FXchar *) StringValuePtr(e);
      }
    }
  }
}

/**
 * Free-up the temporary array allocated above.
 */
%typemap(freearg) const FXchar** pix "FXFREE(&$1);";

/* Used for FXHeader#fillItems and others */
%typecheck(SWIG_TYPECHECK_STRING_ARRAY) const FXchar** strings {
  $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
  if ($1 != 0) {
    for (long i = 0; i < RARRAY_LEN($input); i++) {
      if (TYPE(rb_ary_entry($input, i)) != T_STRING) {
        $1 = 0;
	break;
      }
    }
  }
}

%typemap(in) const FXchar** strings {
  $1 = NULL;
  if(!NIL_P($input)){
    Check_Type($input, T_ARRAY);
    if (FXMALLOC(&$1, FXchar *, RARRAY_LEN($input)+1)) {
      for (long i = 0; i < RARRAY_LEN($input); i++) {
        VALUE e = rb_ary_entry($input, i);
        $1[i] = (FXchar *) StringValuePtr(e);
      }
      $1[RARRAY_LEN($input)] = 0;
    }
  }
}

%typemap(freearg) const FXchar** strings "FXFREE(&$1);";

/* Used for FXColorList#fillItems */
%typemap(in) FXColor* colors {
  $1 = NULL;
  if(!NIL_P($input)){
    Check_Type($input, T_ARRAY);
    if (FXMALLOC(&$1, FXColor, RARRAY_LEN($input)+1)) {
      for (long i = 0; i < RARRAY_LEN($input); i++) {
        $1[i] = static_cast<FXColor>(NUM2ULONG(rb_ary_entry($input, i)));
      }
      $1[RARRAY_LEN($input)] = 0;
    }
  }
}

%typemap(freearg) FXColor* colors "FXFREE(&$1);";

/* Convert a Ruby object into a void pointer (for list item data) */
%typemap(in) void* ITEMDATA "$1 = ($input == Qnil) ? NULL : (void *) $input;";

/* Convert a Ruby FXEvent instance into a pointer to a C++ FXEvent */
%{
static swig_type_info* FXEventTypeInfo=0;

inline void* to_FXEvent(VALUE obj){
  void* ptr;
  if(!FXEventTypeInfo){
    FXEventTypeInfo=SWIG_TypeQuery("FXEvent *");
    FXASSERT(FXEventTypeInfo!=0);
    }
  SWIG_ConvertPtr(obj,&ptr,FXEventTypeInfo,1);
  return ptr;
  }
%}

/* Convert a Ruby instance into either a NULL pointer or a non-NULL */
%typemap(in) void* PTR_BOOL "$1 = reinterpret_cast<void*>(NIL_P($input) ? 0 : 1);";

/* Convert a Ruby number into an FXColor */
%typemap(in) void* PTR_COLOR "$1 = reinterpret_cast<void*>(NUM2UINT($input));";

/* Convert a Ruby string to a C string */
%typemap(in) void* PTR_CSTRING "$1 = static_cast<void*>(StringValuePtr($input));";

/* Convert a Ruby array (of size 2) into an FXdouble array */
%typemap(in) void* PTR_DBLRANGE_IN(FXdouble values[2]) {
  Check_Type($input, T_ARRAY);
  values[0] = (FXdouble) NUM2DBL(rb_ary_entry($input, 0));
  values[1] = (FXdouble) NUM2DBL(rb_ary_entry($input, 1));
  $1 = (void *) values;
}

/* Convert an FXdouble array to a Ruby array */
%typemap(freeargs) void* PTR_DBLRANGE_OUT(FXdouble* values) {
  Check_Type($input, T_ARRAY);
  values = (FXdouble*) $1;
  rb_ary_store($input, 0, to_ruby(values[0]));
  rb_ary_store($input, 1, to_ruby(values[1]));
}

/* Convert a Ruby FXDirItem instance into a pointer to a C++ FXDirItem */
%typemap(in) void* PTR_DIRITEM "SWIG_ConvertPtr($input,&$1,SWIGTYPE_p_FXDirItem,1);";

%typemap(in) void* PTR_EVENT "$1 = to_FXEvent($input);";

/* Convert a Ruby array (of size 3) into an FXfloat array */
%typemap(in) void* PTR_FLTARRAY(FXfloat values[3]) {
  Check_Type($input, T_ARRAY);
  values[0] = (FXfloat) NUM2DBL(rb_ary_entry($input, 0));
  values[1] = (FXfloat) NUM2DBL(rb_ary_entry($input, 1));
  values[2] = (FXfloat) NUM2DBL(rb_ary_entry($input, 2));
  $1 = (void *) values;
}

/* Convert a Ruby FXIcon reference to a pointer to an FXIcon */
%typemap(in) void* PTR_ICON(void *tmp) {
  tmp = FXRbConvertPtr($input, FXRbTypeQuery("FXIcon *"));
  $1 = (void *) &tmp;
}

/* Message data is ignored (doesn't matter what we set $1 to) */
%typemap(in) void* PTR_IGNORE "$1 = 0;";

/* Convert a Ruby number into an FXint */
%typemap(in) void* PTR_INT "$1 = reinterpret_cast<void*>(NUM2INT($input));";

/* Convert a Ruby array (size 2) into an FXint array */
%typemap(in) void* PTR_INTRANGE_IN(FXint values[2]) {
  Check_Type($input, T_ARRAY);
  values[0] = (FXint) NUM2INT(rb_ary_entry($input, 0));
  values[1] = (FXint) NUM2INT(rb_ary_entry($input, 1));
  $1 = static_cast<void*>(values);
}

/* Convert an FXint array (size 2) into a Ruby array */
%typemap(freeargs) void* PTR_INTRANGE_OUT(FXint* values) {
  Check_Type($input, T_ARRAY);
  values = (FXint *) $1;
  rb_ary_store($input, 0, to_ruby(values[0]));
  rb_ary_store($input, 1, to_ruby(values[1]));
}

/* Convert a Ruby number into an FXival */
%typemap(in) void* PTR_IVAL "$1 = reinterpret_cast<void*>(static_cast<FXival>(NUM2LONG($input)));";

/* Convert a Ruby instance (type varies) into the appropriate void pointer */
%typemap(in) void* PTR_MAGIC "$1 = FXRbGetExpectedData(self, arg3, $input);";

/* Convert a Ruby instance into a void pointer to a C++ NULL */
%typemap(in) void* PTR_NULL "$1 = 0;";

/* Convert a Ruby FXObject instance into a pointer to a C++ FXObject */
%typemap(in) void* PTR_OBJECT "SWIG_ConvertPtr($input,&$1,SWIGTYPE_p_FXObject,1);";

/* Convert a Ruby FXPoint instance into a pointer to a C++ FXPoint */
%typemap(in) void* PTR_POINT "$1 = FXRbConvertPtr($input, FXRbTypeQuery(\"FXPoint *\"));";

/* Convert a Ruby number into a pointer to an FXdouble */
%typemap(in) void* PTR_PDOUBLE(FXdouble value) {
  value = (FXdouble) NUM2DBL($input);
  $1 = (void *) &value;
}

/* Convert a Ruby number into a pointer to an FXint */
%typemap(in) void* PTR_PINT(FXint value) {
  value = (FXint) NUM2INT($input);
  $1 = static_cast<void*>(&value);
}

/* Convert a Ruby string to a pointer to an FXString */
%typemap(in) void* PTR_STRING(FXString value) {
  value = FXString(StringValuePtr($input));
  $1 = (void *) &value;
}

/* Convert a Ruby FXTreeItem instance into a pointer to a C++ FXTreeItem */
%typemap(in) void* PTR_TREEITEM "SWIG_ConvertPtr($input,&$1,SWIGTYPE_p_FXTreeItem,1);";

/* Convert a Ruby number into an FXuchar */
%typemap(in) void* PTR_UCHAR "$1 = reinterpret_cast<void*>(NUM2UINT($input));";

/* Convert a Ruby number into an FXuint */
%typemap(in) void* PTR_UINT "$1 = reinterpret_cast<void*>(NUM2UINT($input));";

/**
 * Accept either an FXVec3f instance or a 3-element array of floats
 * when an FXVec3f is expected as input.
 */

%typemap(in) const FXVec3f& {
    if (TYPE($input) == T_ARRAY) {
        $1 = new FXVec3f(NUM2DBL(rb_ary_entry($input, 0)), NUM2DBL(rb_ary_entry($input, 1)), NUM2DBL(rb_ary_entry($input, 2)));
    } else {
        FXVec3f *p;
	SWIG_ConvertPtr($input, (void **)&p, SWIGTYPE_p_FXVec3f, 1);
	$1 = new FXVec3f(*p);
    }
}

%typemap(freearg) const FXVec3f& "delete $1;";

%typemap(in) FXVec3f * (FXVec3f tmp) {
    if (TYPE($input) == T_ARRAY) {
        tmp = FXVec3f(NUM2DBL(rb_ary_entry($input, 0)), NUM2DBL(rb_ary_entry($input, 1)), NUM2DBL(rb_ary_entry($input, 2)));
        $1 = &tmp;
    } else {
	SWIG_ConvertPtr($input, (void **) &$1, SWIGTYPE_p_FXVec3f, 1);
    }
}

/**
 * Accept either an FXVec4f instance or a 4-element array of floats
 * when an FXVec4f is expected as input.
 */

%typemap(in) const FXVec4f& {
    if (TYPE($input) == T_ARRAY) {
        $1 = new FXVec4f(NUM2DBL(rb_ary_entry($input, 0)), NUM2DBL(rb_ary_entry($input, 1)), NUM2DBL(rb_ary_entry($input, 2)), NUM2DBL(rb_ary_entry($input, 3)));
    } else {
        FXVec4f *p;
	SWIG_ConvertPtr($input,(void **)&p,SWIGTYPE_p_FXVec4f,1);
	$1 = new FXVec4f(*p);
    }
}

%typemap(freearg) const FXVec4f& "delete $1;";

%typemap(in) FXVec4f * (FXVec4f tmp) {
    if (TYPE($input) == T_ARRAY) {
        tmp = FXVec4f(NUM2DBL(rb_ary_entry($input, 0)), NUM2DBL(rb_ary_entry($input, 1)), NUM2DBL(rb_ary_entry($input, 2)), NUM2DBL(rb_ary_entry($input, 3)));
        $1 = &tmp;
    } else {
	SWIG_ConvertPtr($input, (void **) &$1, SWIGTYPE_p_FXVec4f, 1);
    }
}

/* Output typemap for FXObject instances */
%typemap(out) FXObject * {
    swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
    $result = FXRbGetRubyObj($1, ty);
}

/* Output typemap for FXAccelTable instances */
%typemap(out) FXAccelTable * = FXObject *;

/* Output typemap for FXApp instances */
%typemap(out) FXApp * = FXObject *;

/* Output typemap for FXBitmap instances */
%typemap(out) FXBitmap * = FXObject *;

/* Output typemap for FXButton instances */
%typemap(out) FXButton * = FXObject *;

/* Output typemap for FXChore instances */
%typemap(out) FXChore* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%nodefaultctor FXChore;

/* Output typemap for FXComposite instances */
%typemap(out) FXComposite * = FXObject *;

/* Output typemap for FXCursor instances */
%typemap(out) FXCursor * = FXObject *;

/* Output typemap for FXDragCorner instances */
%typemap(out) FXDragCorner * = FXObject *;

/* Output typemap for FXFileAssoc instances */
%typemap(out) FXFileAssoc* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXFileDict instances */
%typemap(out) FXFileDict * = FXObject *;

/* Output typemap for FXFoldingItem instances */
%typemap(out) FXFoldingItem* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXFont instances */
%typemap(out) FXFont * = FXObject *;

/* Output typemap for FXFontDesc instances */
%typemap(out) FXFontDesc {
    FXFontDesc* resultptr = new FXFontDesc($1);
    $result = FXRbGetRubyObj(resultptr, "FXFontDesc *");
}
%typemap(out) FXFontDesc* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXGLObject instances */
%typemap(out) FXGLObject* = FXObject *;

/* Output typemap for FXGLShape instances */
%typemap(out) FXGLShape * = FXObject *;

/* Output typemap for FXGLVisual instances */
%typemap(out) FXGLVisual * = FXObject *;

/* Output typemap for FXHeader instances */
%typemap(out) FXHeader * = FXObject *;

/* Output typemap for FXHeaderItem instances */
%typemap(out) FXHeaderItem * = FXObject *;

/* Output typemap for FXMat4f instances */
%typemap(out) FXMat4f {
    FXMat4f* resultptr = new FXMat4f($1);
    $result = FXRbGetRubyObj(resultptr, "FXMat4f *");
}
%typemap(out) FXMat4f& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXVec2d instances */
%typemap(out) FXVec2d* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) FXVec2d& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXVec2f instances */
%typemap(out) FXVec2f* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) FXVec2f& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXVec4f instances */
%typemap(out) FXVec4f {
    FXVec4f* resultptr = new FXVec4f($1);
    $result = FXRbGetRubyObj(resultptr, "FXVec4f *");
}
%typemap(out) FXVec4f* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) FXVec4f& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXIcon instances */
%typemap(out) FXIcon * = FXObject *;

/* Output typemap for FXIconItem instances */
%typemap(out) FXIconItem * = FXObject *;

/* Output typemap for FXImage instances */
%typemap(out) FXImage * = FXObject *;

/* Output typemap for FXLight instances */
%typemap(out) FXLight {
    FXLight *resultptr = new FXLight($1);
    $result = FXRbGetRubyObj(resultptr, "FXLight *");
}
%typemap(out) FXLight* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXListItem instances */
%typemap(out) FXListItem * = FXObject *;

/* Output typemap for FXMaterial instances */
%typemap(out) FXMaterial {
    FXMaterial *resultptr = new FXMaterial($1);
    $result = FXRbGetRubyObj(resultptr, "FXMaterial *");
}

/* Output typemap for FXMDIChild instances */
%typemap(out) FXMDIChild * = FXObject *;

/* Output typemap for FXOption instances */
%typemap(out) FXOption * = FXObject *;

/* Output typemap for FXPoint instances */
%typemap(out) FXPoint* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXPopup instances */
%typemap(out) FXPopup * = FXObject *;

/* Output typemap for FXPrinter instances */
%typemap(out) FXPrinter {
    FXPrinter *resultptr = new FXPrinter($1);
    $result = FXRbGetRubyObj(resultptr, "FXPrinter *");
}

/* Output typemap for FXQuatf instances */
%typemap(out) FXQuatf {
    FXQuatf *resultptr = new FXQuatf($1);
    $result = FXRbGetRubyObj(resultptr, "FXQuatf *");
}
%typemap(out) FXQuatf& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXRangef instances */
%typemap(out) FXRangef {
    FXRangef* resultptr = new FXRangef($1);
    $result = FXRbGetRubyObj(resultptr, "FXRangef *");
}
%typemap(out) FXRangef& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXRectangle instances */
%typemap(out) FXRectangle*, FXRectangle&, const FXRectangle& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) FXRectangle {
    FXRectangle* resultptr = new FXRectangle($1);
    $result = FXRbGetRubyObj(resultptr, "FXRectangle *");
}

/* Output typemap for FXRegion instances */
%typemap(out) FXRegion {
    FXRegion* resultptr = new FXRegion($1);
    $result = FXRbGetRubyObj(resultptr, "FXRegion *");
}
%typemap(out) FXRegion&       "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) const FXRegion& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXRegistry instances */
%typemap(out) FXRegistry& = FXObject *;

/* Output typemap for FXRootWindow instances */
%typemap(out) FXRootWindow * = FXObject *;

/* Output typemap for FXScrollBar instances */
%typemap(out) FXScrollBar * = FXObject *;

/* Output typemap for FXSize instances */
%typemap(out) FXSize* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXStatusLine instances */
%typemap(out) FXStatusLine * = FXObject *;

/* Output typemap for FXStream instances */
%typemap(out) FXStream* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXStringDict instances */
%typemap(out) FXStringDict * = FXObject *;

/* Output typemap for FXTableItem instances */
%typemap(out) FXTableItem * = FXObject *;

/* Output typemap for FXTablePos instances */
// %typemap(out) FXTablePos* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXTableRange instances */
// %typemap(out) FXTableRange* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXTimer instances */
%typemap(out) FXTimer* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%nodefaultctor FXTimer;

/* Output typemap for FXTreeItem instances */
%typemap(out) FXTreeItem * = FXObject *;

/* Output typemap for FXVec3f instances */
%typemap(out) FXVec3f {
    FXVec3f* resultptr = new FXVec3f($1);
    $result = FXRbGetRubyObj(resultptr, "FXVec3f *");
}
%typemap(out) FXVec3f*       "$result = FXRbGetRubyObj($1, \"$1_ltype\");";
%typemap(out) const FXVec3f& "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

/* Output typemap for FXVerticalFrame instances */
%typemap(out) FXVerticalFrame * = FXObject *;

/* Output typemap for FXViewport instances */
%typemap(out) FXViewport {
    FXViewport* resultptr = new FXViewport($1);
    $result = FXRbGetRubyObj(resultptr, "FXViewport *");
}

/* Output typemap for FXVisual instances */
%typemap(out) FXVisual* = FXObject *;

/* Output typemap for FXWindow instances */
%typemap(out) FXWindow * = FXObject *;

/* Output typemap for NotifyHeader instances */
// %typemap(out) NotifyHeader* "$result = FXRbGetRubyObj($1, \"$1_ltype\");";

// Extract a C array (points) and its length (npoints) from a Ruby array of FXPoint instances
%typecheck(SWIG_TYPECHECK_OBJECT_ARRAY) (const FXPoint* points, FXuint npoints) {
  $1 = (TYPE($input) == T_ARRAY) ? 1 : 0;
}
%typemap(in) (const FXPoint* points, FXuint npoints) {
    Check_Type($input, T_ARRAY);
    $1 = new FXPoint[RARRAY_LEN($input)];
    $2 = static_cast<FXuint>( RARRAY_LEN($input) );
    for (FXuint i = 0; i < $2; i++) {
        FXPoint *pPoint;
        Data_Get_Struct(rb_ary_entry($input, i), FXPoint, pPoint);
        $1[i] = *pPoint;
    }
}
%typemap(freearg) (const FXPoint* points, FXuint npoints) {
    delete [] $1;
}

// Extract a C array (segments) and its length (nsegments) from a Ruby array of FXSegment instances
%typemap(in) (const FXSegment* segments, FXuint nsegments) {
    Check_Type($input, T_ARRAY);
    $1 = new FXSegment[RARRAY_LEN($input)];
    $2 = static_cast<FXuint>( RARRAY_LEN($input) );
    for (FXuint i = 0; i < $2; i++) {
        FXSegment *pSeg;
        Data_Get_Struct(rb_ary_entry($input, i), FXSegment, pSeg);
        $1[i] = *pSeg;
    }
}

%typemap(freearg) (const FXSegment* segments, FXuint nsegments) {
    delete [] $1;
}

// Extract a C array (rectangles) and its length (nrectangles) from a Ruby array of FXRectangle instances
%typemap(in) (const FXRectangle* rectangles, FXuint nrectangles) {
    Check_Type($input, T_ARRAY);
    $1 = new FXRectangle[RARRAY_LEN($input)];
    $2 = static_cast<FXuint>( RARRAY_LEN($input) );
    for (FXuint i = 0; i < $2; i++) {
        FXRectangle *pRect;
        Data_Get_Struct(rb_ary_entry($input, i), FXRectangle, pRect);
        $1[i] = *pRect;
    }
}

%typemap(freearg) (const FXRectangle* rectangles, FXuint nrectangles) {
    delete [] $1;
}

// Extract a C array (arcs) and its length (narcs) from a Ruby array of FXArc instances
%typemap(in) (const FXArc* arcs, FXuint narcs) {
    Check_Type($input, T_ARRAY);
    $1 = new FXArc[RARRAY_LEN($input)];
    $2 = static_cast<FXuint>( RARRAY_LEN($input) );
    for (FXuint i = 0; i < $2; i++) {
        FXArc *pArc;
        Data_Get_Struct(rb_ary_entry($input, i), FXArc, pArc);
        $1[i] = *pArc;
    }
}

%typemap(freearg) (const FXArc* rectangles, FXuint narcs) {
    delete [] $1;
}

// Extract the C string pointer and string length from a Ruby string
%typemap(in) (const FXchar* string, FXuint length) {
    Check_Type($input, T_STRING);
    $1 = StringValuePtr($input);
    $2 = RSTRING_LEN($input);
}

// Extract a C array (dashpattern) and its length (dashlength) from a Ruby array of Fixnums
%typemap(in) (const FXchar* dashpattern, FXuint dashlength) {
    Check_Type($input, T_ARRAY);
    $1 = new FXchar[RARRAY_LEN($input)];
    $2 = static_cast<FXuint>( RARRAY_LEN($input) );
    for (FXuint i = 0; i < $2; i++) {
        $1[i] = NUM2INT(rb_ary_entry($input, i));
    }
}

%typemap(freearg) (const FXchar* dashpattern, FXuint dashlength) {
    delete [] $1;
}

%typemap(in) (FXuint* path, FXint n) {
  Check_Type($input, T_ARRAY);
  FXMALLOC(&$1,FXuint,RARRAY_LEN($input));
  $2=static_cast<FXint>(RARRAY_LEN($input));
  for(FXint i=0; i<$2; i++){
    $1[i]=NUM2UINT(rb_ary_entry($input,i));
    }
}

%typemap(freearg) (FXuint* path, FXint n) {
  FXFREE(&$1);
}

/* Convert an array of FXColor values (see constructor for FXMemoryBuffer) */
%typemap(in) (FXColor *data,FXuint size) {
  Check_Type($input, T_ARRAY);
  FXMALLOC(&$1,FXColor,RARRAY_LEN($input));
  $2=static_cast<FXuint>(RARRAY_LEN($input));
  for(FXint i=0; i<$2; i++){
    $1[i]=static_cast<FXColor>(NUM2UINT(rb_ary_entry($input,i)));
    }
}

%typemap(freearg) (FXColor *data,FXuint size) {
  FXFREE(&$1);
}

/**
 * Special typemap for the 2nd argument to FXToolBar::dock(). They should
 * be able to pass either zero, -1, or a window to that function and get
 * the same behavior as in FOX.
 */

%typemap(in) FXWindow* TOOLBAR_DOCK_AFTER {
    if (TYPE($input) == T_FIXNUM) {
        $1 = reinterpret_cast<FXWindow *>(static_cast<long>(NUM2INT($input)));
    } else {
        SWIG_ConvertPtr($input, (void **) &$1, SWIGTYPE_p_FXWindow, 1);
    }
}

/* Convert a null-terminated array of FXGLObject pointers to a Ruby array */
%typemap(out) FXGLObject** {
  $result=Qnil;
  if($1){
    $result=rb_ary_new();
    register FXGLObject** p=$1;
    while(*p){
      rb_ary_push($result,to_ruby(*p));
      p++;
      }
    FXFREE(&$1);
    }
}

/* Convert a Ruby Integer to an FXID (int_to_fxid() is defined in FXRuby.h) */
%typemap(in) FXID "$1 = int_to_fxid($input);";

/* Convert an FXID to a Ruby Integer (fxid_to_int() is defined in FXRuby.h) */
%typemap(out) FXID "$result = fxid_to_int($1);";

%typemap(in) FXuchar *data "$1 = NIL_P($input) ? 0 : reinterpret_cast<FXuchar*>(StringValuePtr($input));";

// FXlong values
%typemap(in)  FXlong "$1 = static_cast<FXlong>(NUM2LONG($input));";
%typemap(out) FXlong "$result = LONG2NUM($1);";

// FXulong values
%typemap(in)  FXulong "$1 = static_cast<FXulong>(NUM2ULONG($input));";
%typemap(out) FXulong "$result = ULONG2NUM($1);";