From 2f5462c3a242bf804e121ee29aaee8cbf18b0ac5 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 20 Mar 2017 16:32:54 -0700 Subject: [PATCH] Standardize on uintptr_t (fixes issue on Android) --- project/src/ExternalInterface.cpp | 10 +++++----- project/src/backend/sdl/SDLRenderer.cpp | 2 +- project/src/backend/sdl/SDLSystem.cpp | 2 +- project/src/graphics/cairo/CairoBindings.cpp | 2 +- project/src/media/openal/OpenALBindings.cpp | 2 +- project/src/net/curl/CURLBindings.cpp | 20 ++++++++++---------- project/src/system/JNI.cpp | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 6d5d1e28b..713ad0f4c 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -210,7 +210,7 @@ namespace lime { value lime_bytes_from_data_pointer (double data, int length) { - intptr_t ptr = (intptr_t)data; + uintptr_t ptr = (uintptr_t)data; Bytes bytes (length); if (ptr) { @@ -227,7 +227,7 @@ namespace lime { double lime_bytes_get_data_pointer (value bytes) { Bytes data = Bytes (bytes); - return (intptr_t)data.Data (); + return (uintptr_t)data.Data (); } @@ -243,7 +243,7 @@ namespace lime { double lime_cffi_get_native_pointer (value handle) { - return (intptr_t)val_data (handle); + return (uintptr_t)val_data (handle); } @@ -988,7 +988,7 @@ namespace lime { double lime_jni_getenv () { #ifdef ANDROID - return (intptr_t)JNI::GetEnv (); + return (uintptr_t)JNI::GetEnv (); #else return 0; #endif @@ -1282,7 +1282,7 @@ namespace lime { double lime_renderer_get_context (value renderer) { Renderer* targetRenderer = (Renderer*)val_data (renderer); - return (intptr_t)targetRenderer->GetContext (); + return (uintptr_t)targetRenderer->GetContext (); } diff --git a/project/src/backend/sdl/SDLRenderer.cpp b/project/src/backend/sdl/SDLRenderer.cpp index eef939eb5..cfd41e04a 100644 --- a/project/src/backend/sdl/SDLRenderer.cpp +++ b/project/src/backend/sdl/SDLRenderer.cpp @@ -177,7 +177,7 @@ namespace lime { alloc_field (result, val_id ("width"), alloc_int (width)); alloc_field (result, val_id ("height"), alloc_int (height)); - alloc_field (result, val_id ("pixels"), alloc_float ((intptr_t)pixels)); + alloc_field (result, val_id ("pixels"), alloc_float ((uintptr_t)pixels)); alloc_field (result, val_id ("pitch"), alloc_int (pitch)); } diff --git a/project/src/backend/sdl/SDLSystem.cpp b/project/src/backend/sdl/SDLSystem.cpp index 2cc51a119..4050b6271 100644 --- a/project/src/backend/sdl/SDLSystem.cpp +++ b/project/src/backend/sdl/SDLSystem.cpp @@ -428,7 +428,7 @@ namespace lime { { /*#ifdef HX_WINDOWS printf("SDKFLJDSLFKJ\n"); - int fd = _open_osfhandle ((intptr_t)((SDL_RWops*)handle)->hidden.windowsio.h, _O_RDONLY); + int fd = _open_osfhandle ((uintptr_t)((SDL_RWops*)handle)->hidden.windowsio.h, _O_RDONLY); if (fd != -1) { printf("SDKFLJDSLFKJ\n"); diff --git a/project/src/graphics/cairo/CairoBindings.cpp b/project/src/graphics/cairo/CairoBindings.cpp index 37cea139b..3e239b764 100644 --- a/project/src/graphics/cairo/CairoBindings.cpp +++ b/project/src/graphics/cairo/CairoBindings.cpp @@ -440,7 +440,7 @@ namespace lime { double lime_cairo_image_surface_get_data (value handle) { - return (intptr_t)cairo_image_surface_get_data ((cairo_surface_t*)val_data (handle)); + return (uintptr_t)cairo_image_surface_get_data ((cairo_surface_t*)val_data (handle)); } diff --git a/project/src/media/openal/OpenALBindings.cpp b/project/src/media/openal/OpenALBindings.cpp index 01abbf180..8a000d443 100644 --- a/project/src/media/openal/OpenALBindings.cpp +++ b/project/src/media/openal/OpenALBindings.cpp @@ -622,7 +622,7 @@ namespace lime { double lime_al_get_proc_address (HxString fname) { - return (intptr_t)alGetProcAddress (fname.__s); + return (uintptr_t)alGetProcAddress (fname.__s); } diff --git a/project/src/net/curl/CURLBindings.cpp b/project/src/net/curl/CURLBindings.cpp index cd7a75813..9c9214df6 100644 --- a/project/src/net/curl/CURLBindings.cpp +++ b/project/src/net/curl/CURLBindings.cpp @@ -9,21 +9,21 @@ namespace lime { void lime_curl_easy_cleanup (double handle) { - curl_easy_cleanup ((CURL*)(intptr_t)handle); + curl_easy_cleanup ((CURL*)(uintptr_t)handle); } double lime_curl_easy_duphandle (double handle) { - return (intptr_t)curl_easy_duphandle ((CURL*)(intptr_t)handle); + return (uintptr_t)curl_easy_duphandle ((CURL*)(uintptr_t)handle); } value lime_curl_easy_escape (double curl, HxString url, int length) { - char* result = curl_easy_escape ((CURL*)(intptr_t)curl, url.__s, length); + char* result = curl_easy_escape ((CURL*)(uintptr_t)curl, url.__s, length); return result ? alloc_string (result) : alloc_null (); } @@ -32,7 +32,7 @@ namespace lime { value lime_curl_easy_getinfo (double curl, int info) { CURLcode code = CURLE_OK; - CURL* handle = (CURL*)(intptr_t)curl; + CURL* handle = (CURL*)(uintptr_t)curl; CURLINFO type = (CURLINFO)info; switch (type) { @@ -120,21 +120,21 @@ namespace lime { double lime_curl_easy_init () { - return (intptr_t)curl_easy_init (); + return (uintptr_t)curl_easy_init (); } int lime_curl_easy_pause (double handle, int bitmask) { - return curl_easy_pause ((CURL*)(intptr_t)handle, bitmask); + return curl_easy_pause ((CURL*)(uintptr_t)handle, bitmask); } int lime_curl_easy_perform (double easy_handle) { - return curl_easy_perform ((CURL*)(intptr_t)easy_handle); + return curl_easy_perform ((CURL*)(uintptr_t)easy_handle); } @@ -150,7 +150,7 @@ namespace lime { void lime_curl_easy_reset (double curl) { - curl_easy_reset ((CURL*)(intptr_t)curl); + curl_easy_reset ((CURL*)(uintptr_t)curl); } @@ -218,7 +218,7 @@ namespace lime { int lime_curl_easy_setopt (double handle, int option, value parameter) { CURLcode code = CURLE_OK; - CURL* curl = (CURL*)(intptr_t)handle; + CURL* curl = (CURL*)(uintptr_t)handle; CURLoption type = (CURLoption)option; switch (type) { @@ -513,7 +513,7 @@ namespace lime { value lime_curl_easy_unescape (double curl, HxString url, int inlength, int outlength) { - char* result = curl_easy_unescape ((CURL*)(intptr_t)curl, url.__s, inlength, &outlength); + char* result = curl_easy_unescape ((CURL*)(uintptr_t)curl, url.__s, inlength, &outlength); return result ? alloc_string (result) : alloc_null (); } diff --git a/project/src/system/JNI.cpp b/project/src/system/JNI.cpp index 52ecce82a..91691a8d5 100644 --- a/project/src/system/JNI.cpp +++ b/project/src/system/JNI.cpp @@ -1959,7 +1959,7 @@ namespace lime { double lime_jni_get_env () { JNIEnv *env = (JNIEnv*)JNI::GetEnv (); - return (intptr_t)env; + return (uintptr_t)env; }