Git Product home page Git Product logo

brl.mod's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brl.mod's Issues

TGALoader segfaulting in Win/Linux

This is a bug in the STB image module, if I remove "?deprecated" it loads all my particular TGA files fine. The STB image loader in Openb3d also works fine, it uses an older version of STB image 1.35 instead of NG's 2.16. I suspect this is a bug somewhere in the C code for TGAs. It happens in Win x64 or x86 and in Linux x64, I didn't have NG in Mac to test. I've done a GDB backtrace if it's any help, it doesn't seem to be!
Linux x64:

*** Error in `/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug': malloc(): memory corruption: 0x0000000001090850 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7ffff67bb7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8213e)[0x7ffff67c613e]
/lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7ffff67c8184]
/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug[0x5099b6]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ffff6764830]
/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug[0x409f19]
======= Memory map: ========
00400000-007a6000 r-xp 00000000 08:06 2360593                            /NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug
009ea000-01130000 rw-p 00000000 00:00 0                                  [heap]
7ffff24aa000-7ffff24e1000 r-xp 00000000 08:06 2234291                    /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7ffff26e2000-7ffff26fb000 r-xp 00000000 08:06 1441877                    /lib/x86_64-linux-gnu/libz.so.1.2.8
REMOVED
7ffffffc3000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Thread 1 "LoadTexture2.de" received signal SIGABRT, Aborted.
0x00007ffff6779428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6779428 in __GI_raise (sig=sig@entry=6)
    at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff677b02a in __GI_abort () at abort.c:89
#2  0x00007ffff67bb7ea in __libc_message (do_abort=2, fmt=<optimized out>)
    at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff67c613e in _int_malloc () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ffff67c8184 in malloc () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00000000005099b6 in brl_pixmap_TPixmap_Create_TTPixmap_iiii (
    bbt_width=128, bbt_height=128, bbt_format=6, bbt_align=4)
    at /NG/mod/brl.mod/pixmap.mod/.bmx/pixmap.bmx.debug.linux.x64.c:940
#6  0x000000000050af6f in brl_pixmap_CreatePixmap (bbt_width=128, 
    bbt_height=128, bbt_format=6, bbt_align_bytes=bbt_align_bytes@entry=4)
    at /NG/mod/brl.mod/pixmap.mod/.bmx/pixmap.bmx.debug.linux.x64.c:1632
#7  0x00000000004f5b71 in _brl_stbimageloader_TPixmapLoaderSTB_LoadPixmap_TTStream (o=0xca2f70, bbt_stream=0xcc91b0)
    at /NG/mod/brl.mod/stbimageloader.mod/.bmx/stbimageloader.bmx.debug.linux.x64.c:330
#8  0x000000000050c9b8 in brl_pixmap_LoadPixmap (bbt_url=0x9a6d30 <_s2>)
    at /NG/mod/brl.mod/pixmap.mod/.bmx/pixmap.bmx.debug.linux.x64.c:2163

Linux x64 different error:

*** Error in `/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug': free(): invalid next size (fast): 0x00000000010abd60 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7ffff67bb7e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7ffff67c437a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7ffff67c853c]
/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug[0x4f5a8f]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7ffff6764830]
/NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug[0x409f19]
======= Memory map: ========
00400000-007a6000 r-xp 00000000 08:06 2360593                            /NG/mod/openb3d.mod/examples/standard/LoadTexture2.debug
009ea000-01130000 rw-p 00000000 00:00 0                                  [heap]
7ffff24aa000-7ffff24e1000 r-xp 00000000 08:06 2234291                    /usr/lib/x86_64-linux-gnu/libtxc_dxtn_s2tc.so.0.0.0
7ffff26e2000-7ffff26fb000 r-xp 00000000 08:06 1441877                    /lib/x86_64-linux-gnu/libz.so.1.2.8
REMOVED
7ffffffc3000-7ffffffff000 rw-p 00000000 00:00 0                          [stack]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

Thread 1 "LoadTexture2.de" received signal SIGABRT, Aborted.
0x00007ffff6779428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6779428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1  0x00007ffff677b02a in __GI_abort () at abort.c:89
#2  0x00007ffff67bb7ea in __libc_message (do_abort=2, fmt=<optimized out>) at ../sysdeps/posix/libc_fatal.c:175
#3  0x00007ffff67c437a in _int_free () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x00007ffff67c853c in free () from /lib/x86_64-linux-gnu/libc.so.6
#5  0x00000000004f5a8f in _brl_stbimageloader_TPixmapLoaderSTB_LoadPixmap_TTStream (o=0xca2f70, bbt_stream=0xcc91b0)
    at /NG/mod/brl.mod/stbimageloader.mod/.bmx/stbimageloader.bmx.debug.linux.x64.c:338
#6  0x000000000050c9b8 in brl_pixmap_LoadPixmap (bbt_url=0x9a6d30 <_s2>)
    at /NG/mod/brl.mod/pixmap.mod/.bmx/pixmap.bmx.debug.linux.x64.c:2163
#7  0x000000000046cec3 in openb3d_openb3d_TTexture_LoadAnimTextureStream_TTTexture_SiiiiiTTTexture (bbt_file=0x9a6d30 <_s2>, bbt_flags=9, 
    bbt_frame_width=bbt_frame_width@entry=0, bbt_frame_height=bbt_frame_height@entry=0, bbt_first_frame=bbt_first_frame@entry=0, 
    bbt_frame_count=bbt_frame_count@entry=1, bbt_tex=0x9f1a48 <bbNullObject>)
    at /NG/mod/openb3d.mod/openb3d.mod/.bmx/openb3d.bmx.debug.linux.x64.c:23052
#8  0x00000000004881b8 in openb3d_openb3d_LoadTextureStream (bbt_file=bbt_file@entry=0x9a6d30 <_s2>, bbt_flags=bbt_flags@entry=9, 
    bbt_tex=0x9f1a48 <bbNullObject>) at /NG/mod/openb3d.mod/openb3d.mod/.bmx/openb3d.bmx.debug.linux.x64.c:54888
#9  0x000000000040ad88 in _bb_main () at /NG/mod/openb3d.mod/examples/standard/LoadTexture2.bmx:30
#10 0x00000000006ec083 in __bb_brl_appstub_appstub () at /NG/mod/brl.mod/appstub.mod/.bmx/appstub.bmx.debug.linux.x64.c:8
#11 0x0000000000409edf in main (argc=1, argv=0x7fffffffdf28) at /NG/mod/brl.mod/appstub.mod/appstub.linux.c:18

Win x64:

warning: Critical error detected c0000374


Program received signal SIGTRAP, Trace/breakpoint trap.
0x000000007760f3b0 in ntdll!RtlUnhandledExceptionFilter ()
   from C:\Windows\SYSTEM32\ntdll.dll
(gdb) bt
#0  0x000000007760f3b0 in ntdll!RtlUnhandledExceptionFilter ()
   from C:\Windows\SYSTEM32\ntdll.dll
#1  0x000000007760f9c6 in ntdll!EtwEnumerateProcessRegGuids ()
   from C:\Windows\SYSTEM32\ntdll.dll
#2  0x0000000077610592 in ntdll!RtlQueryProcessLockInformation ()
   from C:\Windows\SYSTEM32\ntdll.dll
#3  0x0000000077612204 in ntdll!RtlLogStackBackTrace ()
   from C:\Windows\SYSTEM32\ntdll.dll
#4  0x00000000775a86bf in ntdll!RtlIsDosDeviceName_U ()
   from C:\Windows\SYSTEM32\ntdll.dll
#5  0x000000007757f611 in ntdll!RtlSubAuthorityCountSid ()
   from C:\Windows\SYSTEM32\ntdll.dll
#6  0x000000007757f4ba in ntdll!RtlSubAuthorityCountSid ()
   from C:\Windows\SYSTEM32\ntdll.dll
#7  0x0000000000000001 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Win x86:

warning: `C:\Windows\SYSTEM32\ntdll.dll': Shared library architecture i386:x86-6
4 is not compatible with target architecture i386.
warning: `C:\Windows\SYSTEM32\wow64.dll': Shared library architecture i386:x86-6
4 is not compatible with target architecture i386.
warning: `C:\Windows\SYSTEM32\wow64win.dll': Shared library architecture i386:x8
6-64 is not compatible with target architecture i386.
warning: `C:\Windows\SYSTEM32\wow64cpu.dll': Shared library architecture i386:x8
6-64 is not compatible with target architecture i386.
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
warning: Could not load shared library symbols for NOT_AN_IMAGE.
Do you need "set solib-search-path" or "set sysroot"?
[New Thread 2168.0xb30]

