-
-
Save earl/0c6305d7c25e40742b31 to your computer and use it in GitHub Desktop.
Demonstrates a minimal R3 extension that returns a block containing a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "reb-host.h" | |
const char *init_block = | |
"REBOL [\n" | |
"Name: block\n" | |
"Type: extension\n" | |
"]\n" | |
"export get-block: command []\n" | |
; | |
RL_LIB *RL; | |
const char *RX_Init(int opts, RL_LIB *lib) { | |
RL = lib; | |
return init_block; | |
} | |
int RX_Call(int cmd, RXIFRM *frm, void *data) { | |
REBSER *s = RL_MAKE_STRING(3, FALSE); | |
RL_SET_CHAR(s, 0, 'f'); | |
RL_SET_CHAR(s, 1, 'o'); | |
RL_SET_CHAR(s, 2, 'o'); | |
RXIARG a; | |
a.series = s; | |
a.index = 0; | |
REBSER *b = RL_MAKE_BLOCK(1); | |
RL_SET_VALUE(b, 0, a, RXT_STRING); | |
RXA_SERIES(frm, 1) = b; | |
RXA_INDEX(frm, 1) = 0; | |
RXA_TYPE(frm, 1) = RXT_BLOCK; | |
return RXR_VALUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment