MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / c_call_block_impl

Function c_call_block_impl

tutorials/integration/c/04_callbacks.c:124–146  ·  view source on GitHub ↗

----------------------------------------------------------------------- ----------------------------------------------------------------------- Interop: c_call_block — receives a block and calls it daslang signature: def c_call_block(callback : block<(a:int; b:float) : string>; a : int; b : float) : string Mangled: "s 0 $ i f" "0 $" — block (stack-allocated, $ suffix) "i" — int argument

Source from the content-addressed store, hash-verified

122// the first argument. Just pass the actual arguments.
123// -----------------------------------------------------------------------
124vec4f c_call_block_impl(das_context * ctx, das_node * node, vec4f * args) {
125 (void)node;
126 das_block * block = das_argument_block(args[0]);
127 int a = das_argument_int(args[1]);
128 float b = das_argument_float(args[2]);
129
130 printf("[C] calling block with (%d, %.2f)\n", a, b);
131
132 vec4f blk_args[2];
133 blk_args[0] = das_result_int(a);
134 blk_args[1] = das_result_float(b);
135
136 vec4f ret = das_context_eval_block(ctx, block, blk_args);
137 char * ex = das_context_get_exception(ctx);
138 if (ex) {
139 printf("[C] exception in block: %s\n", ex);
140 return das_result_string(NULL);
141 }
142
143 char * str = das_argument_string(ret);
144 printf("[C] block returned: \"%s\"\n", str);
145 return ret;
146}
147
148// -----------------------------------------------------------------------
149// Module registration

Callers

nothing calls this directly

Calls 10

das_argument_blockFunction · 0.85
das_argument_intFunction · 0.85
das_argument_floatFunction · 0.85
printfFunction · 0.85
das_result_intFunction · 0.85
das_result_floatFunction · 0.85
das_context_eval_blockFunction · 0.85
das_result_stringFunction · 0.85
das_argument_stringFunction · 0.85

Tested by

no test coverage detected