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

VM opcode snippet for retrieving the concatenated text of an XML node. More...

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

Go to the source code of this file.

Functions

 free_value (vh)
 if (!n)
 push_value (vm, make_string((const char *) content))
 xmlFree (content)

Variables

case OP_XML_TEXT
int h = (vh.type == VAL_INT) ? (int)vh.i : 0
xmlNodePtr n = xml_node_get(h)
xmlChar * content = xmlNodeGetContent(n)
 break

Detailed Description

VM opcode snippet for retrieving the concatenated text of an XML node.

Included by vm.c; implements OP_XML_TEXT.

Opcode: OP_XML_TEXT

  • Stack effect: pop (int node_handle) → push (string text)
  • Behavior: Retrieves the node's textual content as produced by xmlNodeGetContent(), which concatenates all descendant text nodes. If the node is invalid or has no textual content, an empty string is pushed.
  • Gating: If FUN_WITH_XML2 is disabled, the input is discarded and an empty string is pushed.

Notes

  • The returned string is copied into a VM string value; libxml2 buffers are freed immediately after use.

Example

  • stack: [ node_handle ]
  • OP_XML_TEXT → [ "Hello world" ]

Definition in file text.c.

Function Documentation

◆ free_value()

free_value ( vh )

◆ if()

if ( ! n)

Definition at line 41 of file text.c.

◆ push_value()

push_value ( vm ,
make_string((const char *) content)  )

◆ xmlFree()

xmlFree ( content )

Variable Documentation

◆ break

break

Definition at line 57 of file text.c.

◆ content

xmlChar* content = xmlNodeGetContent(n)

Definition at line 45 of file text.c.

◆ h

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

Definition at line 38 of file text.c.

◆ n

xmlNodePtr n = xml_node_get(h)

Definition at line 39 of file text.c.

◆ OP_XML_TEXT

case OP_XML_TEXT

Definition at line 35 of file text.c.