Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
hello_args_return.c File Reference

Implements the OP_RUST_HELLO_ARGS_RETURN opcode (conditional build). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 free_value (vmsg)
 if (msg)
 if (ret)

Variables

case OP_RUST_HELLO_ARGS_RETURN
char * msg = value_to_string_alloc(&vmsg)
 else
 break

Detailed Description

Implements the OP_RUST_HELLO_ARGS_RETURN opcode (conditional build).

Demonstrates round-tripping a string value through Rust. Pops a value, converts it to a C string, passes it to Rust, and pushes back the string returned by Rust. If Rust returns NULL or Rust support is disabled, Nil is pushed.

OP_RUST_HELLO_ARGS_RETURN: (msg:any) -> string | Nil

Behavior (FUN_WITH_RUST=ON):

  • Pops one value from the stack and converts it to a newly allocated C string via value_to_string_alloc().
  • Calls fun_rust_echo_string(msg) which returns an owned C string pointer that must be released via fun_rust_string_free().
  • Pushes the returned string as VAL_STRING on success; pushes Nil if Rust returns NULL.

Behavior (FUN_WITH_RUST=OFF):

  • Pops and frees one value to preserve stack discipline.
  • Raises a runtime error indicating missing Rust support.
  • Pushes Nil.

Definition in file hello_args_return.c.

Function Documentation

◆ free_value()

free_value ( vmsg )

◆ if() [1/2]

if ( msg )

Definition at line 40 of file hello_args_return.c.

◆ if() [2/2]

if ( ret )

Definition at line 51 of file hello_args_return.c.

Variable Documentation

◆ break

break

Definition at line 65 of file hello_args_return.c.

◆ else

else
Initial value:
{
char *ret = fun_rust_echo_string("")
char * fun_rust_echo_string(const char *input)

Definition at line 49 of file hello_args_return.c.

◆ msg

char* msg = value_to_string_alloc(&vmsg)

Definition at line 38 of file hello_args_return.c.

◆ OP_RUST_HELLO_ARGS_RETURN

case OP_RUST_HELLO_ARGS_RETURN

Definition at line 35 of file hello_args_return.c.