Skip to content

Commit 508a4bd

Browse files
run format-cpp
1 parent 1742953 commit 508a4bd

File tree

4 files changed

+79
-53
lines changed

4 files changed

+79
-53
lines changed

benchmark/napi/create_object_with_properties/binding.cc

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <node_api.h>
21
#include <assert.h>
2+
#include <node_api.h>
33

44
// Creating with many options because complains are when ~20 properties
55
static void CreateTestProperties(napi_env env,
@@ -72,12 +72,8 @@ static napi_value CreateObjectWithPropertiesNew(napi_env env,
7272

7373
for (uint32_t i = 0; i < count; i++) {
7474
napi_value obj;
75-
napi_create_object_with_properties(env,
76-
null_prototype,
77-
names,
78-
values,
79-
20,
80-
&obj);
75+
napi_create_object_with_properties(
76+
env, null_prototype, names, values, 20, &obj);
8177
}
8278

8379
napi_call_function(env, bench_obj, end_fn, 1, &count_val, nullptr);
@@ -138,13 +134,24 @@ static napi_value CreateObjectWithPropertiesOld(napi_env env,
138134

139135
NAPI_MODULE_INIT() {
140136
napi_property_descriptor desc[] = {
141-
{ "createObjectWithPropertiesNew", 0, CreateObjectWithPropertiesNew, 0, 0,
142-
0, napi_default, 0 },
143-
{ "createObjectWithPropertiesOld", 0, CreateObjectWithPropertiesOld, 0, 0,
144-
0, napi_default, 0 },
137+
{"createObjectWithPropertiesNew",
138+
0,
139+
CreateObjectWithPropertiesNew,
140+
0,
141+
0,
142+
0,
143+
napi_default,
144+
0},
145+
{"createObjectWithPropertiesOld",
146+
0,
147+
CreateObjectWithPropertiesOld,
148+
0,
149+
0,
150+
0,
151+
napi_default,
152+
0},
145153
};
146154

147155
napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
148156
return exports;
149157
}
150-

src/js_native_api.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,13 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_object_freeze(napi_env env,
628628
napi_value object);
629629
NAPI_EXTERN napi_status NAPI_CDECL napi_object_seal(napi_env env,
630630
napi_value object);
631-
NAPI_EXTERN napi_status NAPI_CDECL napi_create_object_with_properties(
632-
napi_env env,
633-
napi_value prototype_or_null,
634-
napi_value* property_names,
635-
napi_value* property_values,
636-
size_t property_count,
637-
napi_value* result);
631+
NAPI_EXTERN napi_status NAPI_CDECL
632+
napi_create_object_with_properties(napi_env env,
633+
napi_value prototype_or_null,
634+
napi_value* property_names,
635+
napi_value* property_values,
636+
size_t property_count,
637+
napi_value* result);
638638
#endif // NAPI_VERSION >= 8
639639

640640
EXTERN_C_END

src/js_native_api_v8.cc

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1591,13 +1591,13 @@ napi_status NAPI_CDECL napi_create_object(napi_env env, napi_value* result) {
15911591
return napi_clear_last_error(env);
15921592
}
15931593

1594-
napi_status NAPI_CDECL napi_create_object_with_properties(
1595-
napi_env env,
1596-
napi_value prototype_or_null,
1597-
napi_value* property_names,
1598-
napi_value* property_values,
1599-
size_t property_count,
1600-
napi_value* result) {
1594+
napi_status NAPI_CDECL
1595+
napi_create_object_with_properties(napi_env env,
1596+
napi_value prototype_or_null,
1597+
napi_value* property_names,
1598+
napi_value* property_values,
1599+
size_t property_count,
1600+
napi_value* result) {
16011601
CHECK_ENV_NOT_IN_GC(env);
16021602
CHECK_ARG(env, result);
16031603

@@ -1607,7 +1607,7 @@ napi_status NAPI_CDECL napi_create_object_with_properties(
16071607
}
16081608

16091609
v8::Local<v8::Value> v8_prototype_or_null =
1610-
v8impl::V8LocalValueFromJsValue(prototype_or_null);
1610+
v8impl::V8LocalValueFromJsValue(prototype_or_null);
16111611

16121612
v8::Local<v8::Object> obj;
16131613

@@ -1629,11 +1629,8 @@ napi_status NAPI_CDECL napi_create_object_with_properties(
16291629
v8_values.data(),
16301630
property_count);
16311631
} else {
1632-
obj = v8::Object::New(env->isolate,
1633-
v8_prototype_or_null,
1634-
nullptr,
1635-
nullptr,
1636-
0);
1632+
obj = v8::Object::New(
1633+
env->isolate, v8_prototype_or_null, nullptr, nullptr, 0);
16371634
}
16381635

16391636
RETURN_STATUS_IF_FALSE(env, !obj.IsEmpty(), napi_generic_failure);

test/js-native-api/test_object/test_object.c

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -710,40 +710,49 @@ CheckTypeTag(napi_env env, napi_callback_info info) {
710710
return js_result;
711711
}
712712

713-
static napi_value TestCreateObjectWithProperties(napi_env env, napi_callback_info info) {
713+
static napi_value TestCreateObjectWithProperties(napi_env env,
714+
napi_callback_info info) {
714715
napi_value names[3];
715716
napi_value values[3];
716717
napi_value result;
717718

718-
NODE_API_CALL(env, napi_create_string_utf8(env, "name", NAPI_AUTO_LENGTH, &names[0]));
719-
NODE_API_CALL(env, napi_create_string_utf8(env, "Foo", NAPI_AUTO_LENGTH, &values[0]));
719+
NODE_API_CALL(
720+
env, napi_create_string_utf8(env, "name", NAPI_AUTO_LENGTH, &names[0]));
721+
NODE_API_CALL(
722+
env, napi_create_string_utf8(env, "Foo", NAPI_AUTO_LENGTH, &values[0]));
720723

721-
NODE_API_CALL(env, napi_create_string_utf8(env, "age", NAPI_AUTO_LENGTH, &names[1]));
724+
NODE_API_CALL(
725+
env, napi_create_string_utf8(env, "age", NAPI_AUTO_LENGTH, &names[1]));
722726
NODE_API_CALL(env, napi_create_int32(env, 42, &values[1]));
723727

724-
NODE_API_CALL(env, napi_create_string_utf8(env, "active", NAPI_AUTO_LENGTH, &names[2]));
728+
NODE_API_CALL(
729+
env, napi_create_string_utf8(env, "active", NAPI_AUTO_LENGTH, &names[2]));
725730
NODE_API_CALL(env, napi_get_boolean(env, true, &values[2]));
726731

727732
napi_value null_prototype;
728733
NODE_API_CALL(env, napi_get_null(env, &null_prototype));
729-
NODE_API_CALL(env, napi_create_object_with_properties(
730-
env, null_prototype, names, values, 3, &result));
734+
NODE_API_CALL(env,
735+
napi_create_object_with_properties(
736+
env, null_prototype, names, values, 3, &result));
731737

732738
return result;
733739
}
734740

735-
static napi_value TestCreateObjectWithPropertiesEmpty(napi_env env, napi_callback_info info) {
741+
static napi_value TestCreateObjectWithPropertiesEmpty(napi_env env,
742+
napi_callback_info info) {
736743
napi_value result;
737744

738745
napi_value null_prototype;
739746
NODE_API_CALL(env, napi_get_null(env, &null_prototype));
740-
NODE_API_CALL(env, napi_create_object_with_properties(
741-
env, null_prototype, NULL, NULL, 0, &result));
747+
NODE_API_CALL(env,
748+
napi_create_object_with_properties(
749+
env, null_prototype, NULL, NULL, 0, &result));
742750

743751
return result;
744752
}
745753

746-
static napi_value TestCreateObjectWithCustomPrototype(napi_env env, napi_callback_info info) {
754+
static napi_value TestCreateObjectWithCustomPrototype(napi_env env,
755+
napi_callback_info info) {
747756
napi_value prototype;
748757
napi_value method_name;
749758
napi_value method_func;
@@ -752,16 +761,26 @@ static napi_value TestCreateObjectWithCustomPrototype(napi_env env, napi_callbac
752761
napi_value result;
753762

754763
NODE_API_CALL(env, napi_create_object(env, &prototype));
755-
NODE_API_CALL(env, napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &method_name));
756-
NODE_API_CALL(env, napi_create_function(env, "test", NAPI_AUTO_LENGTH,
757-
TestCreateObjectWithProperties, NULL, &method_func));
758-
NODE_API_CALL(env, napi_set_property(env, prototype, method_name, method_func));
764+
NODE_API_CALL(
765+
env,
766+
napi_create_string_utf8(env, "test", NAPI_AUTO_LENGTH, &method_name));
767+
NODE_API_CALL(env,
768+
napi_create_function(env,
769+
"test",
770+
NAPI_AUTO_LENGTH,
771+
TestCreateObjectWithProperties,
772+
NULL,
773+
&method_func));
774+
NODE_API_CALL(env,
775+
napi_set_property(env, prototype, method_name, method_func));
759776

760-
NODE_API_CALL(env, napi_create_string_utf8(env, "value", NAPI_AUTO_LENGTH, &names[0]));
777+
NODE_API_CALL(
778+
env, napi_create_string_utf8(env, "value", NAPI_AUTO_LENGTH, &names[0]));
761779
NODE_API_CALL(env, napi_create_int32(env, 42, &values[0]));
762780

763-
NODE_API_CALL(env, napi_create_object_with_properties(
764-
env, prototype, names, values, 1, &result));
781+
NODE_API_CALL(env,
782+
napi_create_object_with_properties(
783+
env, prototype, names, values, 1, &result));
765784

766785
return result;
767786
}
@@ -799,9 +818,12 @@ napi_value Init(napi_env env, napi_value exports) {
799818
DECLARE_NODE_API_PROPERTY("TestGetProperty", TestGetProperty),
800819
DECLARE_NODE_API_PROPERTY("TestFreeze", TestFreeze),
801820
DECLARE_NODE_API_PROPERTY("TestSeal", TestSeal),
802-
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithProperties", TestCreateObjectWithProperties),
803-
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithPropertiesEmpty", TestCreateObjectWithPropertiesEmpty),
804-
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithCustomPrototype", TestCreateObjectWithCustomPrototype),
821+
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithProperties",
822+
TestCreateObjectWithProperties),
823+
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithPropertiesEmpty",
824+
TestCreateObjectWithPropertiesEmpty),
825+
DECLARE_NODE_API_PROPERTY("TestCreateObjectWithCustomPrototype",
826+
TestCreateObjectWithCustomPrototype),
805827
};
806828

807829
init_test_null(env, exports);

0 commit comments

Comments
 (0)