Program received signal SIGSEGV, Segmentation fault.
0x0000002b in ?? ()
(gdb) bt
#0  0x0000002b in ?? ()

Copying an empty map inserts an invalid node

SuperStrict
Framework BRL.StandardIO
Import BRL.Map

Local map:TMap = New TMap
'map.Insert "testkey", "testval"

For Local n:TNode = EachIn map
	Print n.Key().ToString() + ", " + n.Value().ToString()
Next

Print "COPY"
map = map.Copy()

For Local n:TNode = EachIn map
	Print n.Key().ToString() + ", " + n.Value().ToString()
Next

Since nothing is ever inserted into the map, the contents of neither loop should ever be executed.
But apparently, calling .Copy() on an empty map returns a map containing a TNode whose key and value are both Null, resulting in an error.

BMPLoader: segfaults and broken uv layouts

I created some bmp-test files (16bit, 24bit, 32bit in Gimp and another one in Photoshop).

Trying to load them results sometimes in segfaults as the "TImageFrame" stays Null - means loading failed.

SuperStrict
Graphics 800,600

'vanilla: runs but wrong colors
'before stbimage-update
'ng 64:   segfault
'ng 32:   runs but only showing a few lines of pixels
'after stbimage-update and disabling bmp loading there
'ng 64:   runs fine
'ng 32:   runs fine
'Global img:TImage = LoadImage("bmxng_ps.bmp")


'vanilla: runs but doubled size, wrong colors
'before stbimage-update
'ng 64:   segfault
'ng 32:   runs perfectly
'after stbimage-update and disabling bmp loading there
'ng 64:   runs but doubled size, retro colors and uv layout broken
'ng 32:   runs but doubled size, retro colors and uv layout broken
'Global img:TImage = LoadImage("bmxng_32bit.bmp")

'vanilla: runs but wrong colors and uv texture layout displaced 
'before stbimage-update
'ng 64:   segfault
'ng 32:   runs but doubled size, only showing a few lines of pixels
'after stbimage-update and disabling bmp loading there
'ng 64:   same as vanilla
'ng 32:   same as vanilla
'Global img:TImage = LoadImage("bmxng_24bit.bmp")

'vanilla: segfault
'before stbimage-update
'ng 64:   segfault
'ng 32:   runs but nothing drawn
'after stbimage-update and disabling bmp loading there
'ng 64:   segfault
'ng 32:   segfault
Global img:TImage = LoadImage("bmxng_16bit.bmp")

Repeat
	Cls
	DrawImage(img, MouseX()-10, MouseY()-10)
	Flip
Until AppTerminate() Or KeyHit(KEY_ESCAPE)

Needed images:
images.zip

[IFC] Reflection: Module needs support to handle interfaces

The BRL.Reflection-module needs support for the newly introduced interfaces.

I mean something in the likes of ExtendsType() we need:

ImplementsInterface() - Boolean

ImplementedInterfaces() - TList containing all used TInterfaceID (or TTypeID)

Or could all of this be done similar to "ExtendsType()" already ?

Various sigsev/segfaults with brl.mod and bcc-ng

With commit a354458 I get a segfault on startup.

Program received signal SIGSEGV, Segmentation fault.
0x0869eee1 in _brl_linkedlist_TList_ObjectEnumerator (o=0x8956b78)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/linkedlist.mod/.bmx/linkedlist.bmx.debug.linux.x86.c:1721
1721        bbt_enum=((struct brl_linkedlist_TListEnum_obj*)bbObjectDowncast((brl_linkedlist_TListEnum__pool)->clas->md_RemoveFirst(brl_linkedlist_TListEnum__pool),&brl_linkedlist_TListEnum));
(gdb) bt
#0  0x0869eee1 in _brl_linkedlist_TList_ObjectEnumerator (o=0x8956b78)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/linkedlist.mod/.bmx/linkedlist.bmx.debug.linux.x86.c:1721
#1  0x085d153d in _brl_reflection_TTypeId__Resolve (o=0x890bf78)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:3756
#2  0x085b51f2 in brl_reflection_TTypeId__Update ()
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:3068
#3  0x085cf96a in brl_reflection_TTypeId_ForObject (bbt_obj=0x88d4d00)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:2511
#4  0x083525a5 in _bb_dig_base_util_helper ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.util.helper.bmx.debug.linux.x86.c:1374
#5  0x0834407f in _bb_dig_base_gfx_gui_list_base ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.gfx.gui.list.base.bmx.debug.linux.x86.c:4489
#6  0x08338dcc in _bb_dig_base_gfx_gui_list_slotlist ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.gfx.gui.list.slotlist.bmx.debug.linux.x86.c:2630
#7  0x081933bf in _bb_source_main ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/.bmx/main.bmx.debug.linux.x86.c:123822
#8  0x0804e0b8 in _bb_main ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/.bmx/TVTower.bmx.console.debug.linux.x86.c:16
#9  0x0860e32c in __bb_brl_appstub_appstub ()
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/appstub.mod/.bmx/appstub.bmx.debug.linux.x86.c:8
#10 0x0804df74 in main (argc=1, argv=0xffffd3c4) at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/appstub.mod/appstub.linux.c:18

Reverting to the one before ("[osx] Don't use deprecated Microseconds()." - 065ddd1) moves the segfault to a later stage (after loading some ressources)

Program received signal SIGSEGV, Segmentation fault.
bbObjectDowncast (o=0x0, t=t@entry=0x880a2a0 <_base_gfx_gui_TGUIobject>)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/blitz.mod/blitz_object.c:97
97      BBClass *p=o->clas;

(gdb) bt
#0  bbObjectDowncast (o=0x0, t=t@entry=0x880a2a0 <_base_gfx_gui_TGUIobject>)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/blitz.mod/blitz_object.c:97
#1  0x0831e957 in __base_gfx_gui_TGUIManager_Update (o=0x8908f78, bbt_State=0x87f66c0 <_s905>, bbt_fromZ=-1000, bbt_toZ=-1000, bbt_updateTypes=3)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.gfx.gui.bmx.debug.linux.x86.c:2236
#2  0x08053170 in __main_TScreen_MainMenu_Update (o=0x89029c0, bbt_deltaTime=0,0333333351)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/.bmx/main.bmx.debug.linux.x86.c:41521
#3  0x083aff2d in __common_misc_screen_TScreenCollection_UpdateCurrent (o=0x89ae1b0, bbt_deltaTime=0,0333333351)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/.bmx/common.misc.screen.bmx.debug.linux.x86.c:902
#4  0x0818b94f in _main_TApp_Update ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/.bmx/main.bmx.debug.linux.x86.c:38331
#5  0x082f4639 in __base_util_deltatimer_TDeltaTimer_RunUpdate (o=0x8986ea0)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.util.deltatimer.bmx.debug.linux.x86.c:370
#6  0x082f4b1b in __base_util_deltatimer_TDeltaTimer_Loop (o=<optimized out>)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.util.deltatimer.bmx.debug.linux.x86.c:485
#7  0x081930fd in _main_StartTVTower (bbt_start=bbt_start@entry=1)
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/.bmx/main.bmx.debug.linux.x86.c:123766
#8  0x0804e118 in _bb_main ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/.bmx/TVTower.bmx.console.debug.linux.x86.c:27
#9  0x0860e32c in __bb_brl_appstub_appstub ()
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/appstub.mod/.bmx/appstub.bmx.debug.linux.x86.c:8
#10 0x0804df74 in main (argc=1, argv=0xffffd3c4) at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/appstub.mod/appstub.linux.c:18

Seems it is not a matter of a special module but the "downcast" way.

So I reverted "BCC" to an older revision ("Boolean expressions should autocast to String." bmx-ng/bcc.git@57588c48c9712ae0611b59e8264b9616eb9e39e0). Recompiled modules and there I got an other crash - or better - it stalled and I had to CTRL+C the execution in GDB:

