Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to create NSDecimal in iPhone-Wax
    primarykey
    data
    text
    <p>Here is a problem I am facing: </p> <p>I create an NSDecimalNumber in Wax with the line </p> <pre><code> local x=NSDecimalNumber:initWithString("2.3") </code></pre> <p>Out of this I would like to create a NSDecimal with the following line </p> <pre><code> local y=x:decimalValue() </code></pre> <p>This promptly crashes the program. </p> <p>To create the same experience you need to create a basic wax project and add the two lines as the lat lines of <strong>function applicationDidFinishLaunching</strong> in AppDelegate.lua.</p> <p>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. </p> <hr> <p>Appendicies </p> <ol> <li>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. </li> <li>To get NSDecimalNumber to work I need to comment out lines 222-224 (NSNumber) and 241-246 (NSValue) from wax-helpers.m. </li> <li>NSDecimal is defined in Foundation/NSNumber.h </li> </ol> <hr> <p>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:</p> <pre><code>#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 </code></pre> <p>Sometimes there is the following tiny stack trace:</p> <pre><code>wTest[36403:207] PANIC: Error ----- Error calling 'applicationDidFinishLaunching:' on lua object '&lt;AppDelegate: 0x6300e50&gt;' data/scripts/AppDelegate.lua:39: attempt to index local 'x' (a number value) stack traceback: [C]: ? data/scripts/AppDelegate.lua:39: in function &lt;data/scripts/AppDelegate.lua:19&gt; </code></pre> <p>This matches what the debugger gives: Wax is trying to call a method for a number value.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload