20
20
#include "iotjs_objectwrap.h"
21
21
22
22
23
- static void iotjs_uart_destroy (iotjs_uart_t * uart );
24
23
static iotjs_uart_t * iotjs_uart_instance_from_jval (const iotjs_jval_t * juart );
25
- IOTJS_DEFINE_NATIVE_HANDLE_INFO (uart );
26
-
24
+ IOTJS_DEFINE_NATIVE_HANDLE_INFO_THIS_MODULE (uart );
27
25
28
26
static iotjs_uart_t * iotjs_uart_create (const iotjs_jval_t * juart ) {
29
27
iotjs_uart_t * uart = IOTJS_ALLOC (iotjs_uart_t );
30
28
IOTJS_VALIDATED_STRUCT_CONSTRUCTOR (iotjs_uart_t , uart );
31
- iotjs_jobjectwrap_initialize (& _this -> jobjectwrap , juart , & uart_native_info );
29
+ iotjs_jobjectwrap_initialize (& _this -> jobjectwrap , juart ,
30
+ & this_module_native_info );
32
31
33
32
_this -> device_fd = -1 ;
34
33
35
34
return uart ;
36
35
}
37
36
38
37
39
- static void iotjs_uart_destroy (iotjs_uart_t * uart ) {
40
- IOTJS_VALIDATED_STRUCT_DESTRUCTOR (iotjs_uart_t , uart );
41
- iotjs_jobjectwrap_destroy (& _this -> jobjectwrap );
42
- iotjs_string_destroy (& _this -> device_path );
43
- IOTJS_RELEASE (uart );
44
- }
45
-
46
-
47
38
#define THIS iotjs_uart_reqwrap_t* uart_reqwrap
48
39
49
40
@@ -292,13 +283,11 @@ JHANDLER_FUNCTION(UartConstructor) {
292
283
293
284
294
285
JHANDLER_FUNCTION (Write ) {
295
- DJHANDLER_CHECK_THIS ( object );
286
+ JHANDLER_DECLARE_THIS_PTR ( uart , uart );
296
287
DJHANDLER_CHECK_ARGS (1 , string );
297
288
DJHANDLER_CHECK_ARG_IF_EXIST (1 , function );
298
289
299
290
const iotjs_jval_t * jcallback = JHANDLER_GET_ARG_IF_EXIST (1 , function );
300
- const iotjs_jval_t * juart = JHANDLER_GET_THIS (object );
301
- iotjs_uart_t * uart = iotjs_uart_instance_from_jval (juart );
302
291
303
292
IOTJS_VALIDATED_STRUCT_METHOD (iotjs_uart_t , uart );
304
293
@@ -322,12 +311,10 @@ JHANDLER_FUNCTION(Write) {
322
311
323
312
324
313
JHANDLER_FUNCTION (Close ) {
325
- DJHANDLER_CHECK_THIS ( object );
314
+ JHANDLER_DECLARE_THIS_PTR ( uart , uart );
326
315
DJHANDLER_CHECK_ARG_IF_EXIST (0 , function );
327
316
328
317
const iotjs_jval_t * jcallback = JHANDLER_GET_ARG_IF_EXIST (0 , function );
329
- const iotjs_jval_t * juart = JHANDLER_GET_THIS (object );
330
- iotjs_uart_t * uart = iotjs_uart_instance_from_jval (juart );
331
318
332
319
IOTJS_VALIDATED_STRUCT_METHOD (iotjs_uart_t , uart );
333
320
iotjs_jval_destroy (& _this -> jemitter_this );
0 commit comments