Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
root.c
Go to the documentation of this file.
1/*
2 * This file is part of the Fun programming language.
3 * https://fun-lang.xyz/
4 *
5 * Copyright 2025 Johannes Findeisen <you@hanez.org>
6 * Licensed under the terms of the Apache-2.0 license.
7 * https://opensource.org/license/apache-2-0
8 */
9
32/* OP_XML_ROOT: pops doc handle; pushes node handle (>0) or 0 */
34#ifdef FUN_WITH_XML2
35 Value vh = pop_value(vm);
36 int h = (vh.type == VAL_INT) ? (int)vh.i : 0;
37 xmlDocPtr doc = xml_doc_get(h);
39 int nh = 0;
40 if (doc) {
41 xmlNodePtr root = xmlDocGetRootElement(doc);
42 if (root) nh = xml_node_alloc(root);
43 }
44 push_value(vm, make_int(nh));
45#else
46 Value drop = pop_value(vm);
47 free_value(drop);
49#endif
50 break;
51}
@ OP_XML_ROOT
Definition bytecode.h:215
free_value(drop)
push_value(vm, make_int(0))
Tagged union representing a Fun value.
Definition value.h:68
Value vh
Definition stubs.c:44
Value make_int(int64_t v)
Construct a Value representing a 64-bit integer.
Definition value.c:51
@ VAL_INT
Definition value.h:51