itextomml 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/ext/itex2MML_ruby.c +538 -189
  3. data/ext/y.tab.c +1564 -1431
  4. data/ext/y.tab.h +191 -179
  5. metadata +3 -6
data/ext/itex2MML_ruby.c CHANGED
@@ -1,18 +1,14 @@
1
1
  /* ----------------------------------------------------------------------------
2
- * This file was automatically generated by SWIG (http://www.swig.org).
3
- * Version 3.0.12
2
+ * This file was automatically generated by SWIG (https://www.swig.org).
3
+ * Version 4.4.1
4
4
  *
5
- * This file is not intended to be easily readable and contains a number of
6
- * coding conventions designed to improve portability and efficiency. Do not make
7
- * changes to this file unless you know what you are doing--modify the SWIG
8
- * interface file instead.
5
+ * Do not make changes to this file unless you know what you are doing - modify
6
+ * the SWIG interface file instead.
9
7
  * ----------------------------------------------------------------------------- */
10
8
 
11
9
 
12
- #ifndef SWIGRUBY
10
+ #define SWIG_VERSION 0x040401
13
11
  #define SWIGRUBY
14
- #endif
15
-
16
12
 
17
13
  /* -----------------------------------------------------------------------------
18
14
  * This section contains generic SWIG labels for method/variable
@@ -138,6 +134,40 @@
138
134
  # pragma warning disable 592
139
135
  #endif
140
136
 
137
+ #if defined(__cplusplus) && __cplusplus >=201103L
138
+ # define SWIG_NOEXCEPT noexcept
139
+ #else
140
+ # define SWIG_NOEXCEPT throw()
141
+ #endif
142
+
143
+ /* -----------------------------------------------------------------------------
144
+ * swigcompat.swg
145
+ *
146
+ * Macros to provide support compatibility with older C and C++ standards.
147
+ *
148
+ * Note that SWIG expects __cplusplus to be defined to the appropriate C++ standard.
149
+ * MSVC users are urged to check and examine the /Zc:__cplusplus compiler option.
150
+ * See https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus.
151
+ * ----------------------------------------------------------------------------- */
152
+
153
+ /* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
154
+ * if you're missing it.
155
+ */
156
+ #if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
157
+ (defined __cplusplus && __cplusplus >= 201103L) || \
158
+ defined SWIG_HAVE_SNPRINTF) && \
159
+ !defined SWIG_NO_SNPRINTF
160
+ # define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
161
+ # define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
162
+ #else
163
+ /* Fallback versions ignore the buffer size, but most of our uses either have a
164
+ * fixed maximum possible size or dynamically allocate a buffer that's large
165
+ * enough.
166
+ */
167
+ # define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
168
+ # define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
169
+ #endif
170
+
141
171
  /* -----------------------------------------------------------------------------
142
172
  * This section contains generic SWIG labels for method/variable
143
173
  * declarations/attributes, and other compiler dependent labels.
@@ -262,6 +292,12 @@
262
292
  # pragma warning disable 592
263
293
  #endif
264
294
 
295
+ #if defined(__cplusplus) && __cplusplus >=201103L
296
+ # define SWIG_NOEXCEPT noexcept
297
+ #else
298
+ # define SWIG_NOEXCEPT throw()
299
+ #endif
300
+
265
301
  /* -----------------------------------------------------------------------------
266
302
  * swigrun.swg
267
303
  *
@@ -271,7 +307,7 @@
271
307
 
272
308
  /* This should only be incremented when either the layout of swig_type_info changes,
273
309
  or for whatever reason, the runtime changes incompatibly */
274
- #define SWIG_RUNTIME_VERSION "4"
310
+ #define SWIG_RUNTIME_VERSION "5"
275
311
 
276
312
  /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
277
313
  #ifdef SWIG_TYPE_TABLE
@@ -307,6 +343,9 @@
307
343
  /* Flags for pointer conversions */
308
344
  #define SWIG_POINTER_DISOWN 0x1
309
345
  #define SWIG_CAST_NEW_MEMORY 0x2
346
+ #define SWIG_POINTER_NO_NULL 0x4
347
+ #define SWIG_POINTER_CLEAR 0x8
348
+ #define SWIG_POINTER_RELEASE (SWIG_POINTER_CLEAR | SWIG_POINTER_DISOWN)
310
349
 
311
350
  /* Flags for new pointer objects */
312
351
  #define SWIG_POINTER_OWN 0x1
@@ -378,7 +417,7 @@
378
417
  SWIG errors code.
379
418
 
380
419
  Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
381
- allows to return the 'cast rank', for example, if you have this
420
+ allows returning the 'cast rank', for example, if you have this
382
421
 
383
422
  int food(double)
384
423
  int fooi(int);
@@ -392,7 +431,13 @@
392
431
  */
393
432
 
394
433
  #define SWIG_OK (0)
434
+ /* Runtime errors are < 0 */
395
435
  #define SWIG_ERROR (-1)
436
+ /* Errors in range -1 to -99 are in swigerrors.swg (errors for all languages including those not using the runtime) */
437
+ /* Errors in range -100 to -199 are language specific errors defined in *errors.swg */
438
+ /* Errors < -200 are generic runtime specific errors */
439
+ #define SWIG_ERROR_RELEASE_NOT_OWNED (-200)
440
+
396
441
  #define SWIG_IsOK(r) (r >= 0)
397
442
  #define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
398
443
 
@@ -400,14 +445,14 @@
400
445
  #define SWIG_CASTRANKLIMIT (1 << 8)
401
446
  /* The NewMask denotes the object was created (using new/malloc) */
402
447
  #define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
403
- /* The TmpMask is for in/out typemaps that use temporal objects */
448
+ /* The TmpMask is for in/out typemaps that use temporary objects */
404
449
  #define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
405
450
  /* Simple returning values */
406
451
  #define SWIG_BADOBJ (SWIG_ERROR)
407
452
  #define SWIG_OLDOBJ (SWIG_OK)
408
453
  #define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
409
454
  #define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
410
- /* Check, add and del mask methods */
455
+ /* Check, add and del object mask methods */
411
456
  #define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
412
457
  #define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
413
458
  #define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
