diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-08-22 19:30:33 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2022-08-22 19:30:33 +0800 |
commit | f91513bcc8f2f001bb3096a2793f16f052f74861 (patch) | |
tree | c14b7267f54945aab0948df16f00a812f77cff1b | |
parent | 5ecc6df502a9d5a4bcb5e4b4242a11f55e822b73 (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.i | 24 |
1 files changed, 22 insertions, 2 deletions
@@ -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 |