Null string fix

This commit is contained in:
Joshua Granick
2015-09-04 19:40:16 -07:00
parent 8b5a6bd68e
commit 506f95acae
16 changed files with 61 additions and 53 deletions

View File

@@ -167,15 +167,15 @@ namespace lime {
}
HxString lime_clipboard_get_text () {
value lime_clipboard_get_text () {
if (Clipboard::HasText ()) {
return HxString (Clipboard::GetText ());
return alloc_string (Clipboard::GetText ());
} else {
return 0;
return alloc_null ();
}
@@ -189,11 +189,11 @@ namespace lime {
}
HxString lime_file_dialog_open_file (HxString filter, HxString defaultPath) {
value lime_file_dialog_open_file (HxString filter, HxString defaultPath) {
#ifdef LIME_NFD
const char* path = FileDialog::OpenFile (filter.__s, defaultPath.__s);
return HxString (path);
return path ? alloc_string (path) : alloc_null ();
#endif
return 0;
@@ -223,11 +223,11 @@ namespace lime {
}
HxString lime_file_dialog_save_file (HxString filter, HxString defaultPath) {
value lime_file_dialog_save_file (HxString filter, HxString defaultPath) {
#ifdef LIME_NFD
const char* path = FileDialog::SaveFile (filter.__s, defaultPath.__s);
return HxString (path);
return path ? alloc_string (path) : alloc_null ();
#endif
return 0;
@@ -486,16 +486,18 @@ namespace lime {
}
HxString lime_gamepad_get_device_guid (int id) {
value lime_gamepad_get_device_guid (int id) {
return HxString (Gamepad::GetDeviceGUID (id));
const char* guid = Gamepad::GetDeviceGUID (id);
return guid ? alloc_string (guid) : alloc_null ();
}
HxString lime_gamepad_get_device_name (int id) {
value lime_gamepad_get_device_name (int id) {
return HxString (Gamepad::GetDeviceName (id));
const char* name = Gamepad::GetDeviceName (id);
return name ? alloc_string (name) : alloc_null ();
}
@@ -926,10 +928,11 @@ namespace lime {
}
HxString lime_renderer_get_type (double renderer) {
value lime_renderer_get_type (double renderer) {
Renderer* targetRenderer = (Renderer*)(intptr_t)renderer;
return HxString (targetRenderer->Type ());
const char* type = targetRenderer->Type ();
return type ? alloc_string (type) : alloc_null ();
}
@@ -955,9 +958,10 @@ namespace lime {
}
HxString lime_system_get_directory (int type, HxString company, HxString title) {
value lime_system_get_directory (int type, HxString company, HxString title) {
return HxString (System::GetDirectory ((SystemDirectory)type, company.__s, title.__s));
const char* path = System::GetDirectory ((SystemDirectory)type, company.__s, title.__s);
return path ? alloc_string (path) : alloc_null ();
}
@@ -1212,10 +1216,11 @@ namespace lime {
}
HxString lime_window_set_title (double window, HxString title) {
value lime_window_set_title (double window, HxString title) {
Window* targetWindow = (Window*)(intptr_t)window;
return HxString (targetWindow->SetTitle (title.__s));
const char* result = targetWindow->SetTitle (title.__s);
return result ? alloc_string (result) : alloc_null ();
}

View File

@@ -613,9 +613,10 @@ namespace lime {
}
HxString lime_al_get_string (int param) {
value lime_al_get_string (int param) {
return HxString (alGetString (param));
const char* result = alGetString (param);
return result ? alloc_string (result) : alloc_null ();
}
@@ -949,10 +950,11 @@ namespace lime {
}
HxString lime_alc_get_string (double device, int param) {
value lime_alc_get_string (double device, int param) {
ALCdevice* alcDevice = (ALCdevice*)(intptr_t)device;
return HxString (alcGetString (alcDevice, param));
const char* result = alcGetString (alcDevice, param);
return result ? alloc_string (result) : alloc_null ();
}

View File

@@ -924,7 +924,8 @@ namespace lime {
HxString lime_cairo_version_string () {
return HxString (cairo_version_string ());
const char* version = cairo_version_string ();
return version ? HxString (version) : HxString (0, 0);
}

View File

@@ -833,20 +833,20 @@ namespace lime {
}
HxString lime_gl_get_shader_source (int id) {
value lime_gl_get_shader_source (int id) {
int len = 0;
glGetShaderiv (id, GL_SHADER_SOURCE_LENGTH, &len);
if (len == 0) {
return 0;
return alloc_null ();
}
char *buf = new char[len + 1];
glGetShaderSource (id, len + 1, 0, buf);
HxString result = HxString (buf);
value result = alloc_string (buf);
delete [] buf;

View File

@@ -20,10 +20,10 @@ namespace lime {
}
HxString lime_curl_easy_escape (double curl, HxString url, int length) {
value lime_curl_easy_escape (double curl, HxString url, int length) {
char* result = curl_easy_escape ((CURL*)(intptr_t)curl, url.__s, length);
return HxString (result);
return result ? alloc_string (result) : alloc_null ();
}
@@ -500,18 +500,18 @@ namespace lime {
}
HxString lime_curl_easy_strerror (int errornum) {
value lime_curl_easy_strerror (int errornum) {
const char* result = curl_easy_strerror ((CURLcode)errornum);
return HxString (result);
return result ? alloc_string (result) : alloc_null ();
}
HxString lime_curl_easy_unescape (double curl, HxString url, int inlength, int outlength) {
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);
return HxString (result);
return result ? alloc_string (result) : alloc_null ();
}
@@ -566,10 +566,10 @@ namespace lime {
//lime_curl_slist_free_all
HxString lime_curl_version () {
value lime_curl_version () {
char* result = curl_version ();
return HxString (result);
return result ? alloc_string (result) : alloc_null ();
}