World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Cyphre 6-Dec-2010 [1852] | Brian: actually the values on the 'command frame' are 'free value slots' as they are not part of any series...they are just in plain fixed size array. But this is probably just playing with words ;) |
BrianH 6-Dec-2010 [1853] | They are in the command frame :) |
Cyphre 6-Dec-2010 [1854x3] | ok :) |
Oldes: I don't think you can do it different way since REBOL has no c-like pointers. | |
The only way is to generate rebol wrapper func which will pass the args in a block! or object! imo. | |
Andreas 6-Dec-2010 [1857] | (Or binary! :) |
Oldes 6-Dec-2010 [1858x3] | ok.. no problem.. I was just asking as I'm learning. It's just something like educative free time project for me as I don't need it.. I use maybe 20 functions of IM in real life. |
(and I could use Jocko's extension for the rest if needed of course) | |
Next question.. when I have: case CMD_MagickGetImageColors: { if(current_wand) { RXA_INT32(frm, 1) = MagickGetImageColors( current_wand); RXA_TYPE(frm, 1) = RXT_INTEGER; } return RXR_VALUE; } While compilation using GCC I get this warning: use of cast expressions as lvalues is deprecated The command is working, just would like to know if I can improve it somehow. The function is defined as: size_t MagickGetImageColors(MagickWand *wand) | |
Andreas 6-Dec-2010 [1861x2] | That's due to how RXA_INT32 is defined. |
Use RXA_INT64 instead, and the warning will go away. | |
Oldes 6-Dec-2010 [1863] | Right.. that's it. |
Oldes 7-Dec-2010 [1864x2] | Having: double mean, standard_deviation; What I must do to get REBOL block with these two values in it? |
This seems to be working, but is this the best solution? REBSER* block = RL_MAKE_BLOCK(2); RXIARG val; RXV_DEC64(val) = mean; RL_SET_VALUE(block, 0, val, RXT_DECIMAL); RXV_DEC64(val) = standard_deviation; RL_SET_VALUE(block, 1, val, RXT_DECIMAL); RXA_TYPE(frm, 1) = RXT_BLOCK; RXA_SERIES(frm, 1) = block; | |
Oldes 12-Dec-2010 [1866] | I have MP3 playing from R3 console using FMOD extension... at this moment just a very first test:) Must go sleep unfortunately. |
Maxim 12-Dec-2010 [1867] | really cool. |
Oldes 13-Dec-2010 [1868x2] | I started using Code::Blocks and now I get error: invalid conversion from 'const char*' to 'REBYTE*' for code: RL->print("init\n"); Which was fine with GCC. Any idea why? |
Also I see such a warnings: ..\src\include\reb-config.h|109|warning: ignoring #pragma warning | | |
Andreas 13-Dec-2010 [1870] | A110? |
Oldes 13-Dec-2010 [1871] | yes |
Andreas 13-Dec-2010 [1872] | Windows? Linux? |
Oldes 13-Dec-2010 [1873x3] | Windows |
I've got it... the file was .cpp instead of .c | |
(the warning is still there, but I can print again) | |
Oldes 14-Dec-2010 [1876x2] | Do you know, if it's (or will be) possible to get struct! from handle!? |
Or to return struct! from the C side? | |
Andreas 14-Dec-2010 [1878x2] | Passing around heap-allocated structs should work right now. |
Ah, struct!, sorry, I misread. | |
Oldes 14-Dec-2010 [1880] | ..because I somehow miss what is struct useful for in R3 without routines. |
Andreas 14-Dec-2010 [1881] | I think struct! is just a datatype for future use. Not used at the moment. |
Cyphre 14-Dec-2010 [1882] | yes, struct! is 'reserved' for now. It may be even removed later. |
Oldes 14-Dec-2010 [1883] | What if I expect float on the C side, but still want to allow to use integer from REBOL (using number!).. what's the best way to do it? |
Kaj 14-Dec-2010 [1884] | Maybe a wrapper interface function in the init block? |
Oldes 14-Dec-2010 [1885] | That's possible, but I was more thinking how to do it on the C side and not end with wrapper for each extension command. |
Kaj 14-Dec-2010 [1886] | Yeah, more elegant, but more work |
Andreas 14-Dec-2010 [1887] | How about defining the command with `command [arg [integer! decimal!]]` and then detecting in C when you where passed an int and converting it to a float? |
Oldes 14-Dec-2010 [1888x2] | Yes.. but how? Remember, I'm still C newbie:) |
and the command can be just [number!] | |
Andreas 14-Dec-2010 [1890] | Then you'll have to handle percent! as well :) |
Oldes 14-Dec-2010 [1891x2] | oh.. right.. but that could be fine in some cases.. like volume. |
also decimal! and percent! are both as RXA_DEC64 | |
Kaj 14-Dec-2010 [1893] | In the extension examples in the docs are examples of detecting multiple types |
Oldes 14-Dec-2010 [1894] | I guess I can use RXA_TYPE(f,n) to get the value type, but hot to convert the integer to decimal? |
Kaj 14-Dec-2010 [1895] | I don't think it's very easy to get at the REBOL conversion functions |
Andreas 14-Dec-2010 [1896] | float value = (float)RXA_DEC64(frm, 1); if (RXA_TYPE(frm, 1) == RXT_INTEGER) value = (float)RXA_INT64(frm, 1); } |
Oldes 14-Dec-2010 [1897] | thanks, that looks good |
Andreas 14-Dec-2010 [1898x3] | In fact, this is not really necessary, as both integer and decimal values are stored in a union anyway. But if you want to rely on as little implementation internals as possible, that's probably the way to go. |
And your compile will quite possibly optimise the redundancy away for you behind your back :) | |
compiler* | |
Oldes 14-Dec-2010 [1901] | I was trying to do just (float)RXA_DEC64(frm, 1) with integer value and it was not working. |
older newer | first last |