summaryrefslogtreecommitdiffstats
path: root/debian/patches/0001-wslua-Fix-support-for-Lua-5.1-and-5.2-on-32bit.patch
blob: 3bb35ff86e5b9fd3adf749de9ea6586d79066887 (plain)
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
From f8fd960cb8f5378c8ab6b20b4bc7f0b73498d057 Mon Sep 17 00:00:00 2001
From: Balint Reczey <balint@balintreczey.hu>
Date: Sat, 20 Apr 2024 18:57:17 +0200
Subject: [PATCH] wslua: Fix support for Lua 5.1 and 5.2 on 32bit
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add macros to use lua_pushnumber for Lua 5.1/5.2 and lua_pushinteger for Lua 5.3/5.4
based on change proposal by Stig Bjørlykke.

Ping #10881

Follow up for commit 8cac5932f79b87deda26480769a266ff344036e6.

Co-authored-by: Stig Bjørlykke <stig@bjorlykke.org>
---
 epan/wslua/init_wslua.c           | 10 +++---
 epan/wslua/lrexlib/pcre2/lpcre2.c |  2 +-
 epan/wslua/make-taps.py           | 24 +++++++-------
 epan/wslua/wslua.h                |  7 +++++
 epan/wslua/wslua_byte_array.c     | 12 +++----
 epan/wslua/wslua_dissector.c      |  4 +--
 epan/wslua/wslua_field.c          | 12 +++----
 epan/wslua/wslua_file.c           |  6 ++--
 epan/wslua/wslua_file_handler.c   |  8 ++---
 epan/wslua/wslua_frame_info.c     |  8 ++---
 epan/wslua/wslua_pinfo.c          |  2 +-
 epan/wslua/wslua_pref.c           |  4 +--
 epan/wslua/wslua_struct.c         | 10 +++---
 epan/wslua/wslua_tree.c           |  6 ++--
 epan/wslua/wslua_tvb.c            | 52 +++++++++++++++----------------
 epan/wslua/wslua_wtap.c           | 10 +++---
 16 files changed, 92 insertions(+), 85 deletions(-)

--- a/epan/wslua/init_wslua.c
+++ b/epan/wslua/init_wslua.c
@@ -969,7 +969,7 @@
     lua_getglobal(L, table);
     /* Set symbol in table. */
     lua_pushstring(L, name);
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
     lua_settable(L, -3);
     /* Pop table from stack. */
     lua_pop(L, 1);
@@ -979,7 +979,7 @@
 add_global_symbol(const char *name, int value)
 {
     /* Set symbol in global environment. */
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
     lua_setglobal(L, name);
 }
 
@@ -988,7 +988,7 @@
 {
     lua_getglobal(L, WSLUA_EXPERT_TABLE);
     lua_getfield(L, -1, WSLUA_EXPERT_SEVERITY_TABLE);
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
     lua_setfield(L, -2, name);
     lua_pop(L, 2);
 }
@@ -998,7 +998,7 @@
 {
     lua_getglobal(L, WSLUA_EXPERT_TABLE);
     lua_getfield(L, -1, WSLUA_EXPERT_GROUP_TABLE);
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
     lua_setfield(L, -2, name);
     lua_pop(L, 2);
 }
@@ -1007,7 +1007,7 @@
 add_menu_group_symbol(const char *name, int value)
 {
     /* Set symbol in global environment. */
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
     char *str = g_strdup(name);
     char *s = strstr(str, "_GROUP_");
     if (s == NULL)
--- a/epan/wslua/lrexlib/pcre2/lpcre2.c
+++ b/epan/wslua/lrexlib/pcre2/lpcre2.c
@@ -432,7 +432,7 @@
 #define SET_INFO_FIELD(L,ud,what,name,valtype) { \
   valtype val; \
   if (0 == pcre2_pattern_info (ud->pr, what, &val)) { \
-    lua_pushinteger (L, val); \
+    WSLUA_PUSHINTEGER (L, val); \
     lua_setfield (L, -2, name); \
   } \
 }
