From d1b9c27a403fb2ac9e69e82ebea32722c6795daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Fri, 16 Jul 2021 10:55:51 +0800 Subject: SWIG files, therefore deprecating Pikul-XS --- pikul.i | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pikul.i (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i new file mode 100644 index 0000000..b00709e --- /dev/null +++ b/pikul.i @@ -0,0 +1,28 @@ +%module Pikul +%{ +#include "pikul.h" +%} + +%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++) { + SV **tv = av_fetch(tempav, i, 0); + $1[i] = (char *)SvPV(*tv, PL_na); + } + $1[i] = 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); +char *pikul_order(const char *trx_id, const char *service, const char *sender_name, + const char *sender_phone, const char *origin, const char *sender_address, + const char *receiver_name, const char *receiver_phone, const char *destination, + const char *receiver_address, int nitems, char **items[], double value); +void pikul_cleanup(); -- cgit v1.2.3 From abe673f9ae7d9d23e92a188ade187ec020b1f67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Fri, 16 Jul 2021 12:01:56 +0800 Subject: Update value parameter to subtotal --- pikul.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index b00709e..6a0882b 100644 --- a/pikul.i +++ b/pikul.i @@ -24,5 +24,5 @@ double pikul_cost(const char *origin, const char *destination, double weight, co char *pikul_order(const char *trx_id, const char *service, const char *sender_name, const char *sender_phone, const char *origin, const char *sender_address, const char *receiver_name, const char *receiver_phone, const char *destination, - const char *receiver_address, int nitems, char **items[], double value); + const char *receiver_address, int nitems, char **items[], double subtotal); void pikul_cleanup(); -- cgit v1.2.3 From 4482f46ee073110c7c52d73bc8a8006437eba6f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Fri, 16 Jul 2021 23:02:24 +0800 Subject: use_insurance turns out to be required This one follows the example given for the boolean JSON value, which is written as true or false. The response is error 500, internal server error. Despite the example, it says max length is 1 in the middle part of the doc, so maybe it should be written as 1 or 0. Will be tried next. --- pikul.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index 6a0882b..05b45c9 100644 --- a/pikul.i +++ b/pikul.i @@ -24,5 +24,5 @@ double pikul_cost(const char *origin, const char *destination, double weight, co char *pikul_order(const char *trx_id, const char *service, const char *sender_name, const char *sender_phone, const char *origin, const char *sender_address, const char *receiver_name, const char *receiver_phone, const char *destination, - const char *receiver_address, int nitems, char **items[], double subtotal); + const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal); void pikul_cleanup(); -- cgit v1.2.3 From b6abbff926e9ff9908935224c1655d94dcc09441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Fri, 16 Jul 2021 23:28:28 +0800 Subject: Typemap for char **[] Not tested yet. Here so this compiles up to Perl module. --- pikul.i | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index 05b45c9..69f582a 100644 --- a/pikul.i +++ b/pikul.i @@ -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); -- cgit v1.2.3 From 0930b738f5261d4e2630242ca5fa2a6bc63026ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 09:41:41 +0800 Subject: Finally able to typemap char **[] right For now the item object is still flattened. --- pikul.i | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index 69f582a..a4215e9 100644 --- a/pikul.i +++ b/pikul.i @@ -19,21 +19,23 @@ } %typemap(in) char **[] { - AV *tempav = (AV *)SvRV($input); - I32 len = av_len(tempav); - $1 = (char ***)malloc((len + 2) * sizeof(char **)); + AV *items = (AV *)SvRV($input); + I32 nitems_min1 = av_len(items); + $1 = (char ***)malloc((nitems_min1 + 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 *)); + for (i = 0; i <= nitems_min1; i++) { + SV **refptr = av_fetch(items, i, 0); + AV *flat = (AV *)SvRV(*refptr); + I32 nattrs_min1 = av_len(flat); + $1[i] = (char **)malloc((nattrs_min1 + 2) * sizeof(char *)); int j; - for (j = 0; j <= avlen; j++) { - SV **tv = av_fetch(av, j, 0); + for (j = 0; j <= nattrs_min1; j++) { + SV **tv = av_fetch(flat, j, 0); $1[i][j] = (char *)SvPV(*tv, PL_na); } $1[i][j] = NULL; } + $1[i] = NULL; }; %typemap(freearg) char **[] { free($1); -- cgit v1.2.3 From 3eb347f32335a58c681d1777dfeef8c6dc1c76d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 09:52:30 +0800 Subject: _Bool typemap --- pikul.i | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index a4215e9..e2d363f 100644 --- a/pikul.i +++ b/pikul.i @@ -41,6 +41,10 @@ free($1); } +%typemap(in) _Bool { + $1 = $input; +} + %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); -- cgit v1.2.3 From dfa57092e26c242c2ab64dc1d029e5dff44eee67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 11:05:19 +0800 Subject: Rename trx_id to order_number --- pikul.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index e2d363f..9defe86 100644 --- a/pikul.i +++ b/pikul.i @@ -48,7 +48,7 @@ %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); -char *pikul_order(const char *trx_id, const char *service, const char *sender_name, +char *pikul_order(const char *order_number, const char *service, const char *sender_name, const char *sender_phone, const char *origin, const char *sender_address, const char *receiver_name, const char *receiver_phone, const char *destination, const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal); -- cgit v1.2.3 From b999dd2f128bcf209c62d3419a559e70222e7b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 15:29:20 +0800 Subject: Postal codes for both sender & receiver --- pikul.i | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index 9defe86..aa4c707 100644 --- a/pikul.i +++ b/pikul.i @@ -50,6 +50,7 @@ void pikul_init(enum pikul_company company, char *provisions[]); double pikul_cost(const char *origin, const char *destination, double weight, const char *service); char *pikul_order(const char *order_number, const char *service, const char *sender_name, const char *sender_phone, const char *origin, const char *sender_address, - const char *receiver_name, const char *receiver_phone, const char *destination, - const char *receiver_address, int nitems, char **items[], _Bool insurance, double subtotal); + const char *sender_postal, const char *receiver_name, const char *receiver_phone, + const char *destination, const char *receiver_address, const char *receiver_postal, + int nitems, char **items[], _Bool insurance, double subtotal); void pikul_cleanup(); -- cgit v1.2.3 From 3f8539bd52be8fdfaca4a056373d751799241659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sat, 17 Jul 2021 15:33:11 +0800 Subject: Remove parameter names to save from retyping --- pikul.i | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index aa4c707..e2938ac 100644 --- a/pikul.i +++ b/pikul.i @@ -46,11 +46,9 @@ } %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); -char *pikul_order(const char *order_number, const char *service, const char *sender_name, - const char *sender_phone, const char *origin, const char *sender_address, - const char *sender_postal, const char *receiver_name, const char *receiver_phone, - const char *destination, const char *receiver_address, const char *receiver_postal, - int nitems, char **items[], _Bool insurance, double subtotal); +void pikul_init(enum pikul_company, char *[]); +double pikul_cost(const char *, const char *, double, const char *); +char *pikul_order(const char *, const char *, const char *, const char *, const char *, const char *, + const char *, const char *, const char *, const char *, const char *, const char *, int, + char **[], _Bool, double); void pikul_cleanup(); -- cgit v1.2.3 From b53957a8fd25bcce8eb98f71b6e9e711b48ce605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A6=8C=EA=A6=AB=EA=A6=B6=EA=A6=8F=EA=A7=80=EA=A6=A6?= =?UTF-8?q?=EA=A6=BF=EA=A6=A7=EA=A6=AE=EA=A6=91=EA=A6=A9=EA=A6=AD=EA=A7=80?= Date: Sun, 18 Jul 2021 11:59:55 +0800 Subject: Insurance is not determined by user's decision It depends on some weight threshhold. --- pikul.i | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'pikul.i') diff --git a/pikul.i b/pikul.i index e2938ac..331cfcb 100644 --- a/pikul.i +++ b/pikul.i @@ -41,14 +41,10 @@ free($1); } -%typemap(in) _Bool { - $1 = $input; -} - %rename("%(strip:[pikul_])s") ""; void pikul_init(enum pikul_company, char *[]); double pikul_cost(const char *, const char *, double, const char *); char *pikul_order(const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, int, - char **[], _Bool, double); + char **[], double); void pikul_cleanup(); -- cgit v1.2.3