Skip to content

Commit 311f6c2

Browse files
committed
Finishing NodeJS module
1 parent 33d12a3 commit 311f6c2

4 files changed

Lines changed: 89 additions & 3 deletions

File tree

main.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
//qua 05 abr 2023 16:05:25
1+
//qua 05 abr 2023 16:05:25
2+
//__ _____ _____ ____ __ __ _ ____ _ ____ ____ ___ _ _
3+
//\ \ / /_ _|_ _/ ___|| \/ | | |___ \ / | | __ ) ___| / _ \| \ | |
4+
// \ \ /\ / / | | | | \___ \| |\/| | | __) | | | | _ \___ \| | | | \| |
5+
// \ V V / | | | | ___) | | | | |___ / __/ _| | | |_) |__) | |_| | |\ |
6+
// \_/\_/ |___| |_| |____/|_| |_|_____| |_____(_)_| |____/____/ \___/|_| \_|
7+
28
#define _GNU_SOURCE
39

410
#include "ns1.nsmap"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414
libraries=['cws_py', 'bson-shared-1.0'],
1515
extra_objects=["soapC_shared.o"],
1616
include_dirs=['include'],
17-
define_macros=[('CWS_LITTLE_ENDIAN', None), ('WITH_STATISTICS', None), ('PY_WITSML21DEBUG', None)]
17+
define_macros=[('CWS_LITTLE_ENDIAN', None), ('WITH_STATISTICS', None), ('PY_SOAP_DEBUG', None)]
1818
)])
1919

2020
if __name__ == "__main__":

src/napi/addon.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@
4848
#define JS_GET_OBJECT_TYPE ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->object_type
4949
#define JS_GET_CWS_CONFIG ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))
5050
#define JS_GET_ERROR ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->internal_soap_error
51+
#define JS_GET_FAULT_STRING ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->cws_soap_fault.faultstring
52+
#define JS_GET_FAULT_STRING_LEN ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->cws_soap_fault.faultstring_len
53+
#define JS_GET_XML_FAULT_DETAIL ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->cws_soap_fault.XMLfaultdetail
54+
#define JS_GET_XML_FAULT_DETAIL_LEN ((CWS_CONFIG *)(js_cws_instance->soap_internal->user))->cws_soap_fault.XMLfaultdetail_len
5155

5256
#define ERR js_cws_instance->err
5357

@@ -1116,13 +1120,89 @@ _Static_assert(sizeof(uint64_t)>=sizeof(size_t), "Archtecture error. Refactor it
11161120
return res;
11171121
}
11181122

1123+
napi_value c_getFaultString(napi_env env, napi_callback_info info)
1124+
{
1125+
napi_value argv=NULL, res;
1126+
size_t argc=0;
1127+
struct js_cws_config_t *js_cws_instance;
1128+
struct cws_js_err_t cws_js_err;
1129+
1130+
JS_CWS_THROW_COND(
1131+
napi_get_cb_info(env, info, &argc, &argv, NULL, (void **)&js_cws_instance)!=napi_ok,
1132+
"napi_get_cb_info",
1133+
"Can't parse arguments. Wrong argument at c_getFaultString",
1134+
200
1135+
)
1136+
1137+
JS_CWS_THROW_COND(argc, "c_getFaultString", "Too many arguments @ c_getFaultString", 201)
1138+
1139+
JS_CWS_THROW_COND(
1140+
(js_cws_instance==NULL),
1141+
"c_getFaultString",
1142+
"Fatal: js_cws_instance @ c_getFaultString. Was expected NOT NULL",
1143+
202
1144+
)
1145+
1146+
if (JS_GET_FAULT_STRING) {
1147+
JS_CWS_THROW_COND(
1148+
(napi_create_string_utf8(env, JS_GET_FAULT_STRING, JS_GET_FAULT_STRING_LEN, &res)!=napi_ok),
1149+
"napi_create_string_utf8",
1150+
"napi_create_string_utf8 @ c_getFaultString. Error on parsing fault string message",
1151+
203
1152+
)
1153+
1154+
return res;
1155+
}
1156+
1157+
JS_CWS_RETURN_NULL
1158+
}
1159+
1160+
napi_value c_getXMLfaultdetail(napi_env env, napi_callback_info info)
1161+
{
1162+
napi_value argv=NULL, res;
1163+
size_t argc=0;
1164+
struct js_cws_config_t *js_cws_instance;
1165+
struct cws_js_err_t cws_js_err;
1166+
1167+
JS_CWS_THROW_COND(
1168+
napi_get_cb_info(env, info, &argc, &argv, NULL, (void **)&js_cws_instance)!=napi_ok,
1169+
"napi_get_cb_info",
1170+
"Can't parse arguments. Wrong argument at c_getXMLfaultdetail",
1171+
210
1172+
)
1173+
1174+
JS_CWS_THROW_COND(argc, "c_getXMLfaultdetail", "Too many arguments @ c_getXMLfaultdetail", 211)
1175+
1176+
JS_CWS_THROW_COND(
1177+
(js_cws_instance==NULL),
1178+
"c_getXMLfaultdetail",
1179+
"Fatal: js_cws_instance @ c_getXMLfaultdetail. Was expected NOT NULL",
1180+
212
1181+
)
1182+
1183+
if (JS_GET_XML_FAULT_DETAIL) {
1184+
JS_CWS_THROW_COND(
1185+
(napi_create_string_utf8(env, JS_GET_XML_FAULT_DETAIL, JS_GET_XML_FAULT_DETAIL_LEN, &res)!=napi_ok),
1186+
"napi_create_string_utf8",
1187+
"napi_create_string_utf8 @ c_getXMLfaultdetail. Error on parsing XML fault detail string message",
1188+
213
1189+
)
1190+
1191+
return res;
1192+
}
1193+
1194+
JS_CWS_RETURN_NULL
1195+
}
1196+
11191197
CWS_JS_FUNCTIONS_OBJ CWS_JS_CREATE_FUNCTIONS[] = {
11201198
SET_JS_FN_CALL(getInstanceName),
11211199
SET_JS_FN_CALL(getObjectName),
11221200
SET_JS_FN_CALL(getObjectType),
11231201
SET_JS_FN_CALL(getBsonBytes),
11241202
SET_JS_FN_CALL(getJson),
11251203
SET_JS_FN_CALL(getStatistics),
1204+
SET_JS_FN_CALL(getFaultString),
1205+
SET_JS_FN_CALL(getXMLfaultdetail),
11261206
SET_JS_FN_CALL(getError),
11271207
SET_JS_FN_CALL(parse),
11281208
SET_JS_FN_CALL(parseToJSON),

src/python/module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct const_t {
5555
{NULL}
5656
};
5757

58-
#ifdef PY_WITSML21DEBUG
58+
#ifdef PY_SOAP_DEBUG
5959
#define Py_WITSML21_DEBUG(std, ...) \
6060
fprintf(std, __VA_ARGS__);
6161
#else

0 commit comments

Comments
 (0)