Skip to content

Commit 2a91123

Browse files
author
chenlin
committedApr 28, 2024
[FIX] fix setLimit(), getUsedMemory(), gc() error
1 parent 691d49f commit 2a91123

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed
 

‎src/Image.cc

+19-5
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,39 @@ napi_value Image::Init(napi_env env, napi_value exports) { // {{{
128128
regAllCodecs();
129129

130130
napi_status status;
131+
132+
// global properties
133+
napi_property_descriptor globalProperties[] = {
134+
DECLARE_NAPI_ACCESSOR("maxWidth", GetMaxWidth, SetMaxWidth),
135+
DECLARE_NAPI_ACCESSOR("maxHeight", GetMaxHeight, SetMaxHeight),
136+
DECLARE_NAPI_ACCESSOR("usedMemory", GetUsedMemory, nullptr),
137+
DECLARE_NAPI_METHOD("gc", GC)
138+
};
139+
140+
napi_property_descriptor desc = { "SetMaxHeight", 0, SetMaxHeight, 0, 0, 0, napi_default, 0 };
141+
status = napi_define_properties(env, exports, sizeof(globalProperties) / sizeof(globalProperties[0]), globalProperties);
142+
assert(status == napi_ok);
143+
144+
// Image properties
131145
napi_property_descriptor properties[] = {
132146
DECLARE_NAPI_ACCESSOR("width", GetWidth, SetWidth),
133147
DECLARE_NAPI_ACCESSOR("height", GetHeight, SetHeight),
134148
DECLARE_NAPI_ACCESSOR("transparent", GetTransparent, nullptr),
135-
DECLARE_NAPI_ACCESSOR("maxWidth", GetMaxWidth, SetMaxWidth),
136-
DECLARE_NAPI_ACCESSOR("maxHeight", GetMaxHeight, SetMaxHeight),
137-
DECLARE_NAPI_ACCESSOR("usedMemory", GetUsedMemory, nullptr),
149+
// DECLARE_NAPI_ACCESSOR("maxWidth", GetMaxWidth, SetMaxWidth),
150+
// DECLARE_NAPI_ACCESSOR("maxHeight", GetMaxHeight, SetMaxHeight),
151+
// DECLARE_NAPI_ACCESSOR("usedMemory", GetUsedMemory, nullptr),
138152
DECLARE_NAPI_METHOD("resize", Resize),
139153
DECLARE_NAPI_METHOD("rotate", Rotate),
140154
DECLARE_NAPI_METHOD("fillColor", FillColor),
141155
DECLARE_NAPI_METHOD("loadFromBuffer", LoadFromBuffer),
142156
DECLARE_NAPI_METHOD("copyFromImage", CopyFromImage),
143157
DECLARE_NAPI_METHOD("drawImage", DrawImage),
144158
DECLARE_NAPI_METHOD("toBuffer", ToBuffer),
145-
DECLARE_NAPI_METHOD("gc", GC)
159+
// DECLARE_NAPI_METHOD("gc", GC)
146160
};
147161

148162
napi_value cons;
149-
status = napi_define_class(env, "Image", NAPI_AUTO_LENGTH, New, nullptr, 14, properties, &cons);
163+
status = napi_define_class(env, "Image", NAPI_AUTO_LENGTH, New, nullptr, sizeof(globalProperties) / sizeof(globalProperties[0]), properties, &cons);
150164
assert(status == napi_ok);
151165

152166
status = napi_create_reference(env, cons, 1, &constructor);

0 commit comments

Comments
 (0)
Please sign in to comment.