Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
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) */
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);
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);
55#endif
56 break;
57}
@ OP_XML_TEXT
Definition bytecode.h:217
int n
Definition insert.c:41
Tagged union representing a Fun value.
Definition value.h:68
Value vh
Definition stubs.c:44
push_value(vm, make_string(""))
free_value(drop)
Value make_string(const char *s)
Construct a string Value by duplicating the given C string.
Definition value.c:95
@ VAL_INT
Definition value.h:51