--- a/epan/wslua/make-taps.py
+++ b/epan/wslua/make-taps.py
@@ -34,18 +34,18 @@
     types = {
         'gchar[]': 'lua_pushstring(L,(const char*)v->STR);',
         'gchar*': 'lua_pushstring(L,(const char*)v->STR);',
-        'guint': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'guint8': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'guint16': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'guint32': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'gint': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'gint8': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'gint16': 'lua_pushinteger(L,(lua_Integer)v->STR);',
-        'gint32': 'lua_pushinteger(L,(lua_Integer)v->STR);',
+        'guint': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'guint8': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'guint16': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'guint32': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'gint': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'gint8': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'gint16': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
+        'gint32': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
         'gboolean': 'lua_pushboolean(L,(int)v->STR);',
         'address': '{ Address a = (Address)g_malloc(sizeof(address)); copy_address(a, &(v->STR)); pushAddress(L,a); }',
         'address*': '{ Address a = (Address)g_malloc(sizeof(address)); copy_address(a, v->STR); pushAddress(L,a); }',
-        'int': 'lua_pushinteger(L,(lua_Integer)v->STR);',
+        'int': 'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR);',
         'nstime_t': 'lua_pushnumber(L,(lua_Number)nstime_to_sec(&(v->STR)));',
         'nstime_t*': 'lua_pushnumber(L,(lua_Number)nstime_to_sec(v->STR));',
     }
@@ -79,7 +79,7 @@
     for enum in enum_types:
         m = re.search(fr'typedef\s+enum[^{{]*{{([^}}]*)}}[\s\n]*{enum}[\s\n]*;', buf, flags=re.DOTALL)
         if m:
-            types[enum] = f'lua_pushinteger(L,(lua_Integer)v->STR); /* {enum} */'
+            types[enum] = f'WSLUA_PUSHINTEGER_WITH_CAST(L,v->STR); /* {enum} */'
             econsts = m.group(1).splitlines()
             econsts = [re.sub(r'\s+', '', item) for item in econsts]
             econsts = [re.sub(',', '', item) for item in econsts]
@@ -183,9 +183,9 @@
         c_body += f'\n\t/*\n\t * {enum}\n\t */\n\tlua_newtable(L);\n'
         for econst in enums[enum]:
             c_body += f'''\
-	lua_pushinteger(L,(lua_Integer){econst});
+	WSLUA_PUSHINTEGER_WITH_CAST(L,{econst});
 	lua_setglobal(L,"{econst}");
-	lua_pushinteger(L,(lua_Integer){econst});
+	WSLUA_PUSHINTEGER_WITH_CAST(L,{econst});
 	lua_pushstring(L,"{econst}");
 	lua_settable(L,-3);
 '''
--- a/epan/wslua/wslua.h
+++ b/epan/wslua/wslua.h
@@ -81,6 +81,13 @@
 #define wslua_optguint32(L,i,d) (guint32)         ( luaL_optnumber(L,i,d) )
 #define wslua_optguint64(L,i,d) (guint64)         ( luaL_optnumber(L,i,d) )
 
+#if LUA_VERSION_NUM < 503
+#define WSLUA_PUSHINTEGER(L, i) lua_pushnumber(L, i)
+#define WSLUA_PUSHINTEGER_WITH_CAST(L, i) lua_pushnumber(L, (lua_Number)i)
+#else
+#define WSLUA_PUSHINTEGER(L, i) lua_pushinteger(L, i)
+#define WSLUA_PUSHINTEGER_WITH_CAST(L, i) lua_pushinteger(L, (lua_Integer)i)
+#endif
 
 struct _wslua_tvb {
     tvbuff_t* ws_tvb;
--- a/epan/wslua/wslua_byte_array.c
+++ b/epan/wslua/wslua_byte_array.c
@@ -214,7 +214,7 @@
         luaL_argerror(L,2,"index out of range");
         return 0;
     }
-    lua_pushinteger(L,ba->data[idx]);
+    WSLUA_PUSHINTEGER(L,ba->data[idx]);
 
     WSLUA_RETURN(1); /* The value [0-255] of the byte. */
 }
@@ -255,7 +255,7 @@
         value |= (guint8)ba->data[offset + i];
     }
 
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
 
     WSLUA_RETURN(1); /* The value of the little endian encoded signed integer beginning at given offset with given length. */
 }
