World: r3wp
[!REBOL3 Extensions] REBOL 3 Extensions discussions
older newer | first last |
Oldes 7-Dec-2010 [1865] | 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 [1901x2] | I was trying to do just (float)RXA_DEC64(frm, 1) with integer value and it was not working. |
Do you think it's better to export all commands in flat structure like: export System_GetNumDrivers: command[] export System_GetDriverInfo: command[id [integer!]] ... Or rather close them to contexts like: export system: context [ GetNumDrivers: command[] GetDriverInfo: command[id [integer!]] ... ] | |
Kaj 14-Dec-2010 [1903] | Depends on the purpose of the module |
BrianH 14-Dec-2010 [1904] | It depends on the situation, and how the commands are supposed to be used. In that case above, don't export 'system. |
Kaj 14-Dec-2010 [1905] | I think that was just an example :-) |
BrianH 14-Dec-2010 [1906] | Direct word access is faster than path access, but some words are logically grouped (like enums). |
Oldes 14-Dec-2010 [1907] | You mean the name? |
BrianH 14-Dec-2010 [1908] | Yes :) |
Oldes 14-Dec-2010 [1909] | At this moment I have a flat structure, but problem is, that there is so much exported commands that I tender to froup them... I know it's slower, but how many times one need to know driver name like in the commands used in the example above? |
BrianH 14-Dec-2010 [1910x2] | For instance, in the AGG wrapper the commands that are used to implement the Draw dialect are exported in their own context rathar than globally, because they aren't meant to be called directly as functions. Other APIs may need to do the same thing for similar reasons. |
In a lot of cases you want to make commands at the marshaling boundary, and make REBOL wrapper code that you export. REBOL code can encapsuate a lot of functionality, whether you are doing so in an object type, a scheme or a dialect. | |
Oldes 14-Dec-2010 [1912] | Back to the name.. what if I export System extension context into main context, where is already System defined? Now it looks it just silently do not overwrites the existing one.. shouldn't it throw an error? |
BrianH 14-Dec-2010 [1913x2] | If you are just exporting the native API then make the extension's module private rather than public, and just import the extension into the module that provides a simple REBOL-like public API for others to use. |
The current build doesn't have most of the security protections implemented. We want to fix the *many* protection bugs first. | |
older newer | first last |