Fun
0.41.5
The programming language that makes You have fun
Main Page
Data Structures
Files
File List
Globals
Loading...
Searching...
No Matches
src
vm
xml
text.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
33
/* OP_XML_TEXT: pops node handle; pushes string (concatenate text node children) */
34
case
OP_XML_TEXT
: {
35
#ifdef FUN_WITH_XML2
36
Value
vh
= pop_value(vm);
37
int
h = (
vh
.type ==
VAL_INT
) ? (
int
)
vh
.i : 0;
38
xmlNodePtr
n
= xml_node_get(h);
39
free_value
(
vh
);
40
if
(!
n
) {
41
push_value
(vm,
make_string
(
""
));
42
break
;
43
}
44
xmlChar *content = xmlNodeGetContent(
n
);
45
if
(!content) {
46
push_value
(vm,
make_string
(
""
));
47
break
;
48
}
49
push_value
(vm,
make_string
((
const
char
*)content));
50
xmlFree(content);
51
#else
52
Value
drop = pop_value(vm);
53
free_value
(drop);
54
push_value
(vm,
make_string
(
""
));
55
#endif
56
break
;
57
}
OP_XML_TEXT
@ OP_XML_TEXT
Definition
bytecode.h:217
n
int n
Definition
insert.c:41
Value
Tagged union representing a Fun value.
Definition
value.h:68
vh
Value vh
Definition
stubs.c:44
push_value
push_value(vm, make_string(""))
free_value
free_value(drop)
make_string
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Definition
value.c:95
VAL_INT
@ VAL_INT
Definition
value.h:51
Generated on
for Fun by
1.16.1