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

VM opcode snippet for retrieving the root node of an XML document. 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 (doc)
 push_value (vm, make_int(nh))

Variables

case OP_XML_ROOT
int h = (vh.type == VAL_INT) ? (int)vh.i : 0
xmlDocPtr doc = xml_doc_get(h)
int nh = 0
 break

Detailed Description

VM opcode snippet for retrieving the root node of an XML document.

Included by vm.c; implements OP_XML_ROOT.

Opcode: OP_XML_ROOT

  • Stack effect: pop (int doc_handle) → push (int node_handle | 0)
  • Behavior: For a valid document handle, obtains the document's root element and returns a positive node handle. If the document is invalid or has no root element, 0 is pushed.
  • Gating: If FUN_WITH_XML2 is disabled, the input is discarded and 0 is pushed.

Notes

  • Returned node handles are managed by the XML node registry. They must be released by corresponding XML VM opcodes to avoid leaks.

Example

  • stack: [ doc_handle ]
  • OP_XML_ROOT → [ node_handle ] or [ 0 ]

Definition in file root.c.

Function Documentation

◆ free_value()

free_value ( vh )

◆ if()

if ( doc )

Definition at line 41 of file root.c.

◆ push_value()

push_value ( vm ,
make_int(nh)  )

Variable Documentation

◆ break

break

Definition at line 51 of file root.c.

◆ doc

xmlDocPtr doc = xml_doc_get(h)

Definition at line 38 of file root.c.

◆ h

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

Definition at line 37 of file root.c.

◆ nh

int nh = 0

Definition at line 40 of file root.c.

◆ OP_XML_ROOT

case OP_XML_ROOT

Definition at line 34 of file root.c.