summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-08-22 19:30:33 +0800
committerꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id>2022-08-22 19:30:33 +0800
commitf91513bcc8f2f001bb3096a2793f16f052f74861 (patch)
treec14b7267f54945aab0948df16f00a812f77cff1b
parent5ecc6df502a9d5a4bcb5e4b4242a11f55e822b73 (diff)
Use helpers for the supported basic arrays in SWIG
https://swig.org/Doc4.0/SWIG.html#SWIG_nn26 Replacing the use of array functions from the carray library.
-rw-r--r--pikul.i24
1 files changed, 22 insertions, 2 deletions
diff --git a/pikul.i b/pikul.i
index f6079c0..c045603 100644
--- a/pikul.i
+++ b/pikul.i
@@ -4,8 +4,28 @@
%}
#ifdef SWIGJAVASCRIPT
-%include "carrays.i"
-%array_functions(char *, stringArray);
+%inline %{
+ char *provisions[3];
+ void provisions_set(int i, char *val)
+ {
+ if (provisions[i])
+ free(provisions[i]);
+ provisions[i] = (char *)malloc(strlen(val) + 1);
+ strcpy(provisions[i], val);
+ }
+ char *provisions_get(int i)
+ {
+ return provisions[i];
+ }
+ void provisions_clear()
+ {
+ for (int i = 0; i < 3; i++)
+ if (provisions[i]) {
+ free(provisions[i]);
+ provisions[i] = NULL;
+ }
+ }
+%}
#endif
#ifdef SWIGPERL