diff options
author | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 23:28:28 +0800 |
---|---|---|
committer | ꦌꦫꦶꦏ꧀ꦦꦿꦧꦮꦑꦩꦭ꧀ <erik@darapsa.co.id> | 2021-07-16 23:28:28 +0800 |
commit | b6abbff926e9ff9908935224c1655d94dcc09441 (patch) | |
tree | d02e1a0eead1c22969251db3c36293aea20297b8 /pikul.i | |
parent | 4482f46ee073110c7c52d73bc8a8006437eba6f2 (diff) |
Typemap for char **[]
Not tested yet. Here so this compiles up to Perl module.
Diffstat (limited to 'pikul.i')
-rw-r--r-- | pikul.i | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -18,6 +18,27 @@ free($1); } +%typemap(in) char **[] { + AV *tempav = (AV *)SvRV($input); + I32 len = av_len(tempav); + $1 = (char ***)malloc((len + 2) * sizeof(char **)); + int i; + for (i = 0; i <= len; i++) { + AV *av = (AV *)av_fetch(tempav, i, 0); + I32 avlen = av_len(av); + $1[i] = (char **)malloc((avlen + 2) * sizeof(char *)); + int j; + for (j = 0; j <= avlen; j++) { + SV **tv = av_fetch(av, j, 0); + $1[i][j] = (char *)SvPV(*tv, PL_na); + } + $1[i][j] = NULL; + } +}; +%typemap(freearg) char **[] { + free($1); +} + %rename("%(strip:[pikul_])s") ""; void pikul_init(enum pikul_company company, char *provisions[]); double pikul_cost(const char *origin, const char *destination, double weight, const char *service); |