Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "pointerToBuffer" function and use it for handling js functions with arguments of Buffer type #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions src/generated/node-raylib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ inline double doubleFromValue(const Napi::CallbackInfo& info, int index) {
uintptr_t pointerFromValue(const Napi::CallbackInfo& info, int index) {
return (uintptr_t) info[index].As<Napi::Number>().Int64Value();
}
uintptr_t pointerFromBuffer(const Napi::CallbackInfo &info, int index)
{
return (uintptr_t)info[index].As<Napi::Buffer<unsigned char>>().Data();
}
inline unsigned char unsignedcharFromValue(const Napi::CallbackInfo& info, int index) {
return info[index].As<Napi::Number>().Uint32Value();
}
Expand Down Expand Up @@ -1138,7 +1142,7 @@ Napi::Value BindSaveFileData(const Napi::CallbackInfo& info) {
Napi::Value BindExportDataAsCode(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
ExportDataAsCode(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
unsignedintFromValue(info, 1),
(const char *) stringFromValue(info, 2)
)
Expand Down Expand Up @@ -1312,7 +1316,7 @@ Napi::Value BindGetFileModTime(const Napi::CallbackInfo& info) {
Napi::Value BindCompressData(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
CompressData(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
intFromValue(info, 1),
(int *) pointerFromValue(info, 2)
)
Expand All @@ -1322,7 +1326,7 @@ Napi::Value BindCompressData(const Napi::CallbackInfo& info) {
Napi::Value BindDecompressData(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
DecompressData(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
intFromValue(info, 1),
(int *) pointerFromValue(info, 2)
)
Expand All @@ -1332,7 +1336,7 @@ Napi::Value BindDecompressData(const Napi::CallbackInfo& info) {
Napi::Value BindEncodeDataBase64(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
EncodeDataBase64(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
intFromValue(info, 1),
(int *) pointerFromValue(info, 2)
)
Expand All @@ -1342,7 +1346,7 @@ Napi::Value BindEncodeDataBase64(const Napi::CallbackInfo& info) {
Napi::Value BindDecodeDataBase64(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
DecodeDataBase64(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
(int *) pointerFromValue(info, 1)
)
);
Expand Down Expand Up @@ -1792,7 +1796,7 @@ Napi::Value BindLoadImageFromMemory(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
LoadImageFromMemory(
(const char *) stringFromValue(info, 0),
(const unsigned char *) pointerFromValue(info, 1),
(const unsigned char *) pointerFromBuffer(info, 1),
intFromValue(info, 2)
)
);
Expand Down Expand Up @@ -2230,7 +2234,7 @@ Napi::Value BindLoadFontFromMemory(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
LoadFontFromMemory(
(const char *) stringFromValue(info, 0),
(const unsigned char *) pointerFromValue(info, 1),
(const unsigned char *) pointerFromBuffer(info, 1),
intFromValue(info, 2),
intFromValue(info, 3),
(int *) pointerFromValue(info, 4),
Expand All @@ -2250,7 +2254,7 @@ Napi::Value BindIsFontReady(const Napi::CallbackInfo& info) {
Napi::Value BindLoadFontData(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
LoadFontData(
(const unsigned char *) pointerFromValue(info, 0),
(const unsigned char *) pointerFromBuffer(info, 0),
intFromValue(info, 1),
intFromValue(info, 2),
(int *) pointerFromValue(info, 3),
Expand Down Expand Up @@ -2787,7 +2791,7 @@ Napi::Value BindLoadWaveFromMemory(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
LoadWaveFromMemory(
(const char *) stringFromValue(info, 0),
(const unsigned char *) pointerFromValue(info, 1),
(const unsigned char *) pointerFromBuffer(info, 1),
intFromValue(info, 2)
)
);
Expand Down Expand Up @@ -2879,7 +2883,7 @@ Napi::Value BindLoadMusicStreamFromMemory(const Napi::CallbackInfo& info) {
return ToValue(info.Env(),
LoadMusicStreamFromMemory(
(const char *) stringFromValue(info, 0),
(const unsigned char *) pointerFromValue(info, 1),
(const unsigned char *) pointerFromBuffer(info, 1),
intFromValue(info, 2)
)
);
Expand Down Expand Up @@ -5213,7 +5217,7 @@ void BindOpenURL(const Napi::CallbackInfo& info) {

void BindUnloadFileData(const Napi::CallbackInfo& info) {
UnloadFileData(
(unsigned char *) pointerFromValue(info, 0)
(unsigned char *) pointerFromBuffer(info, 0)
);
}

Expand Down