Skip to content

Commit

Permalink
FEAT: handle's context accessible from an external extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Oldes committed Jan 16, 2023
1 parent e7273ea commit 43c02f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/include/reb-ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ typedef union rxi_arg_val {
int height:16;
};
struct {
void *ptr;
union {
void *ptr;
REBHOB *hob; // Handle's context object
};
REBCNT type; // Handle's name (symbol)
REBFLG flags:16; // Handle_Flags
REBCNT index:16; // Index into Reb_Handle_Spec value
Expand Down Expand Up @@ -127,6 +130,7 @@ typedef int (*RXICAL)(int cmd, RXIFRM *args, REBCEC *ctx);
#define RXA_OBJECT(f,n) (RXA_ARG(f,n).addr)
#define RXA_MODULE(f,n) (RXA_ARG(f,n).addr)
#define RXA_HANDLE(f,n) (RXA_ARG(f,n).handle.ptr)
#define RXA_HANDLE_CONTEXT(f,n) (RXA_ARG(f,n).handle.hob)
#define RXA_HANDLE_TYPE(f,n) (RXA_ARG(f,n).handle.type)
#define RXA_HANDLE_FLAGS(f,n) (RXA_ARG(f,n).handle.flags)
#define RXA_HANDLE_INDEX(f,n) (RXA_ARG(f,n).handle.index)
Expand Down
5 changes: 4 additions & 1 deletion src/include/sys-value.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,10 @@ typedef struct Reb_Handle_Spec {
} REBHSP;

typedef struct Reb_Handle_Context {
REBYTE *data; // Pointer to raw data
union {
REBYTE *data; // Pointer to raw data
void *handle; // Unspecified pointer (external handle)
};
REBCNT sym; // Index of the word's symbol. Used as a handle's type!
REBFLG flags:16; // Handle_Flags (HANDLE_CONTEXT_MARKED and HANDLE_CONTEXT_USED)
REBCNT index:16; // Index into Reb_Handle_Spec value
Expand Down

0 comments on commit 43c02f9

Please sign in to comment.