^C
Program received signal SIGINT, Interrupt.
0x086a6063 in bbArrayIndex (arr=0x88d3ed8, offset=1, index=5) at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/blitz.mod/blitz_array.c:306
306     if (index < 0 || index >= arr->scales[0]) brl_blitz_ArrayBoundsError();
(gdb) bt
#0  0x086a6063 in bbArrayIndex (arr=0x88d3ed8, offset=1, index=5)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/blitz.mod/blitz_array.c:306
#1  0x0860f0f3 in brl_appstub_debugger_mt_stdio_OnDebugLeaveScope ()
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/appstub.mod/.bmx/debugger_mt.stdio.bmx.debug.linux.x86.c:1188
#2  0x0869ecea in _brl_linkedlist_TList_InsertBeforeLink (o=0x88d4cc0, bbt_value=0x884ea84 <bbNullObject>, bbt_succ=0x8913d10)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/linkedlist.mod/.bmx/linkedlist.bmx.debug.linux.x86.c:814
#3  0x0869c37a in _brl_linkedlist_TList_AddLast (o=0x88d4cc0, bbt_value=0x884ea84 <bbNullObject>)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/linkedlist.mod/.bmx/linkedlist.bmx.debug.linux.x86.c:553
#4  0x085d11c1 in _brl_reflection_TTypeId__Resolve (o=0x8901b58)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:3896
#5  0x085b5bf2 in brl_reflection_TTypeId__Update ()
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:3068
#6  0x085d036a in brl_reflection_TTypeId_ForObject (bbt_obj=0x88d4d00)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:2511
#7  0x08351ec5 in _bb_dig_base_util_helper ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.util.helper.bmx.debug.linux.x86.c:1374
#8  0x083437ef in _bb_dig_base_gfx_gui_list_base ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.gfx.gui.list.base.bmx.debug.linux.x86.c:4507
#9  0x083384bc in _bb_dig_base_gfx_gui_list_slotlist ()
    at /home/ronny/Arbeit/Programmieren/Projekte/Apps/TVTower.WorkingCopy/TVTower.git---NG/source/Dig/.bmx/base.gfx.gui.list.slotlist.bmx.debug.linux.x86.c:2639
#10 0x08193b9f in _bb_source_main ()

I do not know whether it is BCC related - or a mix of both. To research I would need to check each combination of "modules", "bmx" and "bcc". This is more than tedious - so I leave that open for you (who surely finds the reason way easier than I need of time to narrow the bug down to a specific revision-mix).

Add support for overloads in reflection.

EnumMethods, for example, doesn't properly distinguish overloads from overrides and can miss results. FindMethod can retrieve a method by name, but doesn't allow specifying which overload to retrieve.

Bmx NG fail to compile brl.appstub on opensuse 13.2

bmk makemods -g x86
Compilng: debugger_mt.stdio.bmx
Compile Error: Missing function argument 'message'
[/home/olejr/bmx-ng/mod/brl.mod/appstub.mod/debugger_mt.stdio.bmx;384;0]

bmk -v
bmk 2.24 linux-x86 / gcc 040803

SetGraphics CanvasGraphics() causes hang

Program below compiles without error. Window opens, but hangs. The line SetGraphics CanvasGraphics(Canvas) is highlighted. Have all updated bcc, bmx, and modules

SuperStrict
Import maxgui.drivers

Global Window:TGadget = CreateWindow("test",10,10,640,400)
Global Canvas:TGadget = CreateCanvas(0,0,ClientWidth(Window),ClientHeight(Window),Window)

Global Timer:TTimer = CreateTimer(30)

Global x:Int = 0

AddHook EmitEventHook, EventHook

Repeat
	WaitEvent()
Forever

Function EventHook:Object(id:Int,data:Object,context:Object)
	Local event:TEvent = TEvent(data)
	
	Select event.id
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE
			End
		Case EVENT_TIMERTICK
			x :+ 1
			If x > 799 Then x = 0
			RedrawGadget Canvas
		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics(Canvas)
			Cls
			DrawOval x-5,100,10,10
			Flip
	End Select
End Function
			

brl.appstub fail to compile threaded (atleast) on OpenSuse & Windows 8.1

bmk makemods -h / bmk makemods -g x64 -h gives:

Compile Error: Illegal type expression
[/brl.mod/appstub.mod/debugger_mt.stdio.bmx;422;0]

Easy fix, just a missing type on function parameter.

But it also throws a Conflicting types for 'bbThreadGetData'.
Don't know if that's the module, or bmk/bcc bug, as some of the lines listed are from the /.bmx folder.

Timer/Event stuck

I was playing around with maxgui and fmodaudio and noticed that maxgui acted really strange for some reason, repeating events. I traced it to fmodaudio and it has something to do with timers and events, check out the example file included (couldn't name it .bmx) - it should emit EVENT_FOO (1337) but it gets replaced with EVENT_BAR (1338) when emitting it after a WaitEvent() call.
Bug.txt

Arrays not displaying in debugger.

You cannot view array contents whilst debugging.
It seems that bbArrayClass is not a registered type, and is therefore not handled correctly by bbGCValidate().

x64 "DebugError: stack underflow"

So now I can't start bmk compiled in 64 bit (Ubuntu 15.04, 64 bit, gcc version 4.9.2)

Steps to reproduce:

  1. compile bmk to linuxx64.
  2. start "bmk makemod -v -g x86" (even without arguments the error occurs.)

there is only the line DebugError: stack underflow on the screen, gdb says the following:

(gdb) r
Starting program: /home/octavian/Programmierung/bmax/bin/bmk makemod -v -g x86
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff62ea700 (LWP 1332)]
[New Thread 0x7ffff6aeb700 (LWP 1331)]
[New Thread 0x7ffff72ec700 (LWP 1330)]

Breakpoint 1, brl_appstub_debugger_mt_stdio_OnDebugLeaveScope ()
    at /home/octavian/Programmierung/bmax/mod/brl.mod/appstub.mod/.bmx/debugger_mt.stdio.bmx.debug.linux.x64.c:1183
1183            brl_appstub_debugger_mt_stdio_DebugError(&_s94);
(gdb) info local
bbt_dbgState = 0x7befc0
(gdb) print *bbt_dbgState
$1 = {clas = 0x6fb940 <brl_appstub_debugger_mt_stdio_TDbgState>, _brl_appstub_debugger_mt_stdio_tdbgstate_mode = 0, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_debuglevel = 0, _brl_appstub_debugger_mt_stdio_tdbgstate_funclevel = 0, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_currentscope = 0x80dc00, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_scopestack = 0x7bfea0, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_scopestacktop = 0, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_exstatestack = 0x7bfd80, 
  _brl_appstub_debugger_mt_stdio_tdbgstate_exstatestacktop = 0}
(gdb) print _brl_appstub_debugger_mt_stdio_tdbgstate_currentscope
No symbol "_brl_appstub_debugger_mt_stdio_tdbgstate_currentscope" in current context.
(gdb) print *bbt_dbgState->_brl_appstub_debugger_mt_stdio_tdbgstate_currentscope
$3 = {clas = 0x6fb800 <brl_appstub_debugger_mt_stdio_TScope>, _brl_appstub_debugger_mt_stdio_tscope_scope = 0x0, 
  _brl_appstub_debugger_mt_stdio_tscope_inst = 0x0, _brl_appstub_debugger_mt_stdio_tscope_stm = 0x0}