@@ -337,7 +337,7 @@
         value |= (guint8)ba->data[offset + i];
     }
 
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
 
     WSLUA_RETURN(1); /* The value of the little endian encoded unsigned integer beginning at given offset with given length. */
 }
@@ -419,7 +419,7 @@
         value |= (guint8)ba->data[offset + i];
     }
 
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
 
     WSLUA_RETURN(1); /* The value of the big endian encoded 32 bit signed integer beginning at given offset with given length. */
 }
@@ -501,7 +501,7 @@
         value |= (guint8)ba->data[offset + i];
     }
 
-    lua_pushinteger(L, value);
+    WSLUA_PUSHINTEGER(L, value);
 
     WSLUA_RETURN(1); /* The value of the big endian encoded 32 bit unsigned integer beginning at given offset with given length. */
 }
@@ -551,7 +551,7 @@
     /* Obtain the length of a <<lua_class_ByteArray,`ByteArray`>>. */
     ByteArray ba = checkByteArray(L,1);
 
-    lua_pushinteger(L,(lua_Integer)ba->len);
+    WSLUA_PUSHINTEGER_WITH_CAST(L,ba->len);
 
     WSLUA_RETURN(1); /* The length of the <<lua_class_ByteArray,`ByteArray`>>. */
 }
--- a/epan/wslua/wslua_dissector.c
+++ b/epan/wslua/wslua_dissector.c
@@ -107,7 +107,7 @@
        are normal conditions and possibly don't need the Lua traceback. */
     if (error) { WSLUA_ERROR(Dissector_call,error); }
 
-    lua_pushinteger(L,(lua_Integer)len);
+    WSLUA_PUSHINTEGER_WITH_CAST(L,len);
     WSLUA_RETURN(1); /* Number of bytes dissected.  Note that some dissectors always return number of bytes in incoming buffer, so be aware. */
 }
 
@@ -618,7 +618,7 @@
 
     if (error) { WSLUA_ERROR(DissectorTable_try,error); }
 
-    lua_pushinteger(L,(lua_Integer)len);
+    WSLUA_PUSHINTEGER_WITH_CAST(L,len);
     WSLUA_RETURN(1); /* Number of bytes dissected.  Note that some dissectors always return number of bytes in incoming buffer, so be aware. */
 }
 
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -50,7 +50,7 @@
        */
     FieldInfo fi = checkFieldInfo(L,1);
 
-    lua_pushinteger(L,fi->ws_fi->length);
+    WSLUA_PUSHINTEGER(L,fi->ws_fi->length);
     return 1;
 }
 
@@ -61,7 +61,7 @@
        */
     FieldInfo fi = checkFieldInfo(L,1);
 
-    lua_pushinteger(L,fi->ws_fi->start);
+    WSLUA_PUSHINTEGER(L,fi->ws_fi->start);
     return 1;
 }
 
@@ -91,13 +91,13 @@
         case FT_UINT24:
         case FT_UINT32:
         case FT_FRAMENUM:
-                lua_pushinteger(L,(lua_Integer)(fvalue_get_uinteger(fi->ws_fi->value)));
+                WSLUA_PUSHINTEGER_WITH_CAST(L,(fvalue_get_uinteger(fi->ws_fi->value)));
                 return 1;
         case FT_INT8:
         case FT_INT16:
         case FT_INT24:
         case FT_INT32:
-                lua_pushinteger(L,(lua_Integer)(fvalue_get_sinteger(fi->ws_fi->value)));
+                WSLUA_PUSHINTEGER_WITH_CAST(L,(fvalue_get_sinteger(fi->ws_fi->value)));
                 return 1;
         case FT_FLOAT:
         case FT_DOUBLE:
@@ -268,7 +268,7 @@
     FieldInfo fi = checkFieldInfo(L,1);
 
     if (fi->ws_fi->hfinfo) {
-        lua_pushinteger(L, fi->ws_fi->hfinfo->type);
+        WSLUA_PUSHINTEGER(L, fi->ws_fi->hfinfo->type);
     }
     else {
         lua_pushnil(L);
@@ -710,7 +710,7 @@
     Field f = checkField(L,1);
     header_field_info* hfinfo = NULL;
 
-    GET_HFINFO_MEMBER(lua_pushinteger, type);
+    GET_HFINFO_MEMBER(WSLUA_PUSHINTEGER, type);
 
     return 1;
 }
