Here is a problem I am facing:
I create an NSDecimalNumber in Wax with the line
local x=NSDecimalNumber:initWithString("2.3")
Out of this I would like to create a NSDecimal with the following line
local y=x:decimalValue()
This promptly crashes the program.
To create the same experience you need to create a basic wax project and add the two lines as the lat lines of function applicationDidFinishLaunching in AppDelegate.lua.
Question: How can I get this to return an honest NSDecimal which I can pass along? I don't actually need to see or print the number myself.
Appendicies
- Despite popular belief on the internet, NSDecimal is very different from NSDecimalNumber. The first is a C struct, the second is an Obj-C struct with which I work very well.
- To get NSDecimalNumber to work I need to comment out lines 222-224 (NSNumber) and 241-246 (NSValue) from wax-helpers.m.
- NSDecimal is defined in Foundation/NSNumber.h
Output when run: There's not much of a stack trace, it just silently dies. In the Debugger (with breakpoints turned on) there is the following (abbreviated) calling sequence:
#0 0x027553f4 in objc_exception_throw
#1 0x0256e8d6 in __NSGetSizeAndAlignment
#2 0x0256ebd9 in __NSGetSizeAndAlignment
#3 0x025747b8 in __NSMS1
#4 0x02573f9c in +[NSMethodSignature signatureWithObjCTypes:]
#5 0x000342d0 in wax_selectorForInstance at wax_helpers.m:557
#6 0x00035bc2 in __index at wax_instance.m:303
#7 0x000181b9 in luaD_precall at ldo.c:319
#8 0x00018405 in luaD_call at ldo.c:376
#9 0x0002c488 in callTMres at lvm.c:88
#10 0x0002c74a in luaV_gettable at lvm.c:125
#11 0x0002dd26 in luaV_execute at lvm.c:467
#12 0x0001841c in luaD_call at ldo.c:377
#13 0x0000ddc8 in f_call at lapi.c:800
#14 0x0001758a in luaD_rawrunprotected at ldo.c:116
#15 0x0001879a in luaD_pcall at ldo.c:463
#16 0x0000de65 in lua_pcall at lapi.c:821
#17 0x00034e60 in wax_pcall at wax_helpers.m:826
#18 0x00036be4 in pcallUserdata at wax_instance.m:580
#19 0x00036edc in wax_id_call at wax_instance.m:627
Sometimes there is the following tiny stack trace:
wTest[36403:207] PANIC:
Error
-----
Error calling 'applicationDidFinishLaunching:' on lua object '<AppDelegate: 0x6300e50>'
data/scripts/AppDelegate.lua:39: attempt to index local 'x' (a number value)
stack traceback:
[C]: ?
data/scripts/AppDelegate.lua:39: in function <data/scripts/AppDelegate.lua:19>
This matches what the debugger gives: Wax is trying to call a method for a number value.