(gdb) print *bbt_dbgState->_brl_appstub_debugger_mt_stdio_tdbgstate_scopestack
$4 = {clas = 0x7113c0 <bbArrayClass>, type = 0x4d64ad ":", dims = 1, size = 256, scales = {32}}
(gdb) print *bbt_dbgState->_brl_appstub_debugger_mt_stdio_tdbgstate_exstatestack
$5 = {clas = 0x7113c0 <bbArrayClass>, type = 0x4d64ad ":", dims = 1, size = 256, scales = {32}

It's the correspondig code to this .bmx lines:

Function OnDebugPopExState()

    Local dbgState:TDbgState = GetDbgState()
    GCSuspend

    If Not dbgState.exStateStackTop DebugError "exception stack underflow"

    dbgState.exStateStackTop:-1

    dbgState.scopeStackTop=dbgState.exStateStack[dbgState.exStateStackTop].scopeStackTop

    If dbgState.scopeStackTop
        dbgState.currentScope=dbgState.scopeStack[dbgState.scopeStackTop-1]
    Else
        dbgState.currentScope=New TScope
    EndIf

    GCResume    
End Function

this is the correspondig backtrace:

(gdb) bt
#0  brl_appstub_debugger_mt_stdio_OnDebugLeaveScope ()
    at /home/octavian/Programmierung/bmax/mod/brl.mod/appstub.mod/.bmx/debugger_mt.stdio.bmx.debug.linux.x64.c:1183
#1  0x000000000043e702 in __bmk_ng_TBMK_LoadBMK (o=0x7c3f80, bbt_path=0x820c80)
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_ng.bmx.debug.linux.x64.c:747
#2  0x000000000044b6df in _bmk_ng_LoadBMK (bbt_path=0x820c80)
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_ng.bmx.debug.linux.x64.c:5835
#3  0x000000000044bf14 in _bb_bmk_bmk_ng ()
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_ng.bmx.debug.linux.x64.c:6702
#4  0x000000000043c8dd in _bb_bmk_bmk_util ()
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_util.bmx.debug.linux.x64.c:4742
#5  0x0000000000431909 in _bb_bmk_bmk_modutil ()
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_modutil.bmx.debug.linux.x64.c:2958
#6  0x000000000042a8df in _bb_bmk_bmk_make ()
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_make.bmx.debug.linux.x64.c:4049
#7  0x000000000040b56f in _bb_main ()
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk.bmx.console.debug.linux.x64.c:2319
#8  0x00000000004045fa in __bb_brl_appstub_appstub ()
    at /home/octavian/Programmierung/bmax/mod/brl.mod/appstub.mod/.bmx/appstub.bmx.debug.linux.x64.c:9
#9  0x00000000004044af in main (argc=5, argv=0x7fffffffdea8)
    at /home/octavian/Programmierung/bmax/mod/brl.mod/appstub.mod/appstub.linux.c:18

frame 1:

(gdb) frame 1
#1  0x000000000043e702 in __bmk_ng_TBMK_LoadBMK (o=0x7c3f80, bbt_path=0x820c80)
    at /home/octavian/Programmierung/bmax/src/bmk/.bmx/bmk_ng.bmx.debug.linux.x64.c:747
747                                     bbOnDebugLeaveScope();
(gdb) info local
bbt_e2 = 0x756b20
__scope = {kind = 5051198, name = 0x7fffffffd2e0 "0Lp", decls = {{kind = 0, name = 0x7befc0 "@\271o", 
      type_tag = 0x704c30 <_s61> "\300\025q", {
        const_value = 0x404afa <brl_appstub_debugger_mt_stdio_OnDebugLeaveScope+202>, field_offset = 4213498, 
        var_address = 0x404afa <brl_appstub_debugger_mt_stdio_OnDebugLeaveScope+202>}}, {kind = 7359536, 
      name = 0x7befc0 "@\271o", type_tag = 0x7c2d00 "\200@p", {
        const_value = 0x453fee <brl_maxlua_lua_registerobject+318>, field_offset = 4538350, 
        var_address = 0x453fee <brl_maxlua_lua_registerobject+318>}}}}
__stmt_0 = {source_file = 0x0, line_num = 0, char_num = 0}
ex = <optimized out>
buf = <optimized out>
bbt_e = 0x7ffff736ff90 <__GI___libc_malloc+96>
__scope = {kind = 5071712, name = 0x261 <error: Cannot access memory at address 0x261>, decls = {{kind = 1, 
      name = 0x4d620a "lua_setglobal", type_tag = 0x2 <error: Cannot access memory at address 0x2>, {
        const_value = 0x4d614e, field_offset = 5071182, var_address = 0x4d614e}}, {kind = 5088054, 
      name = 0x7fffffffd2e8 " ku", type_tag = 0x2 <error: Cannot access memory at address 0x2>, {const_value = 0x4d5410, 
        field_offset = 5067792, var_address = 0x4d5410}}}}
__stmt_0 = {source_file = 0x100000002 <error: Cannot access memory at address 0x100000002>, line_num = 348345088, 
  char_num = 1181975205}
ex = <optimized out>
buf = <optimized out>
bbt_str = 0x711580 <bbEmptyString>
bbt_pos = 0
---Type <return> to continue, or q <return> to quit---
bbt_inDefine = 0
bbt_text = 0x711580 <bbEmptyString>
bbt_name = 0x711580 <bbEmptyString>
__scope = {kind = 1, name = 0x4d5a56 "LoadBMK", decls = {{kind = 2, name = 0x4d5349 "path", type_tag = 0x4d133e "$", {
        const_value = 0x7fffffffce88, field_offset = 140737488342664, var_address = 0x7fffffffce88}}, {kind = 2, 
      name = 0x4d5584 "str", type_tag = 0x4d133e "$", {const_value = 0x7fffffffcea0, field_offset = 140737488342688, 
        var_address = 0x7fffffffcea0}}, {kind = 2, name = 0x4da9f9 "pos", type_tag = 0x4d15b3 "i", {
        const_value = 0x7fffffffce94, field_offset = 140737488342676, var_address = 0x7fffffffce94}}, {kind = 2, 
      name = 0x4d53f4 "inDefine", type_tag = 0x4d15b3 "i", {const_value = 0x7fffffffce98, 
        field_offset = 140737488342680, var_address = 0x7fffffffce98}}, {kind = 2, name = 0x4d5404 "text", 
      type_tag = 0x4d133e "$", {const_value = 0x7fffffffcea8, field_offset = 140737488342696, 
        var_address = 0x7fffffffcea8}}, {kind = 2, name = 0x4d5410 "name", type_tag = 0x4d133e "$", {
        const_value = 0x7fffffffceb0, field_offset = 140737488342704, var_address = 0x7fffffffceb0}}, {kind = 0, 
      name = 0x0, type_tag = 0x0, {const_value = 0x0, field_offset = 0, var_address = 0x0}}}}
__stmt_0 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 52, char_num = 0}
__stmt_1 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 53, char_num = 0}
__stmt_2 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 85, char_num = 0}
__stmt_3 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 85, char_num = 0}
__stmt_4 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 85, char_num = 0}
__stmt_5 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 85, char_num = 0}
__stmt_6 = {source_file = 0x4d5d30 "/home/octavian/Programmierung/bmax/src/bmk/bmk_ng.bmx", line_num = 87, char_num = 0}

Segfault with reflection and arrays

I am using this code to clone objects:

    'clones the given object
    'function is calling itself recursively for each property
    'returns the cloned object
    Function CloneObject:object(obj:object)
        'clone code is based on the work of "Azathoth"
        'http://www.blitzbasic.com/codearcs/codearcs.php?code=2132

        'skip cloning nothing
        If obj = Null Then Return Null

        'to access properties we need a TTypeID of the object
        Local objTypeID:TTypeId=TTypeId.ForObject(obj)


        '=== STRINGS ===
        If objTypeID.ExtendsType(StringTypeId) then return String(obj)


        '=== ARRAYS ===
        If objTypeID.ExtendsType(ArrayTypeId)
            'if an array does not contain elements, the reflection
            'cannot recognize which type the array contains (Null[])

            'accessing this "null[]"-arrays would lead to a thrown
            'error - so we need "try" to catch the exception.
            'Thanks to Brucey's persistence.mod (doing it similar)

            'objects name might be TMyType[] - remove the []-part
            Local objTypeName:string = objTypeID.name()[..objTypeID.name().length - 2]
            Local size:Int
            Try
                size = objTypeID.ArrayLength(obj)
            Catch e$
                objTypeName = "Object"
                size = 0
            End Try

            'if the object does not contain things in that array, the
            'copy wont need it too
            If size = 0 then return Null

            'create new array
            local clone:object = objTypeID.NewArray(objTypeID.ArrayLength(obj))
            'something failed, return a null object
            If not clone then return Null

            'clone each element of the array
            For Local i:int=0 Until objTypeID.ArrayLength(obj)
                'run recursive clone for arrays, objects and strings
                If objTypeID.ElementType().ExtendsType(ArrayTypeId) or objTypeID.ElementType().ExtendsType(StringTypeId) or objTypeID.ElementType().ExtendsType(ObjectTypeId)
                    objTypeID.SetArrayElement(clone, i, CloneObject(objTypeID.GetArrayElement(obj, i)))
                Else
                    objTypeID.SetArrayElement(clone, i, objTypeID.GetArrayElement(obj, i))
                EndIf
            Next

            return clone
        EndIf


        Local clone:object

        'use the objects specific clone method instead of our
        'generic approach
        'call a method "CloneObject:Int(original:obj)"
        Local mth:TMethod = objTypeID.FindMethod("CloneObject")
        If mth
            clone = objTypeID.NewObject()
            mth.Invoke(clone, [obj])
        Else

            '=== LISTS ===
            If objTypeID.ExtendsType(ListTypeID)
                local list:TList = CreateList()
                For local entry:object = EachIn TList(obj)
                    list.AddLast( CloneObject(entry) )
                Next
                return list
            EndIf


            '=== TMAPS ===
            If objTypeID.ExtendsType(MapTypeID)
                local map:TMap = CreateMap()
                For local key:string = EachIn TMap(obj).Keys()
                    map.Insert(key, CloneObject(TMap(obj).ValueForKey(key)) )
                Next
                return map
            EndIf   


            '=== OBJECTS ===
            'create a new instance of the objects type
            'Local clone:object = New obj
            clone = objTypeID.NewObject()

            'loop over all fields of the object
            For Local fld:TField=EachIn objTypeID.EnumFields()
                Local fldId:TTypeId=fld.TypeId()

                'only clone non-null-fields and if not explicitely forbidden
                If fld.Get(obj) And fld.MetaData("NoClone") = Null
                    'if explizitely stated, clone referenceable objects by
                    'reusing their reference, else deep clone it
                    If fld.MetaData("CloneUseReference")
                        fld.Set(clone, fld.Get(obj))
                    Else
                        fld.Set(clone, CloneObject(fld.Get(obj)))
                    EndIf
                EndIf
            Next
        EndIf

        'inform the clone that it got cloned
        'call a method "onGotCloned:Int(original:obj)"
        mth = objTypeID.FindMethod("onGotCloned")
        If mth then mth.Invoke(clone, [obj])

        Return clone
    End Function    

