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

VM opcode snippet for reading a boolean from an INI dictionary (OP_INI_GET_BOOL). More...

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

Go to the source code of this file.

Functions

 if (d &&sec &&key)
 free_value (vdef)
 free_value (vkey)
 free_value (vsec)
 free_value (vh)
 push_value (vm, make_int(outb ? 1 :0))

Variables

case OP_INI_GET_BOOL
Value vkey = pop_value(vm)
Value vsec = pop_value(vm)
Value vh = pop_value(vm)
int def = (vdef.type == VAL_INT || vdef.type == VAL_BOOL) ? (int)vdef.i : 0
const char * key = (vkey.type == VAL_STRING) ? vkey.s : NULL
const char * sec = (vsec.type == VAL_STRING) ? vsec.s : NULL
int h = (vh.type == VAL_INT) ? (int)vh.i : 0
dictionary * d = ini_get(h)
int outb = def
 break

Detailed Description

VM opcode snippet for reading a boolean from an INI dictionary (OP_INI_GET_BOOL).

Included by vm.c when FUN_WITH_INI is enabled.

Opcode: OP_INI_GET_BOOL Stack: [default:int|bool] [key:string] [section:string] [handle:int] -> [out:int]

Behavior

  • Pops default value (0/1), key, section, and handle.
  • Looks up the entry "section:key" in the referenced dictionary. If not found, also tries a dotted variant "section.key" for compatibility.
  • Accepts textual booleans (true/false, yes/no, on/off; case-insensitive) and numeric values (non-zero => true). Falls back to the provided default when parsing fails or entry is missing.
  • Pushes 1 for true or 0 for false.

Errors

  • Invalid handle or arguments simply yield the default value; no exception.

Definition in file get_bool.c.

Function Documentation

◆ free_value() [1/4]

free_value ( vdef )

◆ free_value() [2/4]

free_value ( vh )

◆ free_value() [3/4]

free_value ( vkey )

◆ free_value() [4/4]

free_value ( vsec )

◆ if()

if ( d &&sec && key)

Definition at line 45 of file get_bool.c.

◆ push_value()

push_value ( vm ,
make_int(outb ? 1 :0)  )

Variable Documentation

◆ break

break

Definition at line 96 of file get_bool.c.

◆ d

dictionary* d = ini_get(h)

Definition at line 43 of file get_bool.c.

◆ def

int def = (vdef.type == VAL_INT || vdef.type == VAL_BOOL) ? (int)vdef.i : 0

Definition at line 39 of file get_bool.c.

◆ h

int h = (vh.type == VAL_INT) ? (int)vh.i : 0

Definition at line 42 of file get_bool.c.

◆ key

const char* key = (vkey.type == VAL_STRING) ? vkey.s : NULL

Definition at line 40 of file get_bool.c.

◆ OP_INI_GET_BOOL

case OP_INI_GET_BOOL

Definition at line 34 of file get_bool.c.

◆ outb

int outb = def

Definition at line 44 of file get_bool.c.

◆ sec

const char* sec = (vsec.type == VAL_STRING) ? vsec.s : NULL

Definition at line 41 of file get_bool.c.

◆ vh

Value vh = pop_value(vm)

Definition at line 38 of file get_bool.c.

◆ vkey

Value vkey = pop_value(vm)

Definition at line 36 of file get_bool.c.

◆ vsec

Value vsec = pop_value(vm)

Definition at line 37 of file get_bool.c.