--- a/epan/wslua/wslua_file.c
+++ b/epan/wslua/wslua_file.c
@@ -152,7 +152,7 @@
     buff[buff_end] = '\0';
 
     if (buff_end > 0 && num_digits > 0 && sscanf(buff, "%lf", &d) == 1) {
-        lua_pushinteger(L, d);
+        WSLUA_PUSHINTEGER(L, d);
         return 1;
     }
     else {
@@ -355,7 +355,7 @@
             return 2;
         }
 
-        lua_pushinteger(L, (lua_Integer)(file_tell(f->file)));
+        lua_pushnumber(L, (lua_Number)(file_tell(f->file)));
     }
     else {
         offset = wtap_dump_file_seek(f->wdh, offset, mode[op], &err);
@@ -374,7 +374,7 @@
             return 2;
         }
 
-        lua_pushinteger(L, (lua_Integer)(offset));
+        lua_pushnumber(L, (lua_Number)(offset));
     }
 
     WSLUA_RETURN(1); /* The current file cursor position as a number. */
--- a/epan/wslua/wslua_file_handler.c
+++ b/epan/wslua/wslua_file_handler.c
@@ -326,7 +326,7 @@
     fp = push_File(L, wth->random_fh);
     fc = push_CaptureInfo(L, wth, FALSE);
     fi = push_FrameInfo(L, rec, buf);
-    lua_pushinteger(L, (lua_Integer)seek_off);
+    lua_pushnumber(L, (lua_Number)seek_off);
 
     switch ( lua_pcall(L,4,1,1) ) {
         case 0:
@@ -474,7 +474,7 @@
 
     INIT_FILEHANDLER_ROUTINE(can_write_encap,WTAP_ERR_UNWRITABLE_ENCAP,NULL,NULL);
 
-    lua_pushinteger(L, encap);
+    WSLUA_PUSHINTEGER(L, encap);
 
     switch ( lua_pcall(L,1,1,1) ) {
         case 0:
@@ -842,7 +842,7 @@
     fh->registered = TRUE;
     registered_file_handlers = g_slist_prepend(registered_file_handlers, fh);
 
-    lua_pushinteger(L, fh->file_type);
+    WSLUA_PUSHINTEGER(L, fh->file_type);
 
     WSLUA_RETURN(1); /* the new type number for this file reader/write */
 }
@@ -1207,7 +1207,7 @@
             break;\
         } \
     } \
-    lua_pushinteger(L, (lua_Integer)supported_comment_types); \
+    lua_pushnumber(L, (lua_Number)supported_comment_types); \
 });
 WSLUA_ATTRIBUTE_SET(FileHandler,supported_comment_types, { \
     guint supported_comment_types; \
--- a/epan/wslua/wslua_frame_info.c
+++ b/epan/wslua/wslua_frame_info.c
@@ -89,7 +89,7 @@
             g_free(err_info); /* is this right? */
         }
         else lua_pushnil(L);
-        lua_pushinteger(L, err);
+        WSLUA_PUSHINTEGER(L, err);
         return 3;
     }
 