Using it, segfaults for me:

Program received signal SIGSEGV, Segmentation fault.
0x0859c949 in brl_reflection_TTypeId_ForObject (bbt_obj=0xc4322d0)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:2497
2497            return (((struct brl_reflection_TTypeId_obj*)bbt_)->clas)->md_ArrayType(bbt_,1);

Backtrace:

#0  0x0859c949 in brl_reflection_TTypeId_ForObject (bbt_obj=0xc4322d0)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/mod/brl.mod/reflection.mod/.bmx/reflection.bmx.debug.linux.x86.c:2497
#1  0x08350475 in _base_util_helper_THelper_CloneObject (bbt_obj=0xc4322d0)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/TVTower-master/source/Dig/.bmx/base.util.helper.bmx.debug.linux.x86.c:459
#2  0x08351c3d in _base_util_helper_THelper_CloneObject (bbt_obj=0xe28f7f8)
    at /home/ronny/Arbeit/Programmieren/BlitzMaxNG/TVTower-master/source/Dig/.bmx/base.util.helper.bmx.debug.linux.x86.c:896

The last line in the c-file references fld.Set(clone, CloneObject(fld.Get(obj))) (when iterating over fields).
The second last line references the portion

    'to access properties we need a TTypeID of the object
    Local objTypeID:TTypeId=TTypeId.ForObject(obj)

I printed out the field name right before "fld.Set()" and it was the field "cast" in my case, which is defined as Field cast:TProgrammePersonJob[] (an array).

So somehow this crashes when "obj" is an array of this type. I tried to reproduce it in a simple example but it did not crash for this. Maybe I am interpreting the BackTrace in a wrong way?

Receiving the following error building for Windows

Apologies if this has already been mentioned elsewhere, building on Windows gives the following message with the latest commit

D:/BlitzMaxNG/BlitzMax/mod/brl.mod/dxgraphics.mod/.bmx/d3d9graphics.bmx.debug.win32.x64.c: In function '_bb_brl_dxgraphics_d3d9graphics':
D:/BlitzMaxNG/BlitzMax/mod/brl.mod/dxgraphics.mod/.bmx/d3d9graphics.bmx.debug.win32.x64.c:2429:39: error: incompatible types when assigning to type 'struct pub_directx_d3d9_D3DCAPS9' from type 'int'
brl_dxgraphics_d3d9graphics__d3dCaps=pub_directx_d3d9_D3DCAPS9_New_ObjectNew();

brl.appstub fail to compile

Windows 8.1 x64, MinGW (x64) v4.8.1, bmk v3.00 (compiled as x86)

bmk makemods -g x64

Error out with:
Interal Error:
[/mod.brl.mod/appstub.mod/debugger_mt.stdio.bmx;86;0]

Same thing when trying only to compile brl.appstub

Seek() + WriteLine() in streams creating garbage

The following code creates a file "ng_logger.txt". The expected output is

Header
line0
line1
...
line10

But instead it consists of 0-bytes and the last line:
ghex

SuperStrict
Framework Brl.StandardIO
Import Brl.Retro


Global fileName:String = "ng_logger.txt"
Global headerWritten:Int = False
For Local i:Int = 0 To 10
    Local size:Int = FileSize(filename)
    If size = -1
        Print "file missing. creating ..." 
        If Not CreateFile(filename)
            Throw "Cannot create logfile: "+filename
        EndIf
    EndIf
    Local file:TStream = WriteFile(filename)

    If Not headerWritten
        WriteLine(file, "Header")
        headerWritten = True
    'if we already have written the header, move to the end of
    'the file
    Else
        'the problematic part ?
        file.Seek(size)
    EndIf
    WriteLine(file, "line"+i)

    CloseFile(file)
Next

"Seek" seems to correctly move the position. BUT ... when not using "seek" (eg only doing "header" + "line0" it is correctly stored in the file).

SIGSEV with brl.mod/map.mod

When trying to build maxide for linux 64 bit I get a segfault during execution:

Program received signal SIGSEGV, Segmentation fault.
0x00000000005fe04c in brl_map_MapKeys (bbt_map=0x993ed0)
    at /BlitzMaxNG/mod/brl.mod/map.mod/.bmx/map.bmx.debug.linux.x64.c:2820
2820        return (bbt_map)->clas->md_Keys(bbt_map);

Might be an bcc-issue (but you could cross-close the issue referencing it from within bcc.git)

Fail to compile on windows

After splitting the system.mod, the timer.mod and glgraphics.mod
fail to compile on windows. (brl.mod/system.mod/system.h no such file)

In glgraphics.win32.c and timer.win32.c change #include

brl.mod/system.mod/system.h
to
brl.mod/systemdefault.mod/system.h

Unable to convert from TSystemDriver to IWrappedSystemDriver.

Fetched / compiled latest BMK
Fetched latest brl and pub.mod - and tried to run /.bmk makemods -a -r brl (brl to avoid the long pub.glew compilation times ;-))

Compile Error: Unable to convert from TSystemDriver to IWrappedSystemDriver.
[/BlitzMaxNG/mod/brl.mod/system.mod/driver.bmx;48;0]
Build Error: failed to compile (65280) /BlitzMaxNG/mod/brl.mod/system.mod/driver.bmx

Edit: hmm, will have to try to update bcc first :-)

TIntMap._FirstNode returns new node, not first node

This is TIntMap's _FirstNode:

	Method _FirstNode:TIntNode()
		If Not IsEmpty() Then
			Local node:TIntNode= New TIntNode
			node._root = _root
			Return node
		Else
			Return Null
		End If
	End Method

This is TMap's _FirstNode:

	Method _FirstNode:TNode()
		Local node:TNode=_root
		While node._left<>nil
			node=node._left
		Wend
		Return node
	End Method

TMap will traverse from _root to the first node, TIntMap will return a new node instead.

Example:

SuperStrict
Framework Brl.StandardIO
Import Brl.Map
 
Local mymap:tintmap=New tintmap
mymap.insert(1,"one")
mymap.insert(2,"two")
mymap.insert(3,"three")
 
Local m:TIntNode = mymap._firstnode() 'root
'uncomment to make it work
'm=m.nextnode()
While m<>Null
        Local v:String = String(m.value())
        m=m.nextnode()
Wend

Bug source: https://www.syntaxbomb.com/index.php/topic,4187.15.html

Binary Shifting Byte Ptr-entries has different result in NG than vanilla

NG-TPixmap.ReadPixel() is having problems with "PF_A8"-format. It is doing the same in vanilla and NG so further analysis has shown that the returned values differ because of the calculation returning "wrong" values.

SuperStrict
Framework Brl.StandardIO
Import Brl.Pixmap

Local p:TPixmap = CreatePixmap(5,1, PF_A8) '1 alpha channel

'using white results in "c" (found in for-loop) to get:
'NG c=-16776961      vanilla c=-1
'using black with 0 alpha
'NG c=255            vanilla c=16777215

'local color:Int = ARGB_COLOR(255, 255, 255, 255) ' "-1"
local color:Int = ARGB_COLOR(0, 0, 0, 0) ' "0"
For Local x:Int = 0 Until 5
    WritePixel(p, x,0, color)
Next

For Local x:Int = 0 Until 5
    'this is the calculation done in "ReadPixel" for "PF_A8" format
    Local p:Byte Ptr = p.PixelPtr(x,0)
    Local c:Int = p[0] Shl 24 | $00ffffff
    'Local c:Int = ReadPixel(p, x,0)

    'vanilla: "16777215", ng: "255"
    Print x+","+0+": c="+c+" = "+ARGB_Red(c)+","+ARGB_Green(c)+","+ARGB_Blue(c)+" a="+ARGB_Alpha(c)
