void SensorEvent::Dispatch (SensorEvent* event) { if (SensorEvent::callback) { if (!init) { id_id = val_id ("id"); id_type = val_id ("type"); id_x = val_id ("x"); id_y = val_id ("y"); id_z = val_id ("z"); init = true; } value object = (SensorEvent::eventObject ? SensorEvent::eventObject->get () : alloc_empty_object ()); alloc_field (object, id_id, alloc_int (event->id)); alloc_field (object, id_type, alloc_int (event->type)); alloc_field (object, id_x, alloc_float (event->x)); alloc_field (object, id_y, alloc_float (event->y)); alloc_field (object, id_z, alloc_float (event->z)); val_call0 (SensorEvent::callback->get ()); } }
void TouchEvent::Dispatch (TouchEvent* event) { if (TouchEvent::callback) { if (!init) { id_id = val_id ("id"); id_type = val_id ("type"); id_x = val_id ("x"); id_y = val_id ("y"); init = true; } value object = (TouchEvent::eventObject ? TouchEvent::eventObject->get () : alloc_empty_object ()); alloc_field (object, id_id, alloc_int (event->id)); alloc_field (object, id_type, alloc_int (event->type)); alloc_field (object, id_x, alloc_float (event->x)); alloc_field (object, id_y, alloc_float (event->y)); val_call1 (TouchEvent::callback->get (), object); } }
// DECL: inline void getAccelerometerValues(float* pitch, float* roll); void hx_Game_getAccelerometerValues(value thisObj, value pitch, value roll) { Game *_thisObj; float _pitch; float _roll; ValueToObject(thisObj, _thisObj); _thisObj->getAccelerometerValues(&_pitch, &_roll); SetOutParameterValue(pitch, alloc_float(_pitch)); SetOutParameterValue(roll, alloc_float(_roll)); }
/** $float : any -> float? <doc>Convert the value to the corresponding float or return [null]</doc> **/ static value builtin_float( value f ) { if( val_is_string(f) ) { char *c = val_string(f), *end; tfloat f = (tfloat)strtod(c,&end); return (c == end) ? val_null : alloc_float(f); } if( val_is_number(f) ) return alloc_float( val_number(f) ); return val_null; }
value lime_al_get_source3f (int source, int param) { ALfloat val1, val2, val3; alGetSource3f (source, param, &val1, &val2, &val3); value result = alloc_array (3); val_array_set_i (result, 0, alloc_float (val1)); val_array_set_i (result, 1, alloc_float (val2)); val_array_set_i (result, 2, alloc_float (val3)); return result; }
value lime_al_get_buffer3f (int buffer, int param) { ALfloat val1, val2, val3; alGetBuffer3f (buffer, param, &val1, &val2, &val3); value result = alloc_array (3); val_array_set_i (result, 0, alloc_float (val1)); val_array_set_i (result, 1, alloc_float (val2)); val_array_set_i (result, 2, alloc_float (val3)); return result; }
value lime_al_get_source3f (value source, value param) { ALfloat val1, val2, val3; alGetBuffer3f (val_int (source), val_int (param), &val1, &val2, &val3); value result = alloc_array (3); val_array_set_i (result, 0, alloc_float (val1)); val_array_set_i (result, 1, alloc_float (val2)); val_array_set_i (result, 2, alloc_float (val3)); return result; }
value lime_al_get_listener3f (value param) { ALfloat val1, val2, val3; alGetListener3f (val_int (param), &val1, &val2, &val3); value result = alloc_array (3); val_array_set_i (result, 0, alloc_float (val1)); val_array_set_i (result, 1, alloc_float (val2)); val_array_set_i (result, 2, alloc_float (val3)); return result; }
/** sys_cpu_time : void -> float <doc>Return the most accurate CPU time spent since the process started (in seconds)</doc> **/ static value sys_cpu_time() { #ifdef NEKO_WINDOWS FILETIME unused; FILETIME stime; FILETIME utime; if( !GetProcessTimes(GetCurrentProcess(),&unused,&unused,&stime,&utime) ) neko_error(); return alloc_float( ((tfloat)(utime.dwHighDateTime+stime.dwHighDateTime)) * 65.536 * 6.5536 + (((tfloat)utime.dwLowDateTime + (tfloat)stime.dwLowDateTime) / 10000000) ); #else struct tms t; times(&t); return alloc_float( ((tfloat)(t.tms_utime + t.tms_stime)) / CLK_TCK ); #endif }
// DECL: float dot(const Vector3& v) const; value hx_Vector3_dot(value thisObj, value v) { Vector3 *_thisObj, *_v; ValueToObject(thisObj, _thisObj); ValueToObject(v, _v); return alloc_float(_thisObj->dot(*_v)); }
value hx_Quaternion_property_z_set(value thisObj, value _value) { Quaternion *_thisObj; float _flt = ValueToFloat(_value); ValueToObject(thisObj, _thisObj); return alloc_float(_thisObj->z = _flt); }
void GamepadEvent::Dispatch (GamepadEvent* event) { if (GamepadEvent::callback) { if (!init) { id_axis = val_id ("axis"); id_button = val_id ("button"); id_id = val_id ("id"); id_type = val_id ("type"); id_value = val_id ("value"); init = true; } value object = (GamepadEvent::eventObject ? GamepadEvent::eventObject->get () : alloc_empty_object ()); alloc_field (object, id_axis, alloc_int (event->axis)); alloc_field (object, id_button, alloc_int (event->button)); alloc_field (object, id_id, alloc_int (event->id)); alloc_field (object, id_type, alloc_int (event->type)); alloc_field (object, id_value, alloc_float (event->axisValue)); val_call0 (GamepadEvent::callback->get ()); } }
value lime_application_create (value callback) { Application* app = CreateApplication (); Application::callback = new AutoGCRoot (callback); return alloc_float ((intptr_t)app); }
LP new_float(double f) { LP result; result = alloc_float(); RAW_FLOAT(result) = f; return(result); }
// DECL: static float angle(const Vector3& v1, const Vector3& v2); value hx_Vector3_static_angle(value v1, value v2) { Vector3 *_v1, *_v2; ValueToObject(v1, _v1); ValueToObject(v2, _v2); return alloc_float(Vector3::angle(*_v1, *_v2)); }
value sdl2_window_event_to_hx( WindowEvent &new_event, SDL_Event &event ) { value _object = alloc_empty_object(); alloc_field( _object, id_type, alloc_int(event.window.event) ); alloc_field( _object, id_window_id, alloc_int(event.window.windowID) ); alloc_field( _object, id_timestamp, alloc_float(event.window.timestamp/1000.0) ); switch (event.window.event) { case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_RESIZED: case SDL_WINDOWEVENT_SIZE_CHANGED: { alloc_field( _object, id_x, alloc_int(event.window.data1) ); alloc_field( _object, id_y, alloc_int(event.window.data2) ); break; } } //switch event.type return _object; } //sdl2_window_event_to_hx
// DECL: float distanceSquared(const Vector3& v) const; value hx_Vector3_distanceSquared(value thisObj, value v) { Vector3 *_thisObj, *_v; ValueToObject(thisObj, _thisObj); ValueToObject(v, _v); return alloc_float(_thisObj->distanceSquared(*_v)); }
value hx_Vector3_property_z_set(value thisObj, value _value) { Vector3 *_thisObj; float _flt = ValueToFloat(_value); ValueToObject(thisObj, _thisObj); return alloc_float(_thisObj->z = _flt); }
// DECL: float getTriggerValue(unsigned int triggerId) const; value hx_Gamepad_getTriggerValue(value thisObj, value triggerId) { Gamepad *_thisObj; unsigned int _triggerId = ValueToUint(triggerId); ValueToObject(thisObj, _thisObj); return alloc_float(_thisObj->getTriggerValue(_triggerId)); }
// DECL: static float dot(const Vector4& v1, const Vector4& v2); value hx_Vector4_static_dot(value v1, value v2) { Vector4 *_v1, *_v2; ValueToObject(v1, _v1); ValueToObject(v2, _v2); return alloc_float(Vector4::dot(*_v1, *_v2)); }
value lime_al_get_sourcef (value source, value param) { float data; alGetSourcef (val_int (source), val_int (param), &data); return alloc_float (data); }
value lime_alc_get_contexts_device (value context) { ALCcontext* alcContext = (ALCcontext*)(intptr_t)val_float (context); ALCdevice* alcDevice = alcGetContextsDevice (alcContext); return alloc_float ((intptr_t)alcDevice); }
value lime_al_get_listenerf (value param) { float data; alGetListenerf (val_int (param), &data); return alloc_float (data); }
value lime_al_get_bufferf (value buffer, value param) { float data; alGetBufferf (val_int (buffer), val_int (param), &data); return alloc_float (data); }
// DECL: float getJoystickAxisY(unsigned int joystickId) const; value hx_Gamepad_getJoystickAxisY(value thisObj, value joystickId) { Gamepad* _thisObj; unsigned int _joystickId = ValueToUint(joystickId); ValueToObject(thisObj, _thisObj); return alloc_float(_thisObj->getJoystickAxisY(_joystickId)); }
// DECL: float getRotation(Vector3* axis) const; value hx_Transform_getRotation_V3(value thisObj, value axis) { Transform *_thisObj; Vector3 *_axis; ValueToObject(thisObj, _thisObj); ValueToObject(axis, _axis); return alloc_float(_thisObj->getRotation(_axis)); }
// DECL: float intersects(const Plane& plane) const; value hx_Ray_intersects_Plane(value thisObj, value plane) { Ray *_thisObj; Plane *_plane; ValueToObject(thisObj, _thisObj); ValueToObject(plane, _plane); return alloc_float(_thisObj->intersects(*_plane)); }
// DECL: float intersects(const BoundingBox& box) const; value hx_Ray_intersects_BBox(value thisObj, value box) { Ray *_thisObj; BoundingBox *_box; ValueToObject(thisObj, _thisObj); ValueToObject(box, _box); return alloc_float(_thisObj->intersects(*_box)); }
// DECL: float intersects(const Frustum& frustum) const; value hx_Ray_intersects_Frstm(value thisObj, value frustum) { Ray *_thisObj; Frustum *_frustum; ValueToObject(thisObj, _thisObj); ValueToObject(frustum, _frustum); return alloc_float(_thisObj->intersects(*_frustum)); }
// DECL: float intersects(const BoundingSphere& sphere) const; value hx_Ray_intersects_BSphr(value thisObj, value sphere) { Ray *_thisObj; BoundingSphere *_sphere; ValueToObject(thisObj, _thisObj); ValueToObject(sphere, _sphere); return alloc_float(_thisObj->intersects(*_sphere)); }