summaryrefslogtreecommitdiff
path: root/prism/util/pm_buffer.h
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-02-16 18:29:19 -0500
committergit <[email protected]>2024-02-17 02:05:12 +0000
commitb56b8ec797408865ccc79b67e9860d8382f986dd (patch)
treea0200cba639f40974ac7a4a1e74942a94ef3b9bf /prism/util/pm_buffer.h
parent075b6ac8aeb1217b04e067eeb10bd06897a4359d (diff)
[ruby/prism] Provide the ability to dump AST to JSON from C
https://github.com/ruby/prism/commit/d3a149efc5
Diffstat (limited to 'prism/util/pm_buffer.h')
-rw-r--r--prism/util/pm_buffer.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/prism/util/pm_buffer.h b/prism/util/pm_buffer.h
index 513633baa1..a798dd1d17 100644
--- a/prism/util/pm_buffer.h
+++ b/prism/util/pm_buffer.h
@@ -130,6 +130,25 @@ void pm_buffer_append_varuint(pm_buffer_t *buffer, uint32_t value);
void pm_buffer_append_varsint(pm_buffer_t *buffer, int32_t value);
/**
+ * The different types of escaping that can be performed by the buffer when
+ * appending a slice of Ruby source code.
+ */
+typedef enum {
+ PM_BUFFER_ESCAPING_RUBY,
+ PM_BUFFER_ESCAPING_JSON
+} pm_buffer_escaping_t;
+
+/**
+ * Append a slice of source code to the buffer.
+ *
+ * @param buffer The buffer to append to.
+ * @param source The source code to append.
+ * @param length The length of the source code to append.
+ * @param escaping The type of escaping to perform.
+ */
+void pm_buffer_append_source(pm_buffer_t *buffer, const uint8_t *source, size_t length, pm_buffer_escaping_t escaping);
+
+/**
* Prepend the given string to the buffer.
*
* @param buffer The buffer to prepend to.