Next


'these functions expect a int value, not a byte
Function ARGB_Alpha:Int(ARGB:Int); Return (argb Shr 24) & $ff; End Function
Function ARGB_Red:Int(ARGB:Int); Return (argb Shr 16) & $ff; End Function
Function ARGB_Green:Int(ARGB:Int); Return (argb Shr 8) & $ff; End Function
Function ARGB_Blue:Int(ARGB:Int); Return (argb & $ff); End Function
Function ARGB_Color:Int(alpha:Int,red:Int,green:Int,blue:Int)
    Return (Int(alpha * $1000000) + Int(red * $10000) + Int(green * $100) + Int(blue))
End Function

Seems it comes down to this calculation resulting in different values:

Local p:Byte Ptr = p.PixelPtr(x,y)
Local c:Int = p[0] Shl 24 | $00ffffff

BTW this is the reason why my bitmapfont-classes create blue text on bitmaps (another one to get squashed :-) )

MaxLua: Invoking functions/methods does not properly check params

MaxLua does not check if it fetches valid userdata when invoking a types method/function.

So a "mytype.Get(10)" with "Method Get:int(o:othertype)" might segfault.

old

Function Invoke( L:Byte Ptr )
....
    For Local i=0 Until args.length
        Select tys[i]
        Case IntTypeId, ShortTypeId, ByteTypeId, LongTypeId
            args[i]=String.FromInt( lua_tointeger( L,i+1 ) )
        Case FloatTypeId
            args[i]=String.FromFloat( lua_tonumber( L,i+1 ) )
        Case DoubleTypeId
            args[i]=String.FromDouble( lua_tonumber( L,i+1 ) )
        Case StringTypeId
            args[i]=lua_tostring( L,i+1 )
        Default
            args[i]=lua_unboxobject( L,i+1 )
        End Select
    Next

suggestion

    For Local i=0 Until args.length
        Select tys[i]
        Case IntTypeId, ShortTypeId, ByteTypeId, LongTypeId
            args[i]=String.FromInt( lua_tointeger( L,i+1 ) )
        Case FloatTypeId
            args[i]=String.FromFloat( lua_tonumber( L,i+1 ) )
        Case DoubleTypeId
            args[i]=String.FromDouble( lua_tonumber( L,i+1 ) )
        Case StringTypeId
            args[i]=lua_tostring( L,i+1 )
        Default
            if lua_isnil(L, i + 1)
                'correctly pass null
                args[i] = null
            elseif lua_isuserdata(L, i + 1)
                'got valid data to unbox
                local obj:object = lua_unboxobject(L, i + 1)
                'given param derives from requested param type
                if TTypeID.ForObject(obj).ExtendsType(tys[i])
                    args[i] = obj
                else
                    print "MaxLua - Invoke(): "+meth.name()+"() got broken param #"+i+" (expected ~q"+tys[i].name()+"~q, got ~q"+TTypeID.ForObject(obj).name()+"~q). Falling back to ~qNull~q."
                    args[i] = null
                endif
            else
                'something "non object" got passed
                print "MaxLua - Invoke(): "+meth.name()+"() got broken param #"+i+" (expected ~q"+tys[i].name()+"~q). Falling back to ~qNull~q."
                args[i] = null
            endif
        End Select
    Next

This change now does:

  • handles wrong params (avoiding segfaults)
  • accept wrong params (maybe give an exception similar to compiler errors when using wrong types?)

We cannot generally use "TTypeID.ForObject()" on all params as this only works for "userdata"-objects and not numerics and other basic types.

Debugger crashes when it sees unreachable pointers

I just spent a long time taking everything in my own code, in bcc, and in the runtime libraries apart to hunt an unbeliavably hard to find bug that was making my program crash. The fact that I just had made modifications to bcc and the runtime for this didn't do me any favours, but as it turns out, the crash came from the debugger itself. (Took me about a day even figuring that out, I was banging my head against the wall trying to understand why my code seemed to crash on an addition...)
The problem: The current version of debugger_mt.stdio.bmx attempts to dereference any pointer that it sees, with the exception of "Byte Ptr"s, to display the value that it points to. This is really bad, because it means that if the debugger ever encounters a pointer that doesn't currently point to accessible memory (or to NULL, it checks against that), it will instantly go boom.
I've looked into ways to check whether a pointer can be safely dereferenced, but it doesn't really seem to be possible. Apparently there are OS-specific ways to do this, but they come with their own sets of problems. I've taken the feature out for now and made a pull request here.

Can't compile lua.bmx during module build

Building Modules
[ 45%] Processing:debugger_mt.stdio.bmx
[ 46%] Processing:sample.bmx
[ 46%] Processing:d3d7max2d.bmx
[ 46%] Processing:d3d9max2d.bmx
[ 46%] Processing:data.bmx
[ 46%] Processing:directsoundaudio.bmx
[ 47%] Processing:dxgraphics.bmx
[ 47%] Processing:font.bmx
[ 47%] Processing:hook.bmx
[ 47%] Processing:keycodes.bmx
[ 47%] Processing:linkedlist.bmx
[ 47%] Processing:intmap.bmx
[ 48%] Processing:objectmap.bmx
[ 48%] Processing:ptrmap.bmx
[ 48%] Processing:stringmap.bmx
[ 48%] Processing:math.bmx
[ 48%] Processing:pixel.bmx
[ 49%] Processing:random.bmx
[ 49%] Processing:driver.bmx
[ 49%] Processing:threads.bmx
[ 49%] Processing:gadgetitem.bmx
[ 49%] Processing:guifont.bmx
[ 49%] Processing:win32maxguiex.bmx
[ 50%] Processing:directx.bmx
[ 50%] Processing:freeaudio.bmx
[ 50%] Processing:glew.bmx
[ 50%] Processing:joystick.bmx
[ 50%] Processing:libjpeg.bmx
[ 50%] Processing:lua.bmx
Compile Error: Invalid Pointer type.
[/Volumes/Irravonia/BlitzMAX/NG/mod/pub.mod/lua.mod/lua.bmx;268;0]
Build Error: failed to compile /Volumes/Irravonia/BlitzMAX/NG/mod/pub.mod/lua.mod/lua.bmx
Process complete

Faulty code:

Rem
bbdoc: see <a href="../lua-5.1.4/doc/manual.html#lua_getinfo">Lua Reference Manual</a>
end rem
  Function lua_getinfo:Int (lua_state:Byte Ptr, what$z, ar:lua_Debug Ptr)    ' no ~0 expected

I wonder if this is due to the fixes on bmx-ng/bcc#200 and bmx-ng/bcc#202

Non-Debug Print causing Exception Access Violation

Hi Brucey, following on from my last post on Newton.mod, I've re-downloaded the latest ng via Frisky, after a fresh build from scratch failed, and I still get "EXCEPTION_ACCESS_VIOLATION" from bcc -- or any program that uses Print without Debug enabled -- at runtime (no build problems).

My previous working setup still works, but obviously can't be updated with all the latest stuff!

Sorry to become the bane of your life lately! :P

Reflection and Structs

There is currently no support for Structs whatsoever.
Structs currently have no TTypeIds and are completely invisible to reflection. Any members of other types that involve them (such as a method that takes a struct parameter, or a field inside a class that stores a struct) are invisible as well.

WParam and LParam

Hiya,

I'm just curious as to why you've made wparam and lparam as a built-in type?

Missing abstract methods in reflection

This was not the case in vanilla, where they would show up as Type members just like normal methods; in NG they currently seem to be invisible to reflection.

Reflection overhaul

As I mentioned in one of the bcc issue discussions before, I've been looking into updating the BRL.Reflection module. Especially lately, as several new features have been introduced to NG, reflection hasn't really kept up.

Current major issues include:

  • 1) Problems with the identity of function type ids. These were already present in vanilla, but should be fixed nonetheless. [code 1]
  • 2) No support for overloading. EnumMethods, for example, doesn't properly distinguish overloads from overrides and can miss results. FindMethod can retrieve a method by name, but doesn't allow specifying which overload to retrieve.
  • 3) No support for top-level functions, globals and consts that aren't members of a type. These are not supported in vanilla either, but would be nice to have.
  • 4) No support for abstract methods. This was not the case in vanilla, where they would show up as Type members just like normal methods; in NG they currently seem to be invisible to reflection.
  • 5) No support for access modifiers. Being able to tell public, protected and private members apart should definitely be possible.
  • 6) No support for parameterized constructors. New objects can only be created using TTypeIDs.NewObject, which uses the default constructor.
  • 7) Only partial support for Interfaces. For example, it is not possible to get the super interfaces inherited by a given interface. TTypeId.Methods doesn't work as expected on interfaces either.
  • 8) No support for Structs whatsoever. Structs currently have no TTypeIds and are completely invisible to reflection. Any members of other types that involve them (such as a method that takes a struct parameter, or a field inside a class that stores a struct) are invisible as well.
  • 9) No support for nested types and generics.
  • 10) TFunction.Invoke and TMethod.Invoke. From what I can see, the current implementation allocates an array of pointers, stores the arguments in it (whether they are actually pointers or not), and then calls the function with them, treating it as if it accepted a set pointer arguments. This seems unsafe (how portable can this be? [code 2] crashes for me when compiled for x86 Windows for example), and it also precludes struct support since structs can have any size.

