aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/c_strings.md46
-rw-r--r--api/c_strings.yaml35
2 files changed, 81 insertions, 0 deletions
diff --git a/api/c_strings.md b/api/c_strings.md
new file mode 100644
index 00000000..35bb44d9
--- /dev/null
+++ b/api/c_strings.md
@@ -0,0 +1,46 @@
+% API
+
+# Builtins
+
+# CString
+## CString.as_text
+
+```tomo
+CString.as_text : func(str: CString -> Text)
+```
+
+Convert a C string to Text.
+
+Argument | Type | Description | Default
+---------|------|-------------|---------
+str | `CString` | The C string. | -
+
+**Return:** The C string as a Text.
+
+
+**Example:**
+```tomo
+assert CString("Hello").as_text() == "Hello"
+
+```
+## CString.join
+
+```tomo
+CString.join : func(glue: CString, pieces: [CString] -> CString)
+```
+
+Join a list of C strings together with a separator.
+
+Argument | Type | Description | Default
+---------|------|-------------|---------
+glue | `CString` | The C joiner used to between elements. | -
+pieces | `[CString]` | A list of C strings to join. | -
+
+**Return:** A C string of the joined together bits.
+
+
+**Example:**
+```tomo
+assert CString(",").join([CString("a"), CString("b")]) == CString("a,b")
+
+```
diff --git a/api/c_strings.yaml b/api/c_strings.yaml
new file mode 100644
index 00000000..7607bc9e
--- /dev/null
+++ b/api/c_strings.yaml
@@ -0,0 +1,35 @@
+CString.as_text:
+ short: convert a C string to Text
+ description: >
+ Convert a C string to Text.
+ return:
+ type: 'Text'
+ description: >
+ The C string as a Text.
+ args:
+ str:
+ type: 'CString'
+ description: >
+ The C string.
+ example: |
+ assert CString("Hello").as_text() == "Hello"
+
+CString.join:
+ short: join a list of C strings
+ description: >
+ Join a list of C strings together with a separator.
+ return:
+ type: 'CString'
+ description: >
+ A C string of the joined together bits.
+ args:
+ glue:
+ type: 'CString'
+ description: >
+ The C joiner used to between elements.
+ pieces:
+ type: '[CString]'
+ description: >
+ A list of C strings to join.
+ example: |
+ assert CString(",").join([CString("a"), CString("b")]) == CString("a,b")