HL bindings
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <system/CFFI.h>
|
||||
#include <system/System.h>
|
||||
#include <utils/ArrayBufferView.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
@@ -17,6 +18,7 @@ namespace lime {
|
||||
|
||||
ColorMatrix ();
|
||||
ColorMatrix (value colorMatrix);
|
||||
ColorMatrix (HL_ArrayBufferView* colorMatrix);
|
||||
~ColorMatrix ();
|
||||
|
||||
float GetAlphaMultiplier ();
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace lime {
|
||||
Vector2 ();
|
||||
Vector2 (double x, double y);
|
||||
Vector2 (value vec);
|
||||
Vector2 (HL_Vector2* vec);
|
||||
|
||||
vdynamic* Dynamic ();
|
||||
value Value ();
|
||||
|
||||
@@ -55,9 +55,10 @@ namespace lime {
|
||||
|
||||
AudioBuffer ();
|
||||
AudioBuffer (value audioBuffer);
|
||||
AudioBuffer (HL_AudioBuffer* audioBuffer);
|
||||
~AudioBuffer ();
|
||||
|
||||
value Value ();
|
||||
void* Value ();
|
||||
|
||||
int bitsPerSample;
|
||||
int channels;
|
||||
@@ -66,7 +67,8 @@ namespace lime {
|
||||
|
||||
private:
|
||||
|
||||
value mValue;
|
||||
HL_AudioBuffer* _buffer;
|
||||
value _value;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
#define HL_NAME(n) hl_##n
|
||||
#include <hl.h>
|
||||
|
||||
struct hl_varray : varray {};
|
||||
struct hl_vstring : vstring {};
|
||||
|
||||
#undef hl_aptr
|
||||
#define hl_aptr(a,t) ((t*)(((hl_varray*)(a))+1))
|
||||
|
||||
#include <hx/CFFIPrime.h>
|
||||
|
||||
|
||||
|
||||
@@ -9,21 +9,37 @@
|
||||
namespace lime {
|
||||
|
||||
|
||||
struct HL_DisplayMode {
|
||||
|
||||
hl_type* t;
|
||||
int height;
|
||||
PixelFormat pixelFormat;
|
||||
int refreshRate;
|
||||
int width;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class DisplayMode {
|
||||
|
||||
public:
|
||||
|
||||
DisplayMode ();
|
||||
DisplayMode (value DisplayMode);
|
||||
DisplayMode (HL_DisplayMode* DisplayMode);
|
||||
DisplayMode (int width, int height, PixelFormat pixelFormat, int refreshRate);
|
||||
|
||||
value Value ();
|
||||
void* Value ();
|
||||
|
||||
int height;
|
||||
PixelFormat pixelFormat;
|
||||
int refreshRate;
|
||||
int width;
|
||||
|
||||
private:
|
||||
|
||||
HL_DisplayMode* _mode;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -343,7 +343,7 @@ namespace lime {
|
||||
mode.refreshRate = displayMode.refresh_rate;
|
||||
mode.width = displayMode.w;
|
||||
|
||||
alloc_field (display, id_currentMode, mode.Value ());
|
||||
alloc_field (display, id_currentMode, (value)mode.Value ());
|
||||
|
||||
int numDisplayModes = SDL_GetNumDisplayModes (id);
|
||||
value supportedModes = alloc_array (numDisplayModes);
|
||||
@@ -376,7 +376,7 @@ namespace lime {
|
||||
mode.refreshRate = displayMode.refresh_rate;
|
||||
mode.width = displayMode.w;
|
||||
|
||||
val_array_set_i (supportedModes, i, mode.Value ());
|
||||
val_array_set_i (supportedModes, i, (value)mode.Value ());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,21 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
ColorMatrix::ColorMatrix (HL_ArrayBufferView* colorMatrix) {
|
||||
|
||||
Bytes bytes;
|
||||
bytes.Set (colorMatrix->buffer);
|
||||
float* src = (float*)bytes.Data ();
|
||||
|
||||
for (int i = 0; i < 20; i++) {
|
||||
|
||||
data[i] = src[i];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ColorMatrix::~ColorMatrix () {
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
Vector2::Vector2 (HL_Vector2* vec) {
|
||||
|
||||
x = vec->x;
|
||||
y = vec->y;
|
||||
|
||||
}
|
||||
|
||||
|
||||
vdynamic* Vector2::Dynamic () {
|
||||
|
||||
HL_Vector2* result = (HL_Vector2*)malloc (sizeof (HL_Vector2));
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace lime {
|
||||
channels = 0;
|
||||
data = new ArrayBufferView ();
|
||||
sampleRate = 0;
|
||||
mValue = 0;
|
||||
_buffer = 0;
|
||||
_value = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -50,7 +51,20 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
mValue = audioBuffer;
|
||||
_buffer = 0;
|
||||
_value = audioBuffer;
|
||||
|
||||
}
|
||||
|
||||
|
||||
AudioBuffer::AudioBuffer (HL_AudioBuffer* audioBuffer) {
|
||||
|
||||
bitsPerSample = audioBuffer->bitsPerSample;
|
||||
channels = audioBuffer->channels;
|
||||
data = new ArrayBufferView (audioBuffer->data);
|
||||
sampleRate = audioBuffer->sampleRate;
|
||||
_buffer = audioBuffer;
|
||||
_value = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -62,30 +76,42 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value AudioBuffer::Value () {
|
||||
void* AudioBuffer::Value () {
|
||||
|
||||
if (!init) {
|
||||
if (_buffer) {
|
||||
|
||||
id_bitsPerSample = val_id ("bitsPerSample");
|
||||
id_channels = val_id ("channels");
|
||||
id_data = val_id ("data");
|
||||
id_sampleRate = val_id ("sampleRate");
|
||||
init = true;
|
||||
_buffer->bitsPerSample = bitsPerSample;
|
||||
_buffer->channels = channels;
|
||||
//data
|
||||
_buffer->sampleRate = sampleRate;
|
||||
return _buffer;
|
||||
|
||||
} else {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_bitsPerSample = val_id ("bitsPerSample");
|
||||
id_channels = val_id ("channels");
|
||||
id_data = val_id ("data");
|
||||
id_sampleRate = val_id ("sampleRate");
|
||||
init = true;
|
||||
|
||||
}
|
||||
|
||||
if (val_is_null (_value)) {
|
||||
|
||||
_value = alloc_empty_object ();
|
||||
|
||||
}
|
||||
|
||||
alloc_field (_value, id_bitsPerSample, alloc_int (bitsPerSample));
|
||||
alloc_field (_value, id_channels, alloc_int (channels));
|
||||
alloc_field (_value, id_data, data ? data->Value () : alloc_null ());
|
||||
alloc_field (_value, id_sampleRate, alloc_int (sampleRate));
|
||||
return _value;
|
||||
|
||||
}
|
||||
|
||||
if (val_is_null (mValue)) {
|
||||
|
||||
mValue = alloc_empty_object ();
|
||||
|
||||
}
|
||||
|
||||
alloc_field (mValue, id_bitsPerSample, alloc_int (bitsPerSample));
|
||||
alloc_field (mValue, id_channels, alloc_int (channels));
|
||||
alloc_field (mValue, id_data, data ? data->Value () : alloc_null ());
|
||||
alloc_field (mValue, id_sampleRate, alloc_int (sampleRate));
|
||||
return mValue;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,6 +31,16 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
DisplayMode::DisplayMode (HL_DisplayMode* displayMode) {
|
||||
|
||||
width = displayMode->width;
|
||||
height = displayMode->height;
|
||||
pixelFormat = displayMode->pixelFormat;
|
||||
refreshRate = displayMode->refreshRate;
|
||||
|
||||
}
|
||||
|
||||
|
||||
DisplayMode::DisplayMode (int _width, int _height, PixelFormat _pixelFormat, int _refreshRate) {
|
||||
|
||||
width = _width;
|
||||
@@ -41,25 +51,37 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
value DisplayMode::Value () {
|
||||
void* DisplayMode::Value () {
|
||||
|
||||
if (!init) {
|
||||
if (_mode) {
|
||||
|
||||
id_height = val_id ("height");
|
||||
id_pixelFormat = val_id ("pixelFormat");
|
||||
id_refreshRate = val_id ("refreshRate");
|
||||
id_width = val_id ("width");
|
||||
init = true;
|
||||
_mode->height = height;
|
||||
_mode->pixelFormat = pixelFormat;
|
||||
_mode->refreshRate = refreshRate;
|
||||
_mode->width = width;
|
||||
return _mode;
|
||||
|
||||
} else {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_height = val_id ("height");
|
||||
id_pixelFormat = val_id ("pixelFormat");
|
||||
id_refreshRate = val_id ("refreshRate");
|
||||
id_width = val_id ("width");
|
||||
init = true;
|
||||
|
||||
}
|
||||
|
||||
value displayMode = alloc_empty_object ();
|
||||
alloc_field (displayMode, id_height, alloc_int (height));
|
||||
alloc_field (displayMode, id_pixelFormat, alloc_int (pixelFormat));
|
||||
alloc_field (displayMode, id_refreshRate, alloc_int (refreshRate));
|
||||
alloc_field (displayMode, id_width, alloc_int (width));
|
||||
return displayMode;
|
||||
|
||||
}
|
||||
|
||||
value displayMode = alloc_empty_object ();
|
||||
alloc_field (displayMode, id_height, alloc_int (height));
|
||||
alloc_field (displayMode, id_pixelFormat, alloc_int (pixelFormat));
|
||||
alloc_field (displayMode, id_refreshRate, alloc_int (refreshRate));
|
||||
alloc_field (displayMode, id_width, alloc_int (width));
|
||||
return displayMode;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user