So how to fix that? These are my plans:

  1. Pretty straightforward. Can be fixed in reflection.bmx.
  2. Ditto.
  3. Would require modifying bcc to add some sort of "top-level" debugscope to the generated C, I suppose? I haven't looked into that yet, but it seems doable.
  4. They are invisible because they aren't listed in the type's debugscope for some reason. Haven't looked into it yet.
  5. Requires changes to both reflection.bmx and bcc, but is otherwise simple. Visibility attributes can be inserted into the member's debugdecl as part of its type tag, like meta data already is.
  6. Parameterized constructors are currently not properly inserted into the type's debugscope, they're listed either as functions or not at all. Once that is fixed, TTypeID.NewObject can get an overload that takes one of the type's constructors (as a TMethod) and an argument list as its parameters.
  7. It seems like relationships between different interfaces are currently not preserved at runtime at all, and inheritance chains are flattened: every "interface" in the generated C directly contains the definitions from what used to be its super interfaces on the BlitzMax side. Can be solved by simply giving the interfaces interface tables of their own, like classes have. This only needs a minor change in bcc, the rest can be done in reflection.bmx.
  8. Making structs visible as TypeIds is not all that hard. Debug scopes for them are already built, and every struct type goes through bbObjectRegisterStruct in blitz_object.c. Giving TGlobal and TField.Get and .Set support for struct instances can be achieved by boxing/unboxing them to and from objects. GetStruct and SetStruct methods as an equivalent to GetInt etc. can also be added, although they will need pass and return pointers to the struct instances instead of the instances themselves.
  9. The introduction of generics means that there will have to be TTypeId instances for generic base types as well as their instantiations (with concrete types assigned to the type parameters). The type parameters themselves should have some sort of representation, maybe as TTypeIds, maybe as something else. Nested types and generic functions will also have to be considered.
    However, generics might also be worth using in the reflection module itself. For example, the common way for reflection-using code to get the TTypeId object for a class is TTypeId.ForName("TSomething"), or TTypeId.ForObject(obj). The former is prone to mistakes, while the latter requires an existing instance and doesn't work on primitives or structs. With generics, we will be able to provide TTypeId.Of<TSomething>() as a more elegant alternative.
  10. This is the hardest one. The current way of calling functions/methods via reflection can not only lead to crashes, it also puts a hard limit on the total memory size of the parameter list, making struct compatibility pretty much impossible.
    Thus, my idea is this:
    Since Invoke is a method of TMethod and TFunction, it has access to the corresponding debugdecls. It knows the TTypeId of the function/method, which means it knows the number and size of the expected arguments and return type. The only problem is putting them together into a function pointer type to make the actual call, since we can't really do that at runtime.
    So what if we have bcc generate an additional wrapper function to every Function or Method for use with Invoke? This wrapper would take pointers to the actual arguments and forward the values to the actual function.
    For example, this method:
Type T
	Method testmethod:T(a:Int, b:Byte, c:Long, d:String, e:Float Ptr)
	End Method
End Type

which creates the following C code:

struct _m_untitled145_T_obj* __m_untitled145_T_testmethod_iblSpf(struct _m_untitled145_T_obj* o,BBINT bbt_a,BBBYTE bbt_b,BBLONG bbt_c,BBSTRING bbt_d,BBFLOAT* bbt_e){
	return &bbNullObject;
}

could get a wrapper like this:

void __m_untitled145_T_testmethod_iblSpf_invokewrapper(struct _m_untitled145_T_obj** retValAddr, struct _m_untitled145_T_obj* o,BBINT* bbt_a,BBBYTE* bbt_b,BBLONG* bbt_c,BBSTRING* bbt_d,BBFLOAT** bbt_e){
	*retValAddr = __m_untitled145_T_testmethod_iblSpf(o,*bbt_a,*bbt_b,*bbt_c,*bbt_d,*bbt_e);
}

A pointer to that wrapper would be then added to the debugdecl. Unlike the original functions, all wrappers created this way would have uniformly sized parameters, as they're all pointers.
Invoke would then retrieve the wrapper, pass it pointers to the arguments, and catch the result in a previously allocated memory block of sufficient size.

Any thoughts/opinions on this approach? As far as I can tell, this should work, allow full support for structs and possibly also be more portable. If there isn't anything I'm missing, I could try implementing this (as well as the other things mentioned above).
It would still impose a limit on the maximum number of parameters, but that would be more predictable than the limits of the current implementation and in vanilla.
It would also generate an extra C function for every function and method written in BlitzMax; whether this would have any noticable performance/memory impact I don't know. In theory it could be optimized to only generate only one wrapper for every unique function type signature in the program instead of one every method/function, but that would be harder to implement. Or each wrapper could take only one parameter which points to an array containing all the other pointers or to a memory block containing the arguments themselves, which would eliminate the parameter count limit.

[code 1]

SuperStrict
Framework BRL.Reflection

Type T
	Method M1:Int(f:Float) End Method
	Method M2:Int(f:Float) End Method
End Type

Local tid1:TTypeId = IntTypeId; tid1 = tid1.functiontype([FloatTypeId])
Local tid2:TTypeId = IntTypeId; tid2 = tid2.functiontype([StringTypeId])
Local eq:Int = tid1 = tid2	' this should be False, but is True

Local m1tid:TTypeId = TTypeId.ForName("T").FindMethod("M1").TypeId()
Local m2tid:TTypeId = TTypeId.ForName("T").FindMethod("M2").TypeId()
Local eq_:Int = m1tid = m2tid	' this should be True, but is False

[code 2]

SuperStrict
Framework BRL.Reflection
Import BRL.StandardIO

Local a_:Int = 1
Local b_:Byte = 2
Local c_:Long = 3
Local d_:String = "blub"
Local e_:Float = 5.5
TTypeId.ForName("T").FindMethod("M").Invoke(New T, [String(a_), String(b_), String(c_), d_, String(Long Varptr e_)]) ' boom

Type T
	Method M:T(a:Int, b:Byte, c:Long, d:String, e:Float Ptr)
		Print "Self="+Self.ToString()
		Print "a="+a
		Print "b="+b
		Print "c="+c
		Print "d="+d
		Print "e=&"+e[0]
	End Method
End Type

Debugging x64

Debugging at least in linux x64 throws the error Invalid scope kind.
The Error is thrown in brl_appstub_debugger_mt_stdio_DebugScopeKind (brl.mod/appstub.mod/debugger.mt.stdio.bmx in the Function DebugScopeKind$(scope:Int Ptr))

! I haven't tested this in x86 since compiling bcc-ng with it self does not throw an error !

Steps to reproduce:
0. Start Linux

  1. Build bcc-ng in 64 Bit.
  2. Build bcc-ng using bcc-ng in a terminal
  3. get "Index out of bounds exception"
  4. press "t" to view stacktrace.

some gdb test I've run:

Breakpoint 1, brl_appstub_debugger_mt_stdio_DebugScopeKind (bbt_scope=0x7fffffff9e10)
    at /home/octavian/Programmierung/bmax/mod/brl.mod/appstub.mod/.bmx/debugger_mt.stdio.bmx.debug.linux.x64.c:643
643     brl_appstub_debugger_mt_stdio_DebugError(bbStringConcat(&_s62,bbStringFromInt(bmx_debugger_DebugScopeKind(bbt_scope))));
(gdb) info local
bbt_scope = 0x7fffffff9e10
bbt_ = 0
(gdb) info locals
bbt_scope = 0x7fffffff9e10
bbt_ = 0
(gdb) print *(struct BBDebugScope*)bbt_scope
$1 = {kind = 0, name = 0x0, decls = {{kind = 0, name = 0x0, type_tag = 0x0, {const_value = 0x0, field_offset = 0, 
        var_address = 0x0}}}}
