@@ -4103,14 +4103,13 @@ static JSValue js_bjson_read(JSContext *ctx, JSValue this_val,
4103
4103
return JS_EXCEPTION ;
4104
4104
if (JS_ToIndex (ctx , & len , argv [2 ]))
4105
4105
return JS_EXCEPTION ;
4106
+ if (JS_ToInt32 (ctx , & flags , argv [3 ]))
4107
+ return JS_EXCEPTION ;
4106
4108
buf = JS_GetArrayBuffer (ctx , & size , argv [0 ]);
4107
4109
if (!buf )
4108
4110
return JS_EXCEPTION ;
4109
4111
if (pos + len > size )
4110
4112
return JS_ThrowRangeError (ctx , "array buffer overflow" );
4111
- flags = 0 ;
4112
- if (JS_ToBool (ctx , argv [3 ]))
4113
- flags |= JS_READ_OBJ_REFERENCE ;
4114
4113
obj = JS_ReadObject (ctx , buf + pos , len , flags );
4115
4114
return obj ;
4116
4115
}
@@ -4123,9 +4122,8 @@ static JSValue js_bjson_write(JSContext *ctx, JSValue this_val,
4123
4122
JSValue array ;
4124
4123
int flags ;
4125
4124
4126
- flags = 0 ;
4127
- if (JS_ToBool (ctx , argv [1 ]))
4128
- flags |= JS_WRITE_OBJ_REFERENCE ;
4125
+ if (JS_ToInt32 (ctx , & flags , argv [1 ]))
4126
+ return JS_EXCEPTION ;
4129
4127
buf = JS_WriteObject (ctx , & len , argv [0 ], flags );
4130
4128
if (!buf )
4131
4129
return JS_EXCEPTION ;
@@ -4138,6 +4136,16 @@ static JSValue js_bjson_write(JSContext *ctx, JSValue this_val,
4138
4136
static const JSCFunctionListEntry js_bjson_funcs [] = {
4139
4137
JS_CFUNC_DEF ("read" , 4 , js_bjson_read ),
4140
4138
JS_CFUNC_DEF ("write" , 2 , js_bjson_write ),
4139
+ #define DEF (x ) JS_PROP_INT32_DEF (#x , JS_##x, JS_PROP_CONFIGURABLE)
4140
+ DEF (READ_OBJ_BYTECODE ),
4141
+ DEF (READ_OBJ_REFERENCE ),
4142
+ DEF (READ_OBJ_SAB ),
4143
+ DEF (WRITE_OBJ_BYTECODE ),
4144
+ DEF (WRITE_OBJ_REFERENCE ),
4145
+ DEF (WRITE_OBJ_SAB ),
4146
+ DEF (WRITE_OBJ_STRIP_DEBUG ),
4147
+ DEF (WRITE_OBJ_STRIP_SOURCE ),
4148
+ #undef DEF
4141
4149
};
4142
4150
4143
4151
static int js_bjson_init (JSContext * ctx , JSModuleDef * m )
0 commit comments