@@ -460,8 +505,8 @@ typedef struct swig_type_info {
460
505
  typedef struct swig_cast_info {
461
506
  swig_type_info *type; /* pointer to type that is equivalent to this type */
462
507
  swig_converter_func converter; /* function to cast the void pointers */
463
- struct swig_cast_info *next; /* pointer to next cast in linked list */
464
- struct swig_cast_info *prev; /* pointer to the previous cast */
508
+ struct swig_cast_info *next; /* pointer to next array of casts | pointer to cast hashed by value */
509
+ unsigned int value; /* index of the last valid element in the array | typename hash value */
465
510
  } swig_cast_info;
466
511
 
467
512
  /* Structure used to store module information
@@ -522,55 +567,147 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
522
567
  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
523
568
  }
524
569
 
570
+ /*
571
+ * Hash function for type name strings, based on maRushPrime1Hash (http://amsoftware.narod.ru/algo2.html)
572
+ */
573
+ SWIGRUNTIME unsigned int SWIG_Hash(const char *str, unsigned int len) {
574
+ const unsigned char *data = (const unsigned char *)str;
575
+ unsigned int hash = len, i = 0, k;
576
+ int rem = (int)len;
577
+
578
+ while (rem >= (int)sizeof(unsigned int)) {
579
+ memcpy(&k, data, sizeof(unsigned int));
580
+ k += i++;
581
+ hash ^= k;
582
+ hash *= 171717;
583
+ data += sizeof(unsigned int);
584
+ rem -= sizeof(unsigned int);
585
+ }
586
+
587
+ switch (rem) {
588
+ case 3: k = (unsigned int)(data[2]) << 16;
589
+ k |= (unsigned int)(data[1]) << 8;
590
+ k |= (unsigned int)(data[0]);
591
+ k += i++;
592
+ hash ^= k;
593
+ hash *= 171717;
594
+ break;
595
+ case 2: k = (unsigned int)(data[1]) << 8;
596
+ k |= (unsigned int)(data[0]);
597
+ k += i++;
598
+ hash ^= k;
599
+ hash *= 171717;
600
+ break;
601
+ case 1: k = (unsigned int)(data[0]);
602
+ k += i++;
603
+ hash ^= k;
604
+ hash *= 171717;
605
+ break;
606
+ }
607
+ return hash;
608
+ }
609
+
525
610
  /*
526
611
  Check the typename
527
612
  */
528
613
  SWIGRUNTIME swig_cast_info *
529
614
  SWIG_TypeCheck(const char *c, swig_type_info *ty) {
615
+ static const unsigned int scan_threshold = 4;
530
616
  if (ty) {
531
- swig_cast_info *iter = ty->cast;
532
- while (iter) {
533
- if (strcmp(iter->type->name, c) == 0) {
534
- if (iter == ty->cast)
535
- return iter;
536
- /* Move iter to the top of the linked list */
537
- iter->prev->next = iter->next;
538
- if (iter->next)
539
- iter->next->prev = iter->prev;
540
- iter->next = ty->cast;
541
- iter->prev = 0;
542
- if (ty->cast) ty->cast->prev = iter;
543
- ty->cast = iter;
544
- return iter;
617
+ swig_cast_info *head = ty->cast;
618
+ unsigned int hash_value = 0;
619
+ int hashed = 0;
620
+
621
+ while (head) {
622
+
623
+ if (strcmp(head->type->name, c) == 0) {
624
+ return head;
545
625
  }
546
- iter = iter->next;
626
+
627
+ if (head->value) {
628
+ swig_cast_info *iter;
629
+ swig_cast_info *last = head + head->value;
630
+ swig_cast_info *first = head + 1;
631
+ int search = 1;
632
+
633
+ if (!hashed) {
634
+ if (head->value < scan_threshold) {
635
+ for (iter = first; iter <= last; iter++) {
636
+ if (strcmp(iter->type->name, c) == 0) {
637
+ return iter;
638
+ }
639
+ }
640
+ search = 0;
641
+ } else {
642
+ hashed = 1;
643
+ hash_value = SWIG_Hash(c, (unsigned int)strlen(c));
644
+ }
645
+ }
646
+
647
+ if (search) {
648
+ /* Binary search over sorted <'next'|'value'> pairs */
649
+ do {
650
+ iter = first + ((last - first) >> 1);
651
+ if (iter->value < hash_value) {
652
+ first = iter + 1;
653
+ } else if (iter->value == hash_value) {
654
+
655
+ if (strcmp(iter->next->type->name, c) == 0) {
656
+ return iter->next;
657
+ }
658
+
659
+ /* Hash collision check */
660
+ for (last = iter + 1; last->next && last->value == hash_value; last++) {
661
+ if (strcmp(last->next->type->name, c) == 0) {
662
+ return last->next;
663
+ }
664
+ }
665
+ for (first = iter - 1; first != head && first->value == hash_value; first--) {
666
+ if (strcmp(first->next->type->name, c) == 0) {
667
+ return first->next;
668
+ }
669
+ }
670
+ break;
671
+ } else
672
+ last = iter - 1;
673
+ } while (first <= last);
674
+ }
675
+ }
676
+ head = head->next;
547
677
  }
548
678
  }
549
679
  return 0;
550
680
  }
551
681
 
552
682
  /*
553
- Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
683
+ Check the type by type address
554
684
  */
555
685
  SWIGRUNTIME swig_cast_info *
556
- SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
686
+ SWIG_TypeCheckStruct(const swig_type_info *from, swig_type_info *ty) {
557
687
  if (ty) {
558
- swig_cast_info *iter = ty->cast;
559
- while (iter) {
560
- if (iter->type == from) {
561
- if (iter == ty->cast)
562
- return iter;
563
- /* Move iter to the top of the linked list */
564
- iter->prev->next = iter->next;
565
- if (iter->next)
566
- iter->next->prev = iter->prev;
567
- iter->next = ty->cast;
568
- iter->prev = 0;
569
- if (ty->cast) ty->cast->prev = iter;
570
- ty->cast = iter;
571
- return iter;
688
+ swig_cast_info *head = ty->cast;
689
+ while (head) {
690
+ if (head->type == from) {
691
+ return head;
572
692
  }
573
- iter = iter->next;
693
+
694
+ if (head->value) {
695
+ swig_cast_info *iter;
696
+ swig_cast_info *last = head + head->value;
697
+ swig_cast_info *first = head + 1;
698
+
699
+ /* Binary search over sorted array of casts */
700
+ do {
701
+ iter = first + ((last - first) >> 1);
702
+ if (iter->type < from) {
703
+ first = iter + 1;
704
+ } else if (iter->type == from) {
705
+ return iter;
706
+ } else
707
+ last = iter - 1;
708
+ } while (first <= last);
709
+ }
710
+ head = head->next;
574
711
  }
575
712
  }
576
713
  return 0;
@@ -613,9 +750,9 @@ SWIG_TypeName(const swig_type_info *ty) {
613
750
  SWIGRUNTIME const char *
614
751
  SWIG_TypePrettyName(const swig_type_info *type) {
615
752
  /* The "str" field contains the equivalent pretty names of the
616
- type, separated by vertical-bar characters. We choose
617
- to print the last name, as it is often (?) the most
618
- specific. */
753
+ type, separated by vertical-bar characters. Choose the last
754
+ name. It should be the most specific; a fully resolved name
755
+ but not necessarily with default template parameters expanded. */
619
756
  if (!type) return NULL;
620
757
  if (type->str != NULL) {
621
758
  const char *last_name = type->str;
@@ -633,20 +770,24 @@ SWIG_TypePrettyName(const swig_type_info *type) {
633
770
  */
634
771
  SWIGRUNTIME void
635
772
  SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
636
- swig_cast_info *cast = ti->cast;
773
+ swig_cast_info *head = ti->cast;
637
774
  /* if (ti->clientdata == clientdata) return; */
638
775
  ti->clientdata = clientdata;
639
776
 
640
- while (cast) {
641
- if (!cast->converter) {
642
- swig_type_info *tc = cast->type;
643
- if (!tc->clientdata) {
644
- SWIG_TypeClientData(tc, clientdata);
777
+ while (head) {
778
+ swig_cast_info *cast;
779
+ for (cast = head; (cast - head) <= head->value; cast++) {
780
+ if (!cast->converter) {
781
+ swig_type_info *tc = cast->type;
782
+ if (!tc->clientdata) {
783
+ SWIG_TypeClientData(tc, clientdata);
784
+ }
645
785
  }
646
786
  }
647
- cast = cast->next;
787
+ head = head->next;
648
788
  }
649
789
  }
790
+
650
791
  SWIGRUNTIME void
651
792
  SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
652
793
  SWIG_TypeClientData(ti, clientdata);
@@ -835,7 +976,7 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
835
976
  }
836
977
  #endif
837
978
 
838
- /* Errors in SWIG */
979
+ /* SWIG Errors applicable to all language modules, values are reserved from -1 to -99 */
839
980
  #define SWIG_UnknownError -1
840
981
  #define SWIG_IOError -2
841
982
  #define SWIG_RuntimeError -3
@@ -851,8 +992,25 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
851
992
  #define SWIG_NullReferenceError -13
852
993
 
853
994
 
995
+ #if __GNUC__ >= 7
996
+ #pragma GCC diagnostic push
997
+ #if defined(__cplusplus)
998
+ #pragma GCC diagnostic ignored "-Wregister"
999
+ #if __GNUC__ >= 10
1000
+ #pragma GCC diagnostic ignored "-Wvolatile"
1001
+ #if __GNUC__ >= 11
1002
+ #pragma GCC diagnostic ignored "-Wdeprecated-enum-enum-conversion"
1003
+ #endif
1004
+ #endif
1005
+ #endif
1006
+ #endif
854
1007
 
855
1008
  #include <ruby.h>
1009
+ #include <ruby/version.h> /* For RUBY_API_VERSION_CODE */
1010
+
1011
+ #if __GNUC__ >= 7
1012
+ #pragma GCC diagnostic pop
1013
+ #endif
856
1014
 
857
1015
  /* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which
858
1016
  * breaks using rb_intern as an lvalue, as SWIG does. We work around this
@@ -945,42 +1103,53 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
945
1103
  #ifndef RSTRUCT_PTR
946
1104
  # define RSTRUCT_PTR(x) RSTRUCT(x)->ptr
947
1105
  #endif
1106
+ #ifndef RTYPEDDATA_P
1107
+ # define RTYPEDDATA_P(x) (TYPE(x) != T_DATA)
1108
+ #endif
948
1109
 
949
1110
 
950
1111
 
951
1112
  /*
952
- * Need to be very careful about how these macros are defined, especially
953
- * when compiling C++ code or C code with an ANSI C compiler.
1113
+ * The following macros are used for providing the correct type of a
1114
+ * function pointer to the Ruby C API.
1115
+ *
1116
+ * Starting with Ruby 2.7 these macros act transparently due to Ruby's moving
1117
+ * moving away from ANYARGS and instead employing strict function signatures.
1118
+ *
1119
+ * Note: In case of C (not C++) the macros are transparent even before
1120
+ * Ruby 2.7 due to the fact that the Ruby C API used function declarators
1121
+ * with empty parentheses, which allows for an unspecified number of
1122
+ * arguments.
1123
+ *
1124
+ * PROTECTFUNC(f) is used for the function pointer argument of the Ruby
1125
+ * C API function rb_protect().
954
1126
  *
955
- * VALUEFUNC(f) is a macro used to typecast a C function that implements
956
- * a Ruby method so that it can be passed as an argument to API functions
957
- * like rb_define_method() and rb_define_singleton_method().
1127
+ * VALUEFUNC(f) is used for the function pointer argument(s) of Ruby C API
1128
+ * functions like rb_define_method() and rb_define_singleton_method().
958
1129
  *
959
- * VOIDFUNC(f) is a macro used to typecast a C function that implements
960
- * either the "mark" or "free" stuff for a Ruby Data object, so that it
961
- * can be passed as an argument to API functions like Data_Wrap_Struct()
1130
+ * VOIDFUNC(f) is used to typecast a C function that implements either
1131
+ * the "mark" or "free" stuff for a Ruby Data object, so that it can be
1132
+ * passed as an argument to Ruby C API functions like Data_Wrap_Struct()
962
1133
  * and Data_Make_Struct().
1134
+ *
1135
+ * SWIG_RUBY_VOID_ANYARGS_FUNC(f) is used for the function pointer
1136
+ * argument(s) of Ruby C API functions like rb_define_virtual_variable().
1137
+ *
1138
+ * SWIG_RUBY_INT_ANYARGS_FUNC(f) is used for the function pointer
1139
+ * argument(s) of Ruby C API functions like st_foreach().
963
1140
  */
964
-
965
- #ifdef __cplusplus
966
- # ifndef RUBY_METHOD_FUNC /* These definitions should work for Ruby 1.4.6 */
967
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
968
- # define VALUEFUNC(f) ((VALUE (*)()) f)
969
- # define VOIDFUNC(f) ((void (*)()) f)
970
- # else
971
- # ifndef ANYARGS /* These definitions should work for Ruby 1.6 */
972
- # define PROTECTFUNC(f) ((VALUE (*)()) f)
973
- # define VALUEFUNC(f) ((VALUE (*)()) f)
974
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
975
- # else /* These definitions should work for Ruby 1.7+ */
976
- # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
977
- # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
978
- # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
979
- # endif
980
- # endif
1141
+ #if defined(__cplusplus) && RUBY_API_VERSION_CODE < 20700
1142
+ # define PROTECTFUNC(f) ((VALUE (*)(VALUE)) f)
1143
+ # define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)
1144
+ # define VOIDFUNC(f) ((RUBY_DATA_FUNC) f)
1145
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) ((void (*)(ANYARGS))(f))
1146
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) ((int (*)(ANYARGS))(f))
981
1147
  #else
1148
+ # define PROTECTFUNC(f) (f)
982
1149
  # define VALUEFUNC(f) (f)
983
1150
  # define VOIDFUNC(f) (f)
1151
+ # define SWIG_RUBY_VOID_ANYARGS_FUNC(f) (f)
1152
+ # define SWIG_RUBY_INT_ANYARGS_FUNC(f) (f)
984
1153
  #endif
985
1154
 
986
1155
  /* Don't use for expressions have side effect */
@@ -1020,15 +1189,12 @@ static VALUE _mSWIG = Qnil;
1020
1189
 
1021
1190
 
1022
1191
  /* Define custom exceptions for errors that do not map to existing Ruby
1023
- exceptions. Note this only works for C++ since a global cannot be
1024
- initialized by a function in C. For C, fallback to rb_eRuntimeError.*/
1192
+ exceptions. */
1025
1193
 
1026
1194
  SWIGINTERN VALUE
1027
1195
  getNullReferenceError(void) {
1028
- static int init = 0;
1029
- static VALUE rb_eNullReferenceError ;
1030
- if (!init) {
1031
- init = 1;
1196
+ static VALUE rb_eNullReferenceError = Qnil;
1197
+ if (rb_eNullReferenceError == Qnil) {
1032
1198
  rb_eNullReferenceError = rb_define_class("NullReferenceError", rb_eRuntimeError);
1033
1199
  }
1034
1200
  return rb_eNullReferenceError;
@@ -1036,10 +1202,8 @@ getNullReferenceError(void) {
1036
1202
 
1037
1203
  SWIGINTERN VALUE
1038
1204
  getObjectPreviouslyDeletedError(void) {
1039
- static int init = 0;
1040
- static VALUE rb_eObjectPreviouslyDeleted ;
1041
- if (!init) {
1042
- init = 1;
1205
+ static VALUE rb_eObjectPreviouslyDeleted = Qnil;
1206
+ if (rb_eObjectPreviouslyDeleted == Qnil) {
1043
1207
  rb_eObjectPreviouslyDeleted = rb_define_class("ObjectPreviouslyDeleted", rb_eRuntimeError);
1044
1208
  }
1045
1209
  return rb_eObjectPreviouslyDeleted;
@@ -1122,7 +1286,7 @@ const char* Ruby_Format_TypeError( const char* msg,
1122
1286
  }
1123
1287
 
1124
1288
  str = rb_str_cat2( str, "Expected argument " );
1125
- sprintf( buf, "%d of type ", argn-1 );
1289
+ SWIG_snprintf( buf, sizeof( buf), "%d of type ", argn-1 );
1126
1290
  str = rb_str_cat2( str, buf );
1127
1291
  str = rb_str_cat2( str, type );
1128
1292
  str = rb_str_cat2( str, ", but got " );
@@ -1168,7 +1332,7 @@ void Ruby_Format_OverloadedError(
1168
1332
  /* -----------------------------------------------------------------------------
1169
1333
  * rubytracking.swg
1170
1334
  *
1171
- * This file contains support for tracking mappings from
1335
+ * This file contains support for tracking mappings from
1172
1336
  * Ruby objects to C++ objects. This functionality is needed
1173
1337
  * to implement mark functions for Ruby's mark and sweep
1174
1338
  * garbage collector.
@@ -1195,11 +1359,11 @@ extern "C" {
1195
1359
  #endif
1196
1360
 
1197
1361
  /* Global hash table to store Trackings from C/C++
1198
- structs to Ruby Objects.
1362
+ structs to Ruby Objects.
1199
1363
  */
1200
1364
  static st_table* swig_ruby_trackings = NULL;
1201
1365
 
1202
- static VALUE swig_ruby_trackings_count(ANYARGS) {
1366
+ static VALUE swig_ruby_trackings_count(ID id, VALUE *var) {
1203
1367
  return SWIG2NUM(swig_ruby_trackings->num_entries);
1204
1368
  }
1205
1369
 
@@ -1209,7 +1373,7 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1209
1373
  /* Create a hash table to store Trackings from C++
1210
1374
  objects to Ruby objects. */
1211
1375
 
1212
- /* Try to see if some other .so has already created a
1376
+ /* Try to see if some other .so has already created a
1213
1377
  tracking hash table, which we keep hidden in an instance var
1214
1378
  in the SWIG module.
1215
1379
  This is done to allow multiple DSOs to share the same
@@ -1236,7 +1400,9 @@ SWIGRUNTIME void SWIG_RubyInitializeTrackings(void) {
1236
1400
  swig_ruby_trackings = (st_table*)NUM2SWIG(trackings_value);
1237
1401
  }
1238
1402
 
1239
- rb_define_virtual_variable("SWIG_TRACKINGS_COUNT", swig_ruby_trackings_count, NULL);
1403
+ rb_define_virtual_variable("SWIG_TRACKINGS_COUNT",
1404
+ VALUEFUNC(swig_ruby_trackings_count),
1405
+ SWIG_RUBY_VOID_ANYARGS_FUNC((rb_gvar_setter_t*)NULL));
1240
1406
  }
1241
1407
 
1242
1408
  /* Add a Tracking from a C/C++ struct to a Ruby object */
@@ -1268,13 +1434,14 @@ SWIGRUNTIME void SWIG_RubyRemoveTracking(void* ptr) {
1268
1434
 
1269
1435
  /* This is a helper method that unlinks a Ruby object from its
1270
1436
  underlying C++ object. This is needed if the lifetime of the
1271
- Ruby object is longer than the C++ object */
1437
+ Ruby object is longer than the C++ object. */
1272
1438
  SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1273
1439
  VALUE object = SWIG_RubyInstanceFor(ptr);
1274
1440
 
1275
1441
  if (object != Qnil) {
1276
- if (TYPE(object) != T_DATA)
1277
- abort();
1442
+ // object might have the T_ZOMBIE type, but that's just
1443
+ // because the GC has flagged it as such for a deferred
1444
+ // destruction. Until then, it's still a T_DATA object.
1278
1445
  DATA_PTR(object) = 0;
1279
1446
  }
1280
1447
  }
@@ -1284,13 +1451,15 @@ SWIGRUNTIME void SWIG_RubyUnlinkObjects(void* ptr) {
1284
1451
  to the passed callback function. */
1285
1452
 
1286
1453
  /* Proxy method to abstract the internal trackings datatype */
1287
- static int swig_ruby_internal_iterate_callback(void* ptr, VALUE obj, void(*meth)(void* ptr, VALUE obj)) {
1288
- (*meth)(ptr, obj);
1454
+ static int swig_ruby_internal_iterate_callback(st_data_t ptr, st_data_t obj, st_data_t meth) {
1455
+ ((void (*) (void *, VALUE))meth)((void *)ptr, (VALUE)obj);
1289
1456
  return ST_CONTINUE;
1290
1457
  }
1291
1458
 
1292
1459
  SWIGRUNTIME void SWIG_RubyIterateTrackings( void(*meth)(void* ptr, VALUE obj) ) {
1293
- st_foreach(swig_ruby_trackings, (int (*)(ANYARGS))&swig_ruby_internal_iterate_callback, (st_data_t)meth);
1460
+ st_foreach(swig_ruby_trackings,
1461
+ SWIG_RUBY_INT_ANYARGS_FUNC(swig_ruby_internal_iterate_callback),
1462
+ (st_data_t)meth);
1294
1463
  }
1295
1464
 
1296
1465
  #ifdef __cplusplus
@@ -1306,8 +1475,8 @@ extern "C" {
1306
1475
  #endif
1307
1476
 
1308
1477
  SWIGINTERN VALUE
1309
- SWIG_Ruby_AppendOutput(VALUE target, VALUE o) {
1310
- if (NIL_P(target)) {
1478
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o, int is_void) {
1479
+ if (NIL_P(target) && is_void) {
1311
1480
  target = o;
1312
1481
  } else {
1313
1482
  if (TYPE(target) != T_ARRAY) {
@@ -1416,6 +1585,7 @@ static VALUE swig_runtime_data_type_pointer = Qnil;
1416
1585
  /* Global IDs used to keep some internal SWIG stuff */
1417
1586
  static ID swig_arity_id = 0;
1418
1587
  static ID swig_call_id = 0;
1588
+ static ID swig_lowerthan_id = 0;
1419
1589
 
1420
1590
  /*
1421
1591
  If your swig extension is to be run within an embedded ruby and has
@@ -1449,10 +1619,8 @@ static ID swig_call_id = 0;
1449
1619
 
1450
1620
  SWIGRUNTIME VALUE
1451
1621
  getExceptionClass(void) {
1452
- static int init = 0;
1453
- static VALUE rubyExceptionClass ;
1454
- if (!init) {
1455
- init = 1;
1622
+ static VALUE rubyExceptionClass = Qnil;
1623
+ if (rubyExceptionClass == Qnil) {
1456
1624
  rubyExceptionClass = rb_const_get(_mSWIG, rb_intern("Exception"));
1457
1625
  }
1458
1626
  return rubyExceptionClass;
@@ -1467,7 +1635,7 @@ SWIG_Ruby_ExceptionType(swig_type_info *desc, VALUE obj) {
1467
1635
  VALUE exceptionClass = getExceptionClass();
1468
1636
  if (rb_obj_is_kind_of(obj, exceptionClass)) {
1469
1637
  return obj;
1470
- } else {
1638
+ } else {
1471
1639
  return rb_exc_new3(rb_eRuntimeError, rb_obj_as_string(obj));
1472
1640
  }
1473
1641
  }
@@ -1480,6 +1648,7 @@ SWIG_Ruby_InitRuntime(void)
1480
1648
  _mSWIG = rb_define_module("SWIG");
1481
1649
  swig_call_id = rb_intern("call");
1482
1650
  swig_arity_id = rb_intern("arity");
1651
+ swig_lowerthan_id = rb_intern("<");
1483
1652
  }
1484
1653
  }
1485
1654
 
@@ -1487,13 +1656,14 @@ SWIG_Ruby_InitRuntime(void)
1487
1656
  SWIGRUNTIME void
1488
1657
  SWIG_Ruby_define_class(swig_type_info *type)
1489
1658
  {
1490
- char *klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1491
- sprintf(klass_name, "TYPE%s", type->name);
1659
+ size_t klass_len = 4 + strlen(type->name) + 1;
1660
+ char *klass_name = (char *) malloc(klass_len);
1661
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
1492
1662
  if (NIL_P(_cSWIG_Pointer)) {
1493
1663
  _cSWIG_Pointer = rb_define_class_under(_mSWIG, "Pointer", rb_cObject);
1494
1664
  rb_undef_method(CLASS_OF(_cSWIG_Pointer), "new");
1495
1665
  }
1496
- rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer);
1666
+ rb_undef_alloc_func(rb_define_class_under(_mSWIG, klass_name, _cSWIG_Pointer));
1497
1667
  free((void *) klass_name);
1498
1668
  }
1499
1669
 
@@ -1507,10 +1677,11 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1507
1677
  swig_class *sklass;
1508
1678
  VALUE klass;
1509
1679
  VALUE obj;
1510
-
1680
+
1511
1681
  if (!ptr)
1512
1682
  return Qnil;
1513
-
1683
+
1684
+ assert(type);
1514
1685
  if (type->clientdata) {
1515
1686
  sklass = (swig_class *) type->clientdata;
1516
1687
 
@@ -1518,7 +1689,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1518
1689
  track = sklass->trackObjects;
1519
1690
  if (track) {
1520
1691
  obj = SWIG_RubyInstanceFor(ptr);
1521
-
1692
+
1522
1693
  /* Check the object's type and make sure it has the correct type.
1523
1694
  It might not in cases where methods do things like
1524
1695
  downcast methods. */
@@ -1543,14 +1714,15 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags)
1543
1714
  SWIG_RubyAddTracking(ptr, obj);
1544
1715
  }
1545
1716
  } else {
1546
- klass_name = (char *) malloc(4 + strlen(type->name) + 1);
1547
- sprintf(klass_name, "TYPE%s", type->name);
1717
+ size_t klass_len = 4 + strlen(type->name) + 1;
1718
+ klass_name = (char *) malloc(klass_len);
1719
+ SWIG_snprintf(klass_name, klass_len, "TYPE%s", type->name);
1548
1720
  klass = rb_const_get(_mSWIG, rb_intern(klass_name));
1549
1721
  free((void *) klass_name);
1550
1722
  obj = Data_Wrap_Struct(klass, 0, 0, ptr);
1551
1723
  }
1552
1724
  rb_iv_set(obj, "@__swigtype__", rb_str_new2(type->name));
1553
-
1725
+
1554
1726
  return obj;
1555
1727
  }
1556
1728
 
@@ -1570,6 +1742,8 @@ SWIGRUNTIMEINLINE char *
1570
1742
  SWIG_Ruby_MangleStr(VALUE obj)
1571
1743
  {
1572
1744
  VALUE stype = rb_iv_get(obj, "@__swigtype__");
1745
+ if (NIL_P(stype))
1746
+ return NULL;
1573
1747
  return StringValuePtr(stype);
1574
1748
  }
1575
1749
 
@@ -1582,7 +1756,7 @@ typedef struct {
1582
1756
  SWIGRUNTIME swig_ruby_owntype
1583
1757
  SWIG_Ruby_AcquirePtr(VALUE obj, swig_ruby_owntype own) {
1584
1758
  swig_ruby_owntype oldown = {0, 0};
1585
- if (obj) {
1759
+ if (TYPE(obj) == T_DATA && !RTYPEDDATA_P(obj)) {
1586
1760
  oldown.datafree = RDATA(obj)->dfree;
1587
1761
  RDATA(obj)->dfree = own.datafree;
1588
1762
  }
@@ -1601,9 +1775,9 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1601
1775
  if (NIL_P(obj)) {
1602
1776
  if (ptr)
1603
1777
  *ptr = 0;
1604
- return SWIG_OK;
1778
+ return (flags & SWIG_POINTER_NO_NULL) ? SWIG_NullReferenceError : SWIG_OK;
1605
1779
  } else {
1606
- if (TYPE(obj) != T_DATA) {
1780
+ if (TYPE(obj) != T_DATA || (TYPE(obj) == T_DATA && RTYPEDDATA_P(obj))) {
1607
1781
  return SWIG_ERROR;
1608
1782
  }
1609
1783
  Data_Get_Struct(obj, void, vptr);
@@ -1614,6 +1788,11 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1614
1788
  own->own = 0;
1615
1789
  }
1616
1790
 
1791
+ if (((flags & SWIG_POINTER_RELEASE) == SWIG_POINTER_RELEASE)) {
1792
+ if (!RDATA(obj)->dfree)
1793
+ return SWIG_ERROR_RELEASE_NOT_OWNED;
1794
+ }
1795
+
1617
1796
  /* Check to see if the input object is giving up ownership
1618
1797
  of the underlying C struct or C++ object. If so then we
1619
1798
  need to reset the destructor since the Ruby object no
@@ -1625,7 +1804,7 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1625
1804
  swig_class *sklass = (swig_class *) ty->clientdata;
1626
1805
  track = sklass->trackObjects;
1627
1806
  }
1628
-
1807
+
1629
1808
  if (track) {
1630
1809
  /* We are tracking objects for this class. Thus we change the destructor
1631
1810
  * to SWIG_RubyRemoveTracking. This allows us to
@@ -1639,6 +1818,10 @@ SWIG_Ruby_ConvertPtrAndOwn(VALUE obj, void **ptr, swig_type_info *ty, int flags,
1639
1818
  }
1640
1819
  }
1641
1820
 
1821
+ if (flags & SWIG_POINTER_CLEAR) {
1822
+ DATA_PTR(obj) = 0;
1823
+ }
1824
+
1642
1825
  /* Do type-checking if type info was provided */
1643
1826
  if (ty) {
1644
1827
  if (ty->clientdata) {
@@ -1698,7 +1881,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
1698
1881
  return rb_str_new2(result);
1699
1882
  }
1700
1883
 
1701
- /* Convert a packed value value */
1884
+ /* Convert a packed pointer value */
1702
1885
  SWIGRUNTIME int
1703
1886
  SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty) {
1704
1887
  swig_cast_info *tc;
@@ -1745,7 +1928,8 @@ SWIGRUNTIME void
1745
1928
  SWIG_Ruby_SetModule(swig_module_info *pointer)
1746
1929
  {
1747
1930
  /* register a new class */
1748
- VALUE cl = rb_define_class("Swig_runtime_data", rb_cObject);
1931
+ VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
1932
+ rb_undef_alloc_func(cl);
1749
1933
  /* create and store the structure pointer to a global variable */
1750
1934
  swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
1751
1935
  rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
@@ -1776,7 +1960,7 @@ int SWIG_Ruby_arity( VALUE proc, int minimal )
1776
1960
  {
1777
1961
  if ( rb_respond_to( proc, swig_arity_id ) )
1778
1962
  {
1779
- VALUE num = rb_funcall( proc, swig_arity_id, 0 );
1963
+ VALUE num = rb_funcall2( proc, swig_arity_id, 0, 0 );
1780
1964
  int arity = NUM2INT(num);
1781
1965
  if ( arity < 0 && (arity+1) < -minimal ) return 1;
1782
1966
  if ( arity == minimal ) return 1;
@@ -1794,7 +1978,7 @@ int SWIG_Ruby_arity( VALUE proc, int minimal )
1794
1978
 
1795
1979
  #define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
1796
1980
 
1797
- #define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
1981
+ #define SWIG_contract_assert(expr, msg) do { if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } } while (0)
1798
1982
 
1799
1983
 
1800
1984
 
@@ -1817,10 +2001,6 @@ static VALUE mItex2MML;
1817
2001
  #define SWIG_RUBY_THREAD_END_BLOCK
1818
2002
 
1819
2003
 
1820
- #define SWIGVERSION 0x030012
1821
- #define SWIG_VERSION SWIGVERSION
1822
-
1823
-
1824
2004
  #define SWIG_as_voidptr(a) (void *)((const void *)(a))
1825
2005
  #define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
1826
2006
 
@@ -1832,11 +2012,9 @@ extern const char * itex2MML_output ();
1832
2012
  SWIGINTERN swig_type_info*
1833
2013
  SWIG_pchar_descriptor(void)
1834
2014
  {
1835
- static int init = 0;
1836
2015
  static swig_type_info* info = 0;
1837
- if (!init) {
2016
+ if (!info) {
1838
2017
  info = SWIG_TypeQuery("_p_char");
1839
- init = 1;
1840
2018
  }
1841
2019
  return info;
1842
2020
  }
@@ -1880,22 +2058,21 @@ SWIG_AsCharPtrAndSize(VALUE obj, char** cptr, size_t* psize, int *alloc)
1880
2058
 
1881
2059
 
1882
2060
  SWIGINTERN VALUE
1883
- SWIG_ruby_failed(void)
2061
+ SWIG_ruby_failed(VALUE SWIGUNUSEDPARM(arg1), VALUE SWIGUNUSEDPARM(arg2))
1884
2062
  {
1885
2063
  return Qnil;
1886
2064
  }
1887
2065
 
1888
2066
 
1889
- /*@SWIG:/sw/share/swig/3.0.12/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1890
- SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE *args)
2067
+ SWIGINTERN VALUE SWIG_AUX_NUM2ULONG(VALUE arg)
1891
2068
  {
2069
+ VALUE *args = (VALUE *)arg;
1892
2070
  VALUE obj = args[0];
1893
2071
  VALUE type = TYPE(obj);
1894
2072
  unsigned long *res = (unsigned long *)(args[1]);
1895
2073
  *res = type == T_FIXNUM ? NUM2ULONG(obj) : rb_big2ulong(obj);
1896
2074
  return obj;
1897
2075
  }
1898
- /*@SWIG@*/
1899
2076
 
1900
2077
  SWIGINTERN int
1901
2078
  SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
@@ -1906,7 +2083,9 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
1906
2083
  VALUE a[2];
1907
2084
  a[0] = obj;
1908
2085
  a[1] = (VALUE)(&v);
1909
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
2086
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULONG), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
2087
+ if (rb_funcall(obj, swig_lowerthan_id, 1, INT2FIX(0)) != Qfalse)
2088
+ return SWIG_OverflowError;
1910
2089
  if (val) *val = v;
1911
2090
  return SWIG_OK;
1912
2091
  }
@@ -1931,16 +2110,15 @@ SWIG_AsVal_unsigned_SS_long (VALUE obj, unsigned long *val)
1931
2110
 
1932
2111
 
1933
2112
  #ifdef SWIG_LONG_LONG_AVAILABLE
1934
- /*@SWIG:/sw/share/swig/3.0.12/ruby/rubyprimtypes.swg,19,%ruby_aux_method@*/
1935
- SWIGINTERN VALUE SWIG_AUX_NUM2ULL(VALUE *args)
2113
+ SWIGINTERN VALUE SWIG_AUX_NUM2ULL(VALUE arg)
1936
2114
  {
2115
+ VALUE *args = (VALUE *)arg;
1937
2116
  VALUE obj = args[0];
1938
2117
  VALUE type = TYPE(obj);
1939
2118
  long long *res = (long long *)(args[1]);
1940
2119
  *res = type == T_FIXNUM ? NUM2ULL(obj) : rb_big2ull(obj);
1941
2120
  return obj;
1942
2121
  }
1943
- /*@SWIG@*/
1944
2122
 
1945
2123
  SWIGINTERN int
1946
2124
  SWIG_AsVal_unsigned_SS_long_SS_long (VALUE obj, unsigned long long *val)
@@ -1951,7 +2129,9 @@ SWIG_AsVal_unsigned_SS_long_SS_long (VALUE obj, unsigned long long *val)
1951
2129
  VALUE a[2];
1952
2130
  a[0] = obj;
1953
2131
  a[1] = (VALUE)(&v);
1954
- if (rb_rescue(RUBY_METHOD_FUNC(SWIG_AUX_NUM2ULL), (VALUE)a, RUBY_METHOD_FUNC(SWIG_ruby_failed), 0) != Qnil) {
2132
+ if (rb_rescue(VALUEFUNC(SWIG_AUX_NUM2ULL), (VALUE)a, VALUEFUNC(SWIG_ruby_failed), 0) != Qnil) {
2133
+ if (rb_funcall(obj, swig_lowerthan_id, 1, INT2FIX(0)) != Qfalse)
2134
+ return SWIG_OverflowError;
1955
2135
  if (val) *val = v;
1956
2136
  return SWIG_OK;
1957
2137
  }
@@ -2017,7 +2197,7 @@ SWIG_FromCharPtr(const char *cptr)
2017
2197
 
2018
2198
  SWIGINTERN VALUE
2019
2199
  _wrap_itex2MML_filter(int argc, VALUE *argv, VALUE self) {
2020
- char *arg1 = (char *) 0 ;
2200
+ char *arg1 = 0 ;
2021
2201
  size_t arg2 ;
2022
2202
  int res1 ;
2023
2203
  char *buf1 = 0 ;
@@ -2052,7 +2232,7 @@ fail:
2052
2232
 
2053
2233
  SWIGINTERN VALUE
2054
2234
  _wrap_itex2MML_html_filter(int argc, VALUE *argv, VALUE self) {
2055
- char *arg1 = (char *) 0 ;
2235
+ char *arg1 = 0 ;
2056
2236
  size_t arg2 ;
2057
2237
  int res1 ;
2058
2238
  char *buf1 = 0 ;
@@ -2121,7 +2301,7 @@ static swig_cast_info *swig_cast_initial[] = {
2121
2301
 
2122
2302
  /* -----------------------------------------------------------------------------
2123
2303
  * Type initialization:
2124
- * This problem is tough by the requirement that no dynamic
2304
+ * This problem is made tough by the requirement that no dynamic
2125
2305
  * memory is used. Also, since swig_type_info structures store pointers to
2126
2306
  * swig_cast_info structures and swig_cast_info structures store pointers back
2127
2307
  * to swig_type_info structures, we need some lookup code at initialization.
@@ -2136,15 +2316,20 @@ static swig_cast_info *swig_cast_initial[] = {
2136
2316
  * array. We just loop through that array, and handle each type individually.
2137
2317
  * First we lookup if this type has been already loaded, and if so, use the
2138
2318
  * loaded structure instead of the generated one. Then we have to fill in the
2139
- * cast linked list. The cast data is initially stored in something like a
2319
+ * cast dependencies. The cast data is initially stored in something like a
2140
2320
  * two-dimensional array. Each row corresponds to a type (there are the same
2141
2321
  * number of rows as there are in the swig_type_initial array). Each entry in
2142
2322
  * a column is one of the swig_cast_info structures for that type.
2143
2323
  * The cast_initial array is actually an array of arrays, because each row has
2144
- * a variable number of columns. So to actually build the cast linked list,
2145
- * we find the array of casts associated with the type, and loop through it
2146
- * adding the casts to the list. The one last trick we need to do is making
2147
- * sure the type pointer in the swig_cast_info struct is correct.
2324
+ * a variable number of columns.
2325
+ *
2326
+ * We loop through the cast[] array associated with the type and mark casts
2327
+ * which have not been defined in previously loaded modules by assigning
2328
+ * cast pointer value to cast->next. We also hash cast->type->name string
2329
+ * and store the value in the cast->value field. If we encounter swig_cast_info
2330
+ * structure that represents a cast to self we move it to the beginning
2331
+ * of the cast array. One trick we need to do is making sure the type pointer
2332
+ * in the swig_cast_info struct is correct.
2148
2333
  *
2149
2334
  * First off, we lookup the cast->type name to see if it is already loaded.
2150
2335
  * There are three cases to handle:
@@ -2156,8 +2341,71 @@ static swig_cast_info *swig_cast_initial[] = {
2156
2341
  * cast->type) are loaded, THEN the cast info has already been loaded by
2157
2342
  * the previous module so we just ignore it.
2158
2343
  * 3) Finally, if cast->type has not already been loaded, then we add that
2159
- * swig_cast_info to the linked list (because the cast->type) pointer will
2344
+ * swig_cast_info to the list (because the cast->type) pointer will
2160
2345
  * be correct.
2346
+ *
2347
+ * Once the cast array has been set up AND it does have new casts that need
2348
+ * to be added we sort non-self cast entries to move filtered out entries
2349
+ * to the end of the array and to arrange the rest in the increasing order
2350
+ * of their type pointer values. We store the index of the last added entry
2351
+ * in the cast->value field of the entry[0] (overwriting the name hash). Then
2352
+ * we sort <next|value> fields of the remaining entries to arrange hash values
2353
+ * in the increasing order. This way cast->next->type->name field matches
2354
+ * the cast->value hash.
2355
+ *
2356
+ * Example:
2357
+ * Array of casts for type stored at 0x5000, cast to type stored at 0x3000
2358
+ * has already been loaded
2359
+ *
2360
+ * After sweep-and-hash: After sort-by-type: After sort-by-hash:
2361
+ * ________________ ________________ ________________
2362
+ * | | | | | |
2363
+ * Entry | type = 0x5000 | | type = 0x5000 | | type = 0x5000 |
2364
+ * 0 | | | | | |
2365
+ * | next = Entry0 | | next = Entry0 | | next = Entry0 |
2366
+ * | value = 1212 | | value = 3 | | value = 3 |
2367
+ * | | | | | |
2368
+ * |================| |================| |================|
2369
+ * | | | | | |
2370
+ * Entry | type = 0x2000 | | type = 0x1000 | | type = 0x1000 |
2371
+ * 1 | | | | | |
2372
+ * | next = Entry1 | | next = Entry1 | | next = Entry3 |
2373
+ * | value = 3434 | | value = 4545 | | value = 2323 |
2374
+ * |________________| |________________| |________________|
2375
+ * | | | | | |
2376
+ * Entry | type = 0x3000 | | type = 0x2000 | | type = 0x2000 |
2377
+ * 2 | | | | | |
2378
+ * | next = 0 | | next = Entry2 | | next = Entry2 |
2379
+ * | value = 0 | | value = 3434 | | value = 3434 |
2380
+ * |________________| |________________| |________________|
2381
+ * | | | | | |
2382
+ * Entry | type = 0x1000 | | type = 0x4000 | | type = 0x4000 |
2383
+ * 3 | | | | | |
2384
+ * | next = Entry3 | | next = Entry3 | | next = Entry1 |
2385
+ * | value = 4545 | | value = 2323 | | value = 4545 |
2386
+ * |________________| |________________| |________________|
2387
+ * | | | | | |
2388
+ * Entry | type = 0x4000 | | type = 0x3000 | | type = 0x3000 |
2389
+ * 4 | | | | | |
2390
+ * | next = Entry4 | | next = 0 | | next = 0 |
2391
+ * | value = 2323 | | value = 0 | | value = 0 |
2392
+ * |________________| |________________| |________________|
2393
+ *
2394
+ * Once the cast array has been initialized, we use cast[0]->next field to link
2395
+ * it into the list of cast arrays for the type.
2396
+ * ____ ____ ____
2397
+ * type->cast->|next|->|next|->|next|->0
2398
+ * |----| |----| |----|
2399
+ * |----| |----| |----|
2400
+ * |----| |----| |----|
2401
+ *
2402
+ * Subsequent cast resolution works as follows:
2403
+ *
2404
+ * 1. Check whether the type matches the first entry in the current cast array.
2405
+ * 2. If not, then do a binary search over the (0:cast->value] interval using
2406
+ * either type address or the hash value of the type name.
2407
+ * 3. If not found, then move over to the next cast array (cast[0]->next).
2408
+ *
2161
2409
  * ----------------------------------------------------------------------------- */
2162
2410
 
2163
2411
  #ifdef __cplusplus
@@ -2171,9 +2419,52 @@ extern "C" {
2171
2419
  #define SWIGRUNTIME_DEBUG
2172
2420
  #endif
2173
2421
 
2422
+ #ifndef SWIG_INIT_CLIENT_DATA_TYPE
2423
+ #define SWIG_INIT_CLIENT_DATA_TYPE void *
2424
+ #endif
2425
+
2426
+ /*
2427
+ * Sort function that puts cast entries with nonzero 'next' at the front
2428
+ * of the array while ordering them by addresses of their 'type' structs.
2429
+ */
2430
+ SWIGINTERN int SWIG_CastCmpStruct(const void *pa, const void *pb) {
2431
+ swig_cast_info *pca = (swig_cast_info *)pa;
2432
+ swig_cast_info *pcb = (swig_cast_info *)pb;
2433
+ if (pca->type < pcb->type)
2434
+ return (pca->next || pcb->next == 0) ? -1 : 1;
2435
+ if (pca->type > pcb->type)
2436
+ return (pcb->next || pca->next == 0) ? 1 : -1;
2437
+ return 0;
2438
+ }
2439
+
2440
+ /*
2441
+ * Shell-sort 'next' and 'value' field pairs to order them by 'value'.
2442
+ */
2443
+ SWIGINTERN void SWIG_CastHashSort(swig_cast_info *cast, int size) {
2444
+ const int hmax = size/9;
2445
+ int h, i;
2446
+ for(h = 1; h <= hmax; h = 3*h+1);
2447
+ for(; h > 0; h /= 3)
2448
+ {
2449
+ for(i = h; i < size; ++i)
2450
+ {
2451
+ swig_cast_info *p = cast[i].next;
2452
+ unsigned int hash = cast[i].value;
2453
+ int j = i;
2454
+ while(j >= h && hash < cast[j-h].value)
2455
+ {
2456
+ cast[j].next = cast[j-h].next;
2457
+ cast[j].value = cast[j-h].value;
2458
+ j -= h;
2459
+ }
2460
+ cast[j].next = p;
2461
+ cast[j].value = hash;
2462
+ }
2463
+ }
2464
+ }
2174
2465
 
2175
2466
  SWIGRUNTIME void
2176
- SWIG_InitializeModule(void *clientdata) {
2467
+ SWIG_InitializeModule(SWIG_INIT_CLIENT_DATA_TYPE clientdata) {
2177
2468
  size_t i;
2178
2469
  swig_module_info *module_head, *iter;
2179
2470
  int init;
@@ -2219,15 +2510,16 @@ SWIG_InitializeModule(void *clientdata) {
2219
2510
 
2220
2511
  /* Now work on filling in swig_module.types */
2221
2512
  #ifdef SWIGRUNTIME_DEBUG
2222
- printf("SWIG_InitializeModule: size %d\n", swig_module.size);
2513
+ printf("SWIG_InitializeModule: size %lu\n", (unsigned long)swig_module.size);
2223
2514
  #endif
2224
2515
  for (i = 0; i < swig_module.size; ++i) {
2225
2516
  swig_type_info *type = 0;
2226
- swig_type_info *ret;
2227
- swig_cast_info *cast;
2517
+ swig_type_info *target_type;
2518
+ swig_cast_info *cast, *first;
2519
+ int num_mapped = 0;
2228
2520
 
2229
2521
  #ifdef SWIGRUNTIME_DEBUG
2230
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2522
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
2231
2523
  #endif
2232
2524
 
2233
2525
  /* if there is another module already loaded */
@@ -2250,49 +2542,104 @@ SWIG_InitializeModule(void *clientdata) {
2250
2542
  }
2251
2543
 
2252
2544
  /* Insert casting types */
2253
- cast = swig_module.cast_initial[i];
2545
+ cast = first = swig_module.cast_initial[i];
2254
2546
  while (cast->type) {
2255
2547
 
2256
2548
  /* Don't need to add information already in the list */
2257
- ret = 0;
2549
+ target_type = 0;
2258
2550
  #ifdef SWIGRUNTIME_DEBUG
2259
2551
  printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
2260
2552
  #endif
2261
2553
  if (swig_module.next != &swig_module) {
2262
- ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
2554
+ target_type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
2555
+ if (target_type) {
2556
+
2557
+ /* Target type already defined in another module */
2263
2558
  #ifdef SWIGRUNTIME_DEBUG
2264
- if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
2559
+ printf("SWIG_InitializeModule: found cast %s\n", target_type->name);
2265
2560
  #endif
2266
- }
2267
- if (ret) {
2268
- if (type == swig_module.type_initial[i]) {
2561
+ if (type == swig_module.type_initial[i]) {
2269
2562
  #ifdef SWIGRUNTIME_DEBUG
2270
- printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
2563
+ printf("SWIG_InitializeModule: skip old type %s\n", target_type->name);
2271
2564
  #endif
2272
- cast->type = ret;
2273
- ret = 0;
2274
- } else {
2275
- /* Check for casting already in the list */
2276
- swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
2565
+ cast->type = target_type;
2566
+ target_type = 0;
2567
+ } else {
2568
+ /* Check if this cast is already in the list */
2569
+ swig_cast_info *ocast = SWIG_TypeCheck(target_type->name, type);
2277
2570
  #ifdef SWIGRUNTIME_DEBUG
2278
- if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
2571
+ if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", target_type->name);
2279
2572
  #endif
2280
- if (!ocast) ret = 0;
2281
- }
2573
+ if (!ocast) target_type = 0;
2574
+ }
2575
+ }
2282
2576
  }
2283
2577
 
2284
- if (!ret) {
2578
+ if (!target_type) {
2579
+ #ifdef SWIGRUNTIME_DEBUG
2580
+ printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
2581
+ #endif
2582
+ /* Set inclusion mark for sorting */
2583
+ cast->next = cast;
2584
+ num_mapped++;
2585
+
2586
+ if (type == cast->type) {
2285
2587
  #ifdef SWIGRUNTIME_DEBUG
2286
- printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
2588
+ printf("%s : self cast at pos [%li]\n", type->name, cast - first);
2287
2589
  #endif
2288
- if (type->cast) {
2289
- type->cast->prev = cast;
2290
- cast->next = type->cast;
2590
+ if (cast - first) {
2591
+
2592
+ /* Move cast to itself to the first entry in the array */
2593
+
2594
+ swig_cast_info tmp = *cast;
2595
+ *cast = *first;
2596
+ *first = tmp;
2597
+ }
2598
+ first++;
2599
+
2600
+ } else {
2601
+ cast->value = SWIG_Hash(cast->type->name, (unsigned int)strlen(cast->type->name));
2291
2602
  }
2292
- type->cast = cast;
2293
2603
  }
2294
2604
  cast++;
2295
2605
  }
2606
+
2607
+ if (num_mapped) {
2608
+ if (cast - first) {
2609
+ swig_cast_info *tmp;
2610
+
2611
+ /* Sort casts by type address for binary search in SWIG_TypeCheckStruct */
2612
+ qsort(first, cast - first, sizeof(swig_cast_info), SWIG_CastCmpStruct);
2613
+
2614
+ /* Remap back links for added entries */
2615
+ cast = swig_module.cast_initial[i] + num_mapped;
2616
+ for (tmp = first; tmp < cast; tmp++) {
2617
+ tmp->next = tmp;
2618
+ }
2619
+ }
2620
+
2621
+ /* Set the value field of the first entry to the index of the last added entry */
2622
+ cast = swig_module.cast_initial[i];
2623
+ cast->value = num_mapped - 1;
2624
+
2625
+ num_mapped -= (int)(first - cast);
2626
+ if (num_mapped > 1) {
2627
+ /* Sort <'next','value'> pairs by 'value' for binary search in SWIG_TypeCheck */
2628
+
2629
+ SWIG_CastHashSort(first, num_mapped);
2630
+ }
2631
+
2632
+ first = type->cast;
2633
+ if (first) {
2634
+ /* Link the current set into the list of cast arrays */
2635
+ cast->next = first->next;
2636
+ first->next = cast;
2637
+ } else {
2638
+ cast->next = 0;
2639
+ type->cast = cast;
2640
+ }
2641
+ }
2642
+
2296
2643
  /* Set entry in modules->types array equal to the type */
2297
2644
  swig_module.types[i] = type;
2298
2645
  }
@@ -2303,7 +2650,7 @@ SWIG_InitializeModule(void *clientdata) {
2303
2650
  for (i = 0; i < swig_module.size; ++i) {
2304
2651
  int j = 0;
2305
2652
  swig_cast_info *cast = swig_module.cast_initial[i];
2306
- printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
2653
+ printf("SWIG_InitializeModule: type %lu %s\n", (unsigned long)i, swig_module.type_initial[i]->name);
2307
2654
  while (cast->type) {
2308
2655
  printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
2309
2656
  cast++;
@@ -2323,7 +2670,6 @@ SWIG_InitializeModule(void *clientdata) {
2323
2670
  SWIGRUNTIME void
2324
2671
  SWIG_PropagateClientData(void) {
2325
2672
  size_t i;
2326
- swig_cast_info *equiv;
2327
2673
  static int init_run = 0;
2328
2674
 
2329
2675
  if (init_run) return;
@@ -2331,13 +2677,16 @@ SWIG_PropagateClientData(void) {
2331
2677
 
2332
2678
  for (i = 0; i < swig_module.size; i++) {
2333
2679
  if (swig_module.types[i]->clientdata) {
2334
- equiv = swig_module.types[i]->cast;
2335
- while (equiv) {
2336
- if (!equiv->converter) {
2337
- if (equiv->type && !equiv->type->clientdata)
2338
- SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
2680
+ swig_cast_info *head, *cast;
2681
+ head = swig_module.types[i]->cast;
2682
+ while (head) {
2683
+ for (cast = head; (cast - head) <= head->value; cast++) {
2684
+ if (!cast->converter) {
2685
+ if (cast->type && !cast->type->clientdata)
2686
+ SWIG_TypeClientData(cast->type, swig_module.types[i]->clientdata);
2687
+ }
2339
2688
  }
2340
- equiv = equiv->next;
2689
+ head = head->next;
2341
2690
  }
2342
2691
  }
2343
2692
  }