5
5
#include <stddef.h>
6
6
7
7
// Type definitions
8
- typedef int32_t ContextPtr ;
9
8
typedef int64_t Val ;
10
9
typedef int32_t WriteResult ;
11
10
typedef size_t InternedStringId ;
@@ -20,206 +19,186 @@ typedef size_t InternedStringId;
20
19
// Common API
21
20
/**
22
21
* Creates a new context for the Shopify Function execution
23
- * @return A new context pointer
24
22
*/
25
23
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
26
24
__attribute__((import_name ("shopify_function_context_new" )))
27
- extern ContextPtr shopify_function_context_new (void );
25
+ extern void shopify_function_context_new (void );
28
26
29
27
// Read API
30
28
/**
31
29
* Gets the input value from the context
32
- * @param context The context pointer
33
30
* @return The input value
34
31
*/
35
32
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
36
33
__attribute__((import_name ("shopify_function_input_get" )))
37
- extern Val shopify_function_input_get (ContextPtr context );
34
+ extern Val shopify_function_input_get ();
38
35
39
36
/**
40
37
* Gets the length of a value (for arrays, objects, or strings)
41
- * @param context The context pointer
42
38
* @param scope The value to get the length of
43
39
* @return The length of the value
44
40
*/
45
41
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
46
42
__attribute__((import_name ("shopify_function_input_get_val_len" )))
47
- extern size_t shopify_function_input_get_val_len (ContextPtr context , Val scope );
43
+ extern size_t shopify_function_input_get_val_len (Val scope );
48
44
49
45
/**
50
46
* Reads a UTF-8 encoded string from the input into the provided buffer
51
- * @param context The context pointer
52
47
* @param src The source address of the string
53
48
* @param out The output buffer to write the string to
54
49
* @param len The length of the string
55
50
*/
56
51
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
57
52
__attribute__((import_name ("shopify_function_input_read_utf8_str" )))
58
- extern void shopify_function_input_read_utf8_str (ContextPtr context , size_t src , uint8_t * out , size_t len );
53
+ extern void shopify_function_input_read_utf8_str (size_t src , uint8_t * out , size_t len );
59
54
60
55
/**
61
56
* Gets an object property by name
62
- * @param context The context pointer
63
57
* @param scope The object to get the property from
64
58
* @param ptr The property name (as a UTF-8 string)
65
59
* @param len The length of the property name
66
60
* @return The property value
67
61
*/
68
62
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
69
63
__attribute__((import_name ("shopify_function_input_get_obj_prop" )))
70
- extern Val shopify_function_input_get_obj_prop (ContextPtr context , Val scope , const uint8_t * ptr , size_t len );
64
+ extern Val shopify_function_input_get_obj_prop (Val scope , const uint8_t * ptr , size_t len );
71
65
72
66
/**
73
67
* Gets an object property by interned string ID
74
- * @param context The context pointer
75
68
* @param scope The object to get the property from
76
69
* @param interned_string_id The interned string ID of the property name
77
70
* @return The property value
78
71
*/
79
72
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
80
73
__attribute__((import_name ("shopify_function_input_get_interned_obj_prop" )))
81
- extern Val shopify_function_input_get_interned_obj_prop (ContextPtr context , Val scope , InternedStringId interned_string_id );
74
+ extern Val shopify_function_input_get_interned_obj_prop (Val scope , InternedStringId interned_string_id );
82
75
83
76
/**
84
77
* Gets an element from an array by index
85
- * @param context The context pointer
86
78
* @param scope The array to get the element from
87
79
* @param index The index of the element
88
80
* @return The element value
89
81
*/
90
82
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
91
83
__attribute__((import_name ("shopify_function_input_get_at_index" )))
92
- extern Val shopify_function_input_get_at_index (ContextPtr context , Val scope , size_t index );
84
+ extern Val shopify_function_input_get_at_index (Val scope , size_t index );
93
85
94
86
/**
95
87
* Gets an object key at the specified index
96
- * @param context The context pointer
97
88
* @param scope The object to get the key from
98
89
* @param index The index of the key
99
90
* @return The key value (as a string)
100
91
*/
101
92
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
102
93
__attribute__((import_name ("shopify_function_input_get_obj_key_at_index" )))
103
- extern Val shopify_function_input_get_obj_key_at_index (ContextPtr context , Val scope , size_t index );
94
+ extern Val shopify_function_input_get_obj_key_at_index (Val scope , size_t index );
104
95
105
96
// Write API
106
97
/**
107
98
* Creates a new boolean output value
108
- * @param context The context pointer
109
99
* @param value The boolean value (0 for false, non-zero for true)
110
100
* @return WriteResult indicating success or failure
111
101
*/
112
102
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
113
103
__attribute__((import_name ("shopify_function_output_new_bool" )))
114
- extern WriteResult shopify_function_output_new_bool (ContextPtr context , uint32_t value );
104
+ extern WriteResult shopify_function_output_new_bool (uint32_t value );
115
105
116
106
/**
117
107
* Creates a new null output value
118
- * @param context The context pointer
119
108
* @return WriteResult indicating success or failure
120
109
*/
121
110
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
122
111
__attribute__((import_name ("shopify_function_output_new_null" )))
123
- extern WriteResult shopify_function_output_new_null (ContextPtr context );
112
+ extern WriteResult shopify_function_output_new_null ();
124
113
125
114
/**
126
115
* Finalizes the output and returns the result
127
- * @param context The context pointer
128
116
* @return WriteResult indicating success or failure
129
117
*/
130
118
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
131
119
__attribute__((import_name ("shopify_function_output_finalize" )))
132
- extern WriteResult shopify_function_output_finalize (ContextPtr context );
120
+ extern WriteResult shopify_function_output_finalize ();
133
121
134
122
/**
135
123
* Creates a new 32-bit integer output value
136
- * @param context The context pointer
137
124
* @param value The integer value
138
125
* @return WriteResult indicating success or failure
139
126
*/
140
127
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
141
128
__attribute__((import_name ("shopify_function_output_new_i32" )))
142
- extern WriteResult shopify_function_output_new_i32 (ContextPtr context , int32_t value );
129
+ extern WriteResult shopify_function_output_new_i32 (int32_t value );
143
130
144
131
/**
145
132
* Creates a new 64-bit float output value
146
- * @param context The context pointer
147
133
* @param value The float value
148
134
* @return WriteResult indicating success or failure
149
135
*/
150
136
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
151
137
__attribute__((import_name ("shopify_function_output_new_f64" )))
152
- extern WriteResult shopify_function_output_new_f64 (ContextPtr context , double value );
138
+ extern WriteResult shopify_function_output_new_f64 (double value );
153
139
154
140
/**
155
141
* Creates a new UTF-8 string output value
156
- * @param context The context pointer
157
142
* @param ptr The string data
158
143
* @param len The length of the string
159
144
* @return WriteResult indicating success or failure
160
145
*/
161
146
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
162
147
__attribute__((import_name ("shopify_function_output_new_utf8_str" )))
163
- extern WriteResult shopify_function_output_new_utf8_str (ContextPtr context , const uint8_t * ptr , size_t len );
148
+ extern WriteResult shopify_function_output_new_utf8_str (const uint8_t * ptr , size_t len );
164
149
165
150
/**
166
151
* Creates a new UTF-8 string output value from an interned string ID
167
- * @param context The context pointer
168
152
* @param id The interned string ID
169
153
* @return WriteResult indicating success or failure
170
154
*/
171
155
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
172
156
__attribute__((import_name ("shopify_function_output_new_interned_utf8_str" )))
173
- extern WriteResult shopify_function_output_new_interned_utf8_str (ContextPtr context , InternedStringId id );
157
+ extern WriteResult shopify_function_output_new_interned_utf8_str (InternedStringId id );
174
158
175
159
/**
176
160
* Creates a new object output value with the specified number of properties
177
- * @param context The context pointer
178
161
* @param len The number of properties
179
162
* @return WriteResult indicating success or failure
180
163
*/
181
164
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
182
165
__attribute__((import_name ("shopify_function_output_new_object" )))
183
- extern WriteResult shopify_function_output_new_object (ContextPtr context , size_t len );
166
+ extern WriteResult shopify_function_output_new_object (size_t len );
184
167
185
168
/**
186
169
* Finalizes an object output value
187
- * @param context The context pointer
188
170
* @return WriteResult indicating success or failure
189
171
*/
190
172
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
191
173
__attribute__((import_name ("shopify_function_output_finish_object" )))
192
- extern WriteResult shopify_function_output_finish_object (ContextPtr context );
174
+ extern WriteResult shopify_function_output_finish_object ();
193
175
194
176
/**
195
177
* Creates a new array output value with the specified length
196
- * @param context The context pointer
197
178
* @param len The length of the array
198
179
* @return WriteResult indicating success or failure
199
180
*/
200
181
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
201
182
__attribute__((import_name ("shopify_function_output_new_array" )))
202
- extern WriteResult shopify_function_output_new_array (ContextPtr context , size_t len );
183
+ extern WriteResult shopify_function_output_new_array (size_t len );
203
184
204
185
/**
205
186
* Finalizes an array output value
206
- * @param context The context pointer
207
187
* @return WriteResult indicating success or failure
208
188
*/
209
189
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
210
190
__attribute__((import_name ("shopify_function_output_finish_array" )))
211
- extern WriteResult shopify_function_output_finish_array (ContextPtr context );
191
+ extern WriteResult shopify_function_output_finish_array ();
212
192
213
193
// Other
214
194
/**
215
195
* Interns a UTF-8 string and returns its ID for efficient reuse
216
- * @param context The context pointer
217
196
* @param ptr The string data
218
197
* @param len The length of the string
219
198
* @return The interned string ID
220
199
*/
221
200
__attribute__((import_module (SHOPIFY_FUNCTION_IMPORT_MODULE )))
222
201
__attribute__((import_name ("shopify_function_intern_utf8_str" )))
223
- extern InternedStringId shopify_function_intern_utf8_str (ContextPtr context , const uint8_t * ptr , size_t len );
202
+ extern InternedStringId shopify_function_intern_utf8_str (const uint8_t * ptr , size_t len );
224
203
225
204
#endif // SHOPIFY_FUNCTION_H
0 commit comments