Merge branch '8.1.0-Dev' into 8.2.0-Dev
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
#endif
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
DEFINE_KIND (k_finalizer);
|
||||
|
||||
@@ -175,6 +176,54 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value wstring_to_value (std::wstring* val) {
|
||||
|
||||
if (val) {
|
||||
|
||||
#ifdef HX_WINDOWS
|
||||
return alloc_wstring (val->c_str ());
|
||||
#else
|
||||
std::string _val = std::string (val->begin (), val->end ());
|
||||
return alloc_string (_val.c_str ());
|
||||
#endif
|
||||
|
||||
} else {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
vbyte* wstring_to_vbytes (std::wstring* val) {
|
||||
|
||||
if (val) {
|
||||
|
||||
#ifdef HX_WINDOWS
|
||||
int size = std::wcslen (val->c_str ());
|
||||
char* result = (char*)malloc (size + 1);
|
||||
std::wcstombs (result, val->c_str (), size);
|
||||
result[size] = '\0';
|
||||
return (vbyte*)result;
|
||||
#else
|
||||
std::string _val = std::string (val->begin (), val->end ());
|
||||
int size = std::strlen (_val.c_str ());
|
||||
char* result = (char*)malloc (size + 1);
|
||||
std::strncpy (result, _val.c_str (), size);
|
||||
result[size] = '\0';
|
||||
return (vbyte*)result;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
value lime_application_create () {
|
||||
|
||||
Application* application = CreateApplication ();
|
||||
@@ -687,7 +736,7 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
value _path = alloc_wstring (path->c_str ());
|
||||
value _path = wstring_to_value (path);
|
||||
delete path;
|
||||
return _path;
|
||||
|
||||
@@ -720,13 +769,9 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
int size = std::wcslen (path->c_str ());
|
||||
char* result = (char*)malloc (size + 1);
|
||||
std::wcstombs (result, path->c_str (), size);
|
||||
result[size] = '\0';
|
||||
vbyte* _path = wstring_to_vbytes (path);
|
||||
delete path;
|
||||
|
||||
return (vbyte*)result;
|
||||
return _path;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -757,7 +802,7 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
value _path = alloc_wstring (path->c_str ());
|
||||
value _path = wstring_to_value (path);
|
||||
delete path;
|
||||
return _path;
|
||||
|
||||
@@ -790,13 +835,9 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
int size = std::wcslen (path->c_str ());
|
||||
char* result = (char*)malloc (size + 1);
|
||||
std::wcstombs (result, path->c_str (), size);
|
||||
result[size] = '\0';
|
||||
vbyte* _path = wstring_to_vbytes (path);
|
||||
delete path;
|
||||
|
||||
return (vbyte*)result;
|
||||
return _path;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -830,7 +871,8 @@ namespace lime {
|
||||
|
||||
for (int i = 0; i < files.size (); i++) {
|
||||
|
||||
val_array_set_i (result, i, alloc_wstring (files[i]->c_str ()));
|
||||
value _file = wstring_to_value (files[i]);
|
||||
val_array_set_i (result, i, _file);
|
||||
delete files[i];
|
||||
|
||||
}
|
||||
@@ -864,12 +906,8 @@ namespace lime {
|
||||
|
||||
for (int i = 0; i < files.size (); i++) {
|
||||
|
||||
int size = std::wcslen (files[i]->c_str ());
|
||||
char* _file = (char*)malloc (size + 1);
|
||||
std::wcstombs (_file, files[i]->c_str (), size);
|
||||
_file[size] = '\0';
|
||||
|
||||
*resultData++ = (vbyte*)_file;
|
||||
vbyte* _file = wstring_to_vbytes (files[i]);
|
||||
*resultData++ = _file;
|
||||
delete files[i];
|
||||
|
||||
}
|
||||
@@ -899,7 +937,7 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
value _path = alloc_wstring (path->c_str ());
|
||||
value _path = wstring_to_value (path);
|
||||
delete path;
|
||||
return _path;
|
||||
|
||||
@@ -932,13 +970,9 @@ namespace lime {
|
||||
|
||||
if (path) {
|
||||
|
||||
int size = std::wcslen (path->c_str ());
|
||||
char* result = (char*)malloc (size + 1);
|
||||
std::wcstombs (result, path->c_str (), size);
|
||||
result[size] = '\0';
|
||||
vbyte* _path = wstring_to_vbytes (path);
|
||||
delete path;
|
||||
|
||||
return (vbyte*)result;
|
||||
return _path;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -3518,6 +3552,38 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void lime_window_set_minimum_size (value window, int width, int height) {
|
||||
|
||||
Window* targetWindow = (Window*)val_data (window);
|
||||
targetWindow->SetMinimumSize (width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
HL_PRIM void HL_NAME(hl_window_set_minimum_size) (HL_CFFIPointer* window, int width, int height) {
|
||||
|
||||
Window* targetWindow = (Window*)window->ptr;
|
||||
targetWindow->SetMinimumSize (width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lime_window_set_maximum_size (value window, int width, int height) {
|
||||
|
||||
Window* targetWindow = (Window*)val_data (window);
|
||||
targetWindow->SetMaximumSize (width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
HL_PRIM void HL_NAME(hl_window_set_maximum_size) (HL_CFFIPointer* window, int width, int height) {
|
||||
|
||||
Window* targetWindow = (Window*)window->ptr;
|
||||
targetWindow->SetMaximumSize (width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool lime_window_set_borderless (value window, bool borderless) {
|
||||
|
||||
Window* targetWindow = (Window*)val_data (window);
|
||||
@@ -3986,6 +4052,8 @@ namespace lime {
|
||||
DEFINE_PRIME3v (lime_window_move);
|
||||
DEFINE_PRIME3 (lime_window_read_pixels);
|
||||
DEFINE_PRIME3v (lime_window_resize);
|
||||
DEFINE_PRIME3v (lime_window_set_minimum_size);
|
||||
DEFINE_PRIME3v (lime_window_set_maximum_size);
|
||||
DEFINE_PRIME2 (lime_window_set_borderless);
|
||||
DEFINE_PRIME2v (lime_window_set_cursor);
|
||||
DEFINE_PRIME2 (lime_window_set_display_mode);
|
||||
@@ -4173,6 +4241,8 @@ namespace lime {
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_move, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_DYN, hl_window_read_pixels, _TCFFIPOINTER _TRECTANGLE _TIMAGEBUFFER);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_resize, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_minimum_size, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_maximum_size, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_BOOL, hl_window_set_borderless, _TCFFIPOINTER _BOOL);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_cursor, _TCFFIPOINTER _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_window_set_display_mode, _TCFFIPOINTER _TDISPLAYMODE _TDISPLAYMODE);
|
||||
|
||||
@@ -745,6 +745,20 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void SDLWindow::SetMinimumSize (int width, int height) {
|
||||
|
||||
SDL_SetWindowMinimumSize (sdlWindow, width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SDLWindow::SetMaximumSize (int width, int height) {
|
||||
|
||||
SDL_SetWindowMaximumSize (sdlWindow, width, height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool SDLWindow::SetBorderless (bool borderless) {
|
||||
|
||||
if (borderless) {
|
||||
|
||||
@@ -42,6 +42,8 @@ namespace lime {
|
||||
virtual void Move (int x, int y);
|
||||
virtual void ReadPixels (ImageBuffer *buffer, Rectangle *rect);
|
||||
virtual void Resize (int width, int height);
|
||||
virtual void SetMinimumSize (int width, int height);
|
||||
virtual void SetMaximumSize (int width, int height);
|
||||
virtual bool SetBorderless (bool borderless);
|
||||
virtual void SetCursor (Cursor cursor);
|
||||
virtual void SetDisplayMode (DisplayMode* displayMode);
|
||||
|
||||
@@ -3659,7 +3659,7 @@ namespace lime {
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_effecti, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_effectiv, _TCFFIPOINTER _I32 _ARR);
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_enable, _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_filteri, _TCFFIPOINTER _I32 _DYN);
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_filteri, _TCFFIPOINTER _I32 _I32);
|
||||
DEFINE_HL_PRIM (_VOID, hl_al_filterf, _TCFFIPOINTER _I32 _F32);
|
||||
DEFINE_HL_PRIM (_TCFFIPOINTER, hl_al_gen_aux, _NO_ARG);
|
||||
DEFINE_HL_PRIM (_TCFFIPOINTER, hl_al_gen_buffer, _NO_ARG);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define IS_IN_RANGE(c, f, l) (((c) >= (f)) && ((c) <= (l)))
|
||||
|
||||
|
||||
unsigned long readNextChar (char*& p)
|
||||
unsigned long readNextChar (const char*& p)
|
||||
{
|
||||
// TODO: since UTF-8 is a variable-length
|
||||
// encoding, you should pass in the input
|
||||
@@ -33,7 +33,8 @@ unsigned long readNextChar (char*& p)
|
||||
// can determine if a malformed UTF-8
|
||||
// sequence would exceed the end of the buffer...
|
||||
|
||||
unsigned char c1, c2, *ptr = (unsigned char*) p;
|
||||
const unsigned char* ptr = (const unsigned char*) p;
|
||||
unsigned char c1, c2;
|
||||
unsigned long uc = 0;
|
||||
int seqlen;
|
||||
|
||||
@@ -792,7 +793,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
int Font::GetGlyphIndex (char* character) {
|
||||
int Font::GetGlyphIndex (const char* character) {
|
||||
|
||||
long charCode = readNextChar (character);
|
||||
|
||||
@@ -801,7 +802,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void* Font::GetGlyphIndices (bool useCFFIValue, char* characters) {
|
||||
void* Font::GetGlyphIndices (bool useCFFIValue, const char* characters) {
|
||||
|
||||
if (useCFFIValue) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user