(gdb) print *(struct BBDebugScope*)bbt_scope
$1 = {kind = 0, name = 0x0, decls = {{kind = 0, name = 0x0, type_tag = 0x0, {const_value = 0x0, field_offset = 0, 
        var_address = 0x0}}}}

So "kind" is 0 (zero) which dosn't match to:

'DEBUGSCOPE_KIND values
Const DEBUGSCOPEKIND_FUNCTION:Int=1
Const DEBUGSCOPEKIND_TYPE:Int=2
Const DEBUGSCOPEKIND_LOCAL:Int=3

Pointer problems...

Compiling:freetypefont.bmx
/BlitzMaxNG/mod/brl.mod/freetypefont.mod/freetypefont.bmx<106> : Error : NULL
Archiving:freetypefont.release.linux.x86.a

Compiling:gnet.bmx
/BlitzMaxNG/mod/brl.mod/gnet.mod/gnet.bmx<428> : Error : NULL
Archiving:gnet.release.linux.x86.a

Compiling:tgaloader.bmx
/BlitzMaxNG/mod/brl.mod/tgaloader.mod/tgaloader.bmx<62> : Error : NULL
Archiving:tgaloader.release.linux.x86.a

gnet.bmx line is:
If Not enet_host_service( _enetHost,ev,0 ) Return

freetypefont.bmx line is:
MemCopy slot,_face.glyphslot,SizeOf slot

tgaloader.bmx line is:
If stream.ReadBytes( hdr,8 )<>8 Return Null

  • stream.ReadBytes awaits (byte ptr, int)
    -> If stream.ReadBytes( Varptr i,8 )<>8 Return Null
    compiles fine.
    Seems that pointer handling is not correct atm
  • enet_host_service awaits (Byte Ptr, Byte Ptr, int)
    -> think it is the same problem
  • freetypefont: glyphslot is an "Int Ptr", maybe that it the flaw...

Brl.linkedlist: TLink.Remove() bypasses TList._count-cache

In short:

If you manipulate a TList via TLink.Remove() you bypass any adjustment to the cached _count-property.

So "list.count()" stays the same - even with entries getting removed.

SuperStrict
Framework Brl.Retro
Import Brl.LinkedList

Local entry:TList = New TList 'just an object to add
Local l:TList = New TList
For Local i:Int = 0 Until 10
	l.AddLast(entry)
Next

Print l.Count()
l.FirstLink().Remove()
Print l.Count()

For details:
http://www.blitzmax.com/Community/posts.php?topic=107656#1334461

Another compile error on windows

After brl.threads got an overhaul/fix, the brl.linkedlist mod fail to compile in threaded mode on windows.

ie: bmk makemods -h brl.linkedlist

makemods -a fails: Compile Error: Can't find interface for module 'brl.blitz'

Steps to reproduce:

  1. Use Linux 64bit (Ubuntu 14.10 in my case)
  2. clone bmx-ng/bcc.git and bmx-ng/bmk.git
  3. clone bmx-ng/brl.mod.git and bmx-ng/pub.mod.git to "bmax/mod" (make sure the folder was empty before.)
  4. build them via "BlitzMax/bin/bmk makeapp -t console -r -h bcc.bmx" (same for bmk.bmx)
  5. copy to bmax/bin:
    bcc
    bcc.conf.default (remove ".default" and change the path in it)
    bmk
    core.bmk
    make.bmk
  6. execute "bmax/bin/bmk makemods -a"

Note:

bmax is the directory for bmax-ng, "BlitzMax" is the directory of the legacy BlitzMax-Installation.

expected result:

all mods (pub and brl) should be build without error messages.

what actually happened:

compiler stops with the error: "Compile Error: Can't find interface for module 'brl.blitz'"
full ouptut: http://pastebin.com/9nUnykZj

Wrong number of arguments to SendMessage

SendMessage is declared with only two arguments in blitz_object.h, yet code is (correctly) generated to pass it three, resulting in the C compiler getting upset:

error: too many arguments to function call, expected 2, have 3
        BBOBJECT volatile bbt_=(bbt_win)->clas->SendMessage(bbt_win,&_s5,o->__m_eventlog_eventlog_msgs );
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reflection: Metadata gone missing

I cannot explain it exactly - and even more, cannot give a (non) working example.

  • I expose objects/methods/functions/properties to LUA using reflection
  • I limit this expose via metadata
  • {_exposeToLua} -> expose everything below
  • {_exposeToLua="selected"} -> expose everything having its own {_exposeToLua}-meta-data

Now my app with NG blames that the lua scripts try to call methods not exposed. In vanilla they are happily exposed - and accessible.
I tried to make it reproduceable in a small example using the same logic (function stripped down a bit), but there... it just worked.

Is there a chance that the "complexity" of my bigger project creates the hassle? (compared to a small single-file-sample just having a handful of types and extends).

I checked the "metadata" of the object in my engine - and they seems to be empty in the failing-cases (compiled with NG, in vanilla they are "filled").

Ideas how to narrow it down?

LuaEngine:
https://github.com/GWRon/Dig/blob/master/base.util.luaengine.bmx
"Filtering" is done in "TLuaEngine.Index()"

Like said, If I copy this code and use it in a simple example, with some simple classes, it just "works" as expected...
Also this portion is not encapsulated as I wanted it to be - so the problematic portion is in the "main"-file which includes many things and the resulting c-file is 2.8mb in release or 6.7mb in debug ...so not that small). This makes it really hard to strip down the whole project for narrowing down the source of the flaw.

BRL.Reflection does not retrieve Method and Function types correctly

Out of interest, I made a small program outputting the results of TTypeId.EnumTypes(), to see if I could spot any differences between my vanilla BlitzMax installation (using an older brl.mod, not this one here) and NG. What I found is that in NG, all function reference types are missing.
When trying to get the TTypeId of a function or method, the function/method's return type is returned instead.

Sample code:

SuperStrict
Framework BRL.Reflection
Import BRL.StandardIO

Type T
    Method F(a0:Int, a1:Float, a2:String)
    End Method
End Type

Local ftid:TTypeId = TTypeId.ForName("T").FindMethod("F").TypeID()
Print "full type: " + ftid.Name()
Print "return type: " + ftid.ReturnType().Name()
Local argtids:TTypeId[] = ftid.ArgTypes()
For Local i:Int = 0 Until argtids.Length
    Print "arg" + i + " type: " + argtids[i].Name()
Next

The output produced by my vanilla BlitzMax installation is

full type: Int(Int,Float,String)
return type: Int
arg0 type: Int
arg1 type: Float
arg2 type: String

The expected output for NG is

full type: Void(Int,Float,String)
return type: Void
arg0 type: Int
arg1 type: Float
arg2 type: String

Instead, the actual output is

full type: Void

followed by a "TypeID is not a function type" exception.

So I've located this code around line 2250 in reflection.bmx :

                        If bbDebugDeclKind(p) = 6 Then ' method
                            _methods.AddLast New TMethod.Init(id, retType, meta, Self, bbDebugDeclVarAddress(p), argTypes)
                        Else ' function
                            _functions.AddLast New TFunction.Init(id, retType, meta, Self, bbDebugDeclVarAddress(p), argTypes)
                        End If

Replacing both instances of "retType" in above code with "TypeIdForTag(ty)" seems to fix the problem at first glance.
But as I'm not familiar with the internals of BlitzMax I'm not sure if that's all that needs to be done.

Invocation through reflection

Improve the current implementation of method and function invocation.

The current implementation allocates an array of pointers, stores the arguments in it (whether they are actually pointers or not), and then calls the function with them, treating it as if it accepted a set pointer arguments. This seems unsafe (how portable can this be? [code 2] crashes for me when compiled for x86 Windows for example), and it also precludes struct support since structs can have any size.

Improved reflection interface support

Only partial support for Interfaces. For example, it is not possible to get the super interfaces inherited by a given interface. TTypeId.Methods doesn't work as expected on interfaces either.

Use of compilerswitch "?disabled"

The compiler condition ?disabled is used in directx related modules in brl.mod and pub.mod.
what is this used for?
Can we just delete those lines included in it?

bcc_ng build in debug mode DebugStops at every occurrence of it.

bmax/mod$ grep -R -nr -i "?disable"
brl.mod/d3d9max2d.mod/d3d9max2d.bmx:18:?disabled
brl.mod/dxgraphics.mod/dxgraphics.bmx:73:?disabled
brl.mod/d3d7max2d.mod/d3d7max2d.bmx:62:?disabled
pub.mod/directx.mod/directx.bmx:28:?disabled
pub.mod/directx.mod/dsound.bmx:69:?disabled

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.