aboutsummaryrefslogtreecommitdiff
path: root/core/encoding/xml
diff options
context:
space:
mode:
Diffstat (limited to 'core/encoding/xml')
-rw-r--r--core/encoding/xml/xml_os.odin18
-rw-r--r--core/encoding/xml/xml_reader.odin26
2 files changed, 24 insertions, 20 deletions
diff --git a/core/encoding/xml/xml_os.odin b/core/encoding/xml/xml_os.odin
new file mode 100644
index 000000000..1e94572c6
--- /dev/null
+++ b/core/encoding/xml/xml_os.odin
@@ -0,0 +1,18 @@
+#+build !freestanding
+#+build !js
+package encoding_xml
+
+import "core:os"
+
+// Load an XML file
+load_from_file :: proc(filename: string, options := DEFAULT_OPTIONS, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) {
+ context.allocator = allocator
+ options := options
+
+ data, data_err := os.read_entire_file(filename, allocator)
+ if data_err != nil { return {}, .File_Error }
+
+ options.flags += { .Input_May_Be_Modified }
+
+ return parse_bytes(data, options, filename, error_handler, allocator)
+}
diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin
index 8f8fffe14..6d068466b 100644
--- a/core/encoding/xml/xml_reader.odin
+++ b/core/encoding/xml/xml_reader.odin
@@ -9,13 +9,12 @@ package encoding_xml
- Jeroen van Rijn: Initial implementation.
*/
-import "core:bytes"
-import "core:encoding/entity"
-import "base:intrinsics"
-import "core:mem"
-import "core:os"
-import "core:strings"
-import "base:runtime"
+import "base:runtime"
+import "core:bytes"
+import "core:encoding/entity"
+import "base:intrinsics"
+import "core:mem"
+import "core:strings"
likely :: intrinsics.expect
@@ -373,19 +372,6 @@ parse_string :: proc(data: string, options := DEFAULT_OPTIONS, path := "", error
parse :: proc { parse_string, parse_bytes }
-// Load an XML file
-load_from_file :: proc(filename: string, options := DEFAULT_OPTIONS, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) {
- context.allocator = allocator
- options := options
-
- data, data_ok := os.read_entire_file(filename)
- if !data_ok { return {}, .File_Error }
-
- options.flags += { .Input_May_Be_Modified }
-
- return parse_bytes(data, options, filename, error_handler, allocator)
-}
-
destroy :: proc(doc: ^Document, allocator := context.allocator) {
context.allocator = allocator
if doc == nil { return }