----------------------------------------------------------------------- ----------------------------------------------------------------------- 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
| 122 | // the first argument. Just pass the actual arguments. |
| 123 | // ----------------------------------------------------------------------- |
| 124 | vec4f 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 |
nothing calls this directly
no test coverage detected