@@ -120,7 +120,7 @@
     lua_createtable(L, n_comments, 0);
     for (i = 0; i < n_comments; i++) {
         comment = NULL;
-        lua_pushinteger(L, i+1);
+        WSLUA_PUSHINTEGER(L, i+1);
         if (WTAP_OPTTYPE_SUCCESS ==
                 wtap_block_get_nth_string_option_value(block, OPT_COMMENT, i, &comment)) {
             lua_pushstring(L, comment);
@@ -371,7 +371,7 @@
     if (!wtap_dump_file_write(fh->wdh, fi->pd, (size_t)(len), &err)) {
         lua_pushboolean(L, FALSE);
         lua_pushfstring(L, "FrameInfoConst write_data() error: %s", g_strerror(err));
-        lua_pushinteger(L, err);
+        WSLUA_PUSHINTEGER(L, err);
         return 3;
     }
 
@@ -403,7 +403,7 @@
     lua_createtable(L, n_comments, 0);
     for (i = 0; i < n_comments; i++) {
         comment = NULL;
-        lua_pushinteger(L, i+1);
+        WSLUA_PUSHINTEGER(L, i+1);
         if (WTAP_OPTTYPE_SUCCESS ==
                 wtap_block_get_nth_string_option_value(block, OPT_COMMENT, i, &comment)) {
             lua_pushstring(L, comment);
--- a/epan/wslua/wslua_pinfo.c
+++ b/epan/wslua/wslua_pinfo.c
@@ -308,7 +308,7 @@
     if (pinfo->ws_pinfo->match_string) {
         lua_pushstring(L,pinfo->ws_pinfo->match_string);
     } else {
-        lua_pushinteger(L,(lua_Integer)(pinfo->ws_pinfo->match_uint));
+        WSLUA_PUSHINTEGER_WITH_CAST(L,(pinfo->ws_pinfo->match_uint));
     }
 
     return 1;
--- a/epan/wslua/wslua_pref.c
+++ b/epan/wslua/wslua_pref.c
@@ -515,9 +515,9 @@
         if ( g_str_equal(prefs_p->name,name) ) {
             switch (prefs_p->type) {
                 case PREF_BOOL: lua_pushboolean(L, prefs_p->value.b); break;
-                case PREF_UINT: lua_pushinteger(L,(lua_Integer)prefs_p->value.u); break;
+                case PREF_UINT: WSLUA_PUSHINTEGER_WITH_CAST(L,prefs_p->value.u); break;
                 case PREF_STRING: lua_pushstring(L,prefs_p->value.s); break;
-                case PREF_ENUM: lua_pushinteger(L,(lua_Integer)prefs_p->value.e); break;
+                case PREF_ENUM: WSLUA_PUSHINTEGER_WITH_CAST(L,prefs_p->value.e); break;
                 case PREF_RANGE:
                     {
                     char *push_str = range_convert_range(NULL, prefs_p->value.r);
--- a/epan/wslua/wslua_struct.c
+++ b/epan/wslua/wslua_struct.c
@@ -410,7 +410,7 @@
  * given endianness and size. If the integer type is signed, this makes
  * the Lua number be +/- correctly as well.
  */
-static lua_Integer getinteger (const gchar *buff, int endian,
+static lua_Number getinteger (const gchar *buff, int endian,
                         int issigned, int size) {
   Uinttype l = 0;
   int i;
@@ -427,12 +427,12 @@
     }
   }
   if (!issigned)
-    return (lua_Integer)l;
+    return (lua_Number)l;
   else {  /* signed format */
     Uinttype mask = (Uinttype)(~((Uinttype)0)) << (size*8 - 1);
     if (l & mask)  /* negative value? */
       l |= mask;  /* signal extension */
-    return (lua_Integer)(Inttype)l;
+    return (lua_Number)(Inttype)l;
   }
 }
 
@@ -470,8 +470,8 @@
       case 'b': case 'B': case 'h': case 'H':
       case 'l': case 'L': case 'T': case 'i':  case 'I': {  /* integer types */
         int issigned = g_ascii_islower(opt);
-        lua_Integer res = getinteger(data+pos, h.endian, issigned, (int)size);
-        lua_pushinteger(L, res);
+        lua_Number res = getinteger(data+pos, h.endian, issigned, (int)size);
+        WSLUA_PUSHINTEGER(L, res);
         break;
       }
       case 'e': {
--- a/epan/wslua/wslua_tree.c
+++ b/epan/wslua/wslua_tree.c
@@ -123,7 +123,7 @@
                 item = proto_tree_add_item_ret_int(tree_item->tree, hfid, tvbr->tvb->ws_tvb,
                                                 tvbr->offset, tvbr->len, encoding,
                                                 &ret);
-                lua_pushinteger(L, (lua_Integer)ret);
+                lua_pushnumber(L, (lua_Number)ret);
                 lua_pushinteger(L, tvbr->offset + tvbr->len);
             }
             break;
@@ -152,7 +152,7 @@
                 item = proto_tree_add_item_ret_uint(tree_item-> tree, hfid, tvbr->tvb->ws_tvb,
                                                     tvbr->offset, tvbr->len, encoding,
                                                     &ret);
-                lua_pushinteger(L, (lua_Integer)ret);
+                lua_pushnumber(L, (lua_Number)ret);
                 lua_pushinteger(L, tvbr->offset + tvbr->len);
             }
             break;
@@ -502,7 +502,7 @@
             switch(type) {
                 case FT_PROTOCOL:
                     item = proto_tree_add_item(tree_item->tree,hfid,tvbr->tvb->ws_tvb,tvbr->offset,tvbr->len,ENC_NA);
-                    lua_pushinteger(L,0);
+                    WSLUA_PUSHINTEGER(L,0);
                     lua_insert(L,1);
                     break;
                 case FT_BOOLEAN:
--- a/epan/wslua/wslua_tvb.c
+++ b/epan/wslua/wslua_tvb.c
@@ -135,7 +135,7 @@
     /* Obtain the reported length (length on the network) of a <<lua_class_Tvb,`Tvb`>>. */
     Tvb tvb = checkTvb(L,1);
 
-    lua_pushinteger(L,tvb_reported_length(tvb->ws_tvb));
+    WSLUA_PUSHINTEGER(L,tvb_reported_length(tvb->ws_tvb));
     WSLUA_RETURN(1); /* The reported length of the <<lua_class_Tvb,`Tvb`>>. */
 }
 
@@ -143,7 +143,7 @@
     /* Obtain the captured length (amount saved in the capture process) of a <<lua_class_Tvb,`Tvb`>>. */
     Tvb tvb = checkTvb(L,1);
 
-    lua_pushinteger(L,tvb_captured_length(tvb->ws_tvb));
+    WSLUA_PUSHINTEGER(L,tvb_captured_length(tvb->ws_tvb));
     WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
 }
 
@@ -152,7 +152,7 @@
        Same as captured_len; kept only for backwards compatibility */
     Tvb tvb = checkTvb(L,1);
 
-    lua_pushinteger(L,tvb_captured_length(tvb->ws_tvb));
+    WSLUA_PUSHINTEGER(L,tvb_captured_length(tvb->ws_tvb));
     WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
 }
 
@@ -163,7 +163,7 @@
     Tvb tvb = checkTvb(L,1);
     int offset = (int) luaL_optinteger(L, Tvb_reported_length_remaining_OFFSET, 0);
 
-    lua_pushinteger(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
+    WSLUA_PUSHINTEGER(L,tvb_reported_length_remaining(tvb->ws_tvb, offset));
     WSLUA_RETURN(1); /* The captured length of the <<lua_class_Tvb,`Tvb`>>. */
 }
 
@@ -210,7 +210,7 @@
     /* Returns the raw offset (from the beginning of the source <<lua_class_Tvb,`Tvb`>>) of a sub <<lua_class_Tvb,`Tvb`>>. */
     Tvb tvb = checkTvb(L,1);
 
-    lua_pushinteger(L,tvb_raw_offset(tvb->ws_tvb));
+    WSLUA_PUSHINTEGER(L,tvb_raw_offset(tvb->ws_tvb));
     WSLUA_RETURN(1); /* The raw offset of the <<lua_class_Tvb,`Tvb`>>. */
 }
 
@@ -441,16 +441,16 @@
 
     switch (tvbr->len) {
         case 1:
-            lua_pushinteger(L,tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 2:
-            lua_pushinteger(L,tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 3:
-            lua_pushinteger(L,tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 4:
-            lua_pushinteger(L,tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
             WSLUA_RETURN(1); /* The unsigned integer value. */
         default:
             luaL_error(L,"TvbRange:uint() does not handle %d byte integers",tvbr->len);
@@ -474,16 +474,16 @@
     switch (tvbr->len) {
         case 1:
             /* XXX unsigned anyway */
-            lua_pushinteger(L,(lua_Integer)(guint)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER_WITH_CAST(L,(guint)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 2:
-            lua_pushinteger(L,tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 3:
-            lua_pushinteger(L,tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 4:
-            lua_pushinteger(L,tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
             WSLUA_RETURN(1); /* The unsigned integer value */
         default:
             luaL_error(L,"TvbRange:le_uint() does not handle %d byte integers",tvbr->len);
@@ -594,16 +594,16 @@
 
     switch (tvbr->len) {
         case 1:
-            lua_pushinteger(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 2:
-            lua_pushinteger(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 3:
-            lua_pushinteger(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 4:
-            lua_pushinteger(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
             WSLUA_RETURN(1); /* The signed integer value. */
             /*
              * XXX:
@@ -633,16 +633,16 @@
 
     switch (tvbr->len) {
         case 1:
-            lua_pushinteger(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 2:
-            lua_pushinteger(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 3:
-            lua_pushinteger(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
             return 1;
         case 4:
-            lua_pushinteger(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
+            WSLUA_PUSHINTEGER(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
             WSLUA_RETURN(1); /* The signed integer value. */
         default:
             luaL_error(L,"TvbRange:le_int() does not handle %d byte integers",tvbr->len);
@@ -1237,13 +1237,13 @@
     }
 
     if (len <= 8) {
-        lua_pushinteger(L,(lua_Integer)(guint)tvb_get_bits8(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len));
+        WSLUA_PUSHINTEGER_WITH_CAST(L,(guint)tvb_get_bits8(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len));
         return 1;
     } else if (len <= 16) {
-        lua_pushinteger(L,tvb_get_bits16(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
+        WSLUA_PUSHINTEGER(L,tvb_get_bits16(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
         return 1;
     } else if (len <= 32) {
-        lua_pushinteger(L,tvb_get_bits32(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
+        WSLUA_PUSHINTEGER(L,tvb_get_bits32(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
         return 1;
     } else if (len <= 64) {
         pushUInt64(L,tvb_get_bits64(tvbr->tvb->ws_tvb,tvbr->offset*8 + pos, len, FALSE));
@@ -1334,7 +1334,7 @@
         luaL_error(L,"expired tvb");
         return 0;
     }
-    lua_pushinteger(L,(lua_Integer)tvbr->len);
+    WSLUA_PUSHINTEGER_WITH_CAST(L,tvbr->len);
     return 1;
 }
 
@@ -1347,7 +1347,7 @@
         luaL_error(L,"expired tvb");
         return 0;
     }
-    lua_pushinteger(L,(lua_Integer)tvbr->offset);
+    WSLUA_PUSHINTEGER_WITH_CAST(L,tvbr->offset);
     return 1;
 }
 
--- a/epan/wslua/wslua_wtap.c
+++ b/epan/wslua/wslua_wtap.c
@@ -85,7 +85,7 @@
     if (filetype == -1)
         lua_pushnil(LS);
     else
-        lua_pushinteger(LS,filetype);
+        WSLUA_PUSHINTEGER(LS,filetype);
     WSLUA_RETURN(1); /* The filetype value for the file type with that name, or nil if there is no such file type. */
 }
 
@@ -96,7 +96,7 @@
     @since 3.2.12, 3.4.4
     */
     lua_Number filetype = wtap_pcap_file_type_subtype();
-    lua_pushinteger(LS,filetype);
+    WSLUA_PUSHINTEGER(LS,filetype);
     WSLUA_RETURN(1); /* The filetype value for pcap files. */
 }
 
@@ -107,7 +107,7 @@
     @since 3.2.12, 3.4.4
     */
     lua_Number filetype = wtap_pcap_nsec_file_type_subtype();
-    lua_pushinteger(LS,filetype);
+    WSLUA_PUSHINTEGER(LS,filetype);
     WSLUA_RETURN(1); /* The filetype value for nanosecond-resolution pcap files. */
 }
 
@@ -118,7 +118,7 @@
     @since 3.2.12, 3.4.4
     */
     lua_Number filetype = wtap_pcapng_file_type_subtype();
-    lua_pushinteger(LS,filetype);
+    WSLUA_PUSHINTEGER(LS,filetype);
     WSLUA_RETURN(1); /* The filetype value for pcapng files. */
 }
 
@@ -148,7 +148,7 @@
          * it.
          */
         lua_pushstring(LS, entry->name);
-        lua_pushinteger(LS, entry->ft);
+        WSLUA_PUSHINTEGER(LS, entry->ft);
         /*
          * The -3 is the index, relative to the top of the stack, of
          * the table; the two elements on top of it are the ft and