Skip to content

Commit

Permalink
Adding WA bindings. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Dec 27, 2024
1 parent 71de0ea commit 9e45483
Show file tree
Hide file tree
Showing 206 changed files with 8,301 additions and 1,729 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ Projects/Linux/3rdParty/
# Ignore rust files
Source/Rust/lib/*
Source/Rust/target/*

# Ignore files build by Wa
Tools/dora-wa/output
2 changes: 1 addition & 1 deletion Source/Basic/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include <thread>

#define DORA_VERSION "1.6.2"_slice
#define DORA_REVISION "3"_slice
#define DORA_REVISION "4"_slice

#if BX_PLATFORM_ANDROID
#include <jni.h>
Expand Down
2 changes: 1 addition & 1 deletion Source/Rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Source/Wasm/Dora/ActionWasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ int32_t action_is_running(int64_t self) {
int32_t action_is_paused(int64_t self) {
return r_cast<Action*>(self)->isPaused() ? 1 : 0;
}
void action_set_reversed(int64_t self, int32_t var) {
r_cast<Action*>(self)->setReversed(var != 0);
void action_set_reversed(int64_t self, int32_t val) {
r_cast<Action*>(self)->setReversed(val != 0);
}
int32_t action_is_reversed(int64_t self) {
return r_cast<Action*>(self)->isReversed() ? 1 : 0;
}
void action_set_speed(int64_t self, float var) {
r_cast<Action*>(self)->setSpeed(var);
void action_set_speed(int64_t self, float val) {
r_cast<Action*>(self)->setSpeed(val);
}
float action_get_speed(int64_t self) {
return r_cast<Action*>(self)->getSpeed();
Expand Down
40 changes: 20 additions & 20 deletions Source/Wasm/Dora/ApplicationWasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,62 +50,62 @@ int32_t application_get_max_fps() {
int32_t application_is_debugging() {
return SharedApplication.isDebugging() ? 1 : 0;
}
void application_set_locale(int64_t var) {
SharedApplication.setLocale(*Str_From(var));
void application_set_locale(int64_t val) {
SharedApplication.setLocale(*Str_From(val));
}
int64_t application_get_locale() {
return Str_Retain(SharedApplication.getLocale());
}
void application_set_theme_color(int32_t var) {
SharedApplication.setThemeColor(Color(s_cast<uint32_t>(var)));
void application_set_theme_color(int32_t val) {
SharedApplication.setThemeColor(Color(s_cast<uint32_t>(val)));
}
int32_t application_get_theme_color() {
return SharedApplication.getThemeColor().toARGB();
}
void application_set_seed(int32_t var) {
SharedApplication.setSeed(s_cast<uint32_t>(var));
void application_set_seed(int32_t val) {
SharedApplication.setSeed(s_cast<uint32_t>(val));
}
int32_t application_get_seed() {
return s_cast<int32_t>(SharedApplication.getSeed());
}
void application_set_target_fps(int32_t var) {
SharedApplication.setTargetFPS(s_cast<uint32_t>(var));
void application_set_target_fps(int32_t val) {
SharedApplication.setTargetFPS(s_cast<uint32_t>(val));
}
int32_t application_get_target_fps() {
return s_cast<int32_t>(SharedApplication.getTargetFPS());
}
void application_set_win_size(int64_t var) {
SharedApplication.setWinSize(Size_From(var));
void application_set_win_size(int64_t val) {
SharedApplication.setWinSize(Size_From(val));
}
int64_t application_get_win_size() {
return Size_Retain(SharedApplication.getWinSize());
}
void application_set_win_position(int64_t var) {
SharedApplication.setWinPosition(Vec2_From(var));
void application_set_win_position(int64_t val) {
SharedApplication.setWinPosition(Vec2_From(val));
}
int64_t application_get_win_position() {
return Vec2_Retain(SharedApplication.getWinPosition());
}
void application_set_fps_limited(int32_t var) {
SharedApplication.setFPSLimited(var != 0);
void application_set_fps_limited(int32_t val) {
SharedApplication.setFPSLimited(val != 0);
}
int32_t application_is_fps_limited() {
return SharedApplication.isFPSLimited() ? 1 : 0;
}
void application_set_idled(int32_t var) {
SharedApplication.setIdled(var != 0);
void application_set_idled(int32_t val) {
SharedApplication.setIdled(val != 0);
}
int32_t application_is_idled() {
return SharedApplication.isIdled() ? 1 : 0;
}
void application_set_full_screen(int32_t var) {
SharedApplication.setFullScreen(var != 0);
void application_set_full_screen(int32_t val) {
SharedApplication.setFullScreen(val != 0);
}
int32_t application_is_full_screen() {
return SharedApplication.isFullScreen() ? 1 : 0;
}
void application_set_always_on_top(int32_t var) {
SharedApplication.setAlwaysOnTop(var != 0);
void application_set_always_on_top(int32_t val) {
SharedApplication.setAlwaysOnTop(val != 0);
}
int32_t application_is_always_on_top() {
return SharedApplication.isAlwaysOnTop() ? 1 : 0;
Expand Down
54 changes: 27 additions & 27 deletions Source/Wasm/Dora/BodyDefWasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,74 @@ using namespace Dora;
int32_t bodydef_type() {
return DoraType<BodyDef>();
}
void bodydef__set_type(int64_t self, int32_t var) {
BodyDef_SetTypeEnum(r_cast<BodyDef*>(self), s_cast<int>(var));
void bodydef__set_type(int64_t self, int32_t val) {
BodyDef_SetTypeEnum(r_cast<BodyDef*>(self), s_cast<int>(val));
}
int32_t bodydef__get_type(int64_t self) {
return BodyDef_GetTypeEnum(r_cast<BodyDef*>(self));
}
void bodydef_set_position(int64_t self, int64_t var) {
r_cast<BodyDef*>(self)->offset = Vec2_From(var);
void bodydef_set_position(int64_t self, int64_t val) {
r_cast<BodyDef*>(self)->offset = Vec2_From(val);
}
int64_t bodydef_get_position(int64_t self) {
return Vec2_Retain(r_cast<BodyDef*>(self)->offset);
}
void bodydef_set_angle(int64_t self, float var) {
r_cast<BodyDef*>(self)->angleOffset = s_cast<float>(var);
void bodydef_set_angle(int64_t self, float val) {
r_cast<BodyDef*>(self)->angleOffset = s_cast<float>(val);
}
float bodydef_get_angle(int64_t self) {
return r_cast<BodyDef*>(self)->angleOffset;
}
void bodydef_set_face(int64_t self, int64_t var) {
r_cast<BodyDef*>(self)->face = *Str_From(var);
void bodydef_set_face(int64_t self, int64_t val) {
r_cast<BodyDef*>(self)->face = *Str_From(val);
}
int64_t bodydef_get_face(int64_t self) {
return Str_Retain(r_cast<BodyDef*>(self)->face);
}
void bodydef_set_face_pos(int64_t self, int64_t var) {
r_cast<BodyDef*>(self)->facePos = Vec2_From(var);
void bodydef_set_face_pos(int64_t self, int64_t val) {
r_cast<BodyDef*>(self)->facePos = Vec2_From(val);
}
int64_t bodydef_get_face_pos(int64_t self) {
return Vec2_Retain(r_cast<BodyDef*>(self)->facePos);
}
void bodydef_set_linear_damping(int64_t self, float var) {
r_cast<BodyDef*>(self)->setLinearDamping(var);
void bodydef_set_linear_damping(int64_t self, float val) {
r_cast<BodyDef*>(self)->setLinearDamping(val);
}
float bodydef_get_linear_damping(int64_t self) {
return r_cast<BodyDef*>(self)->getLinearDamping();
}
void bodydef_set_angular_damping(int64_t self, float var) {
r_cast<BodyDef*>(self)->setAngularDamping(var);
void bodydef_set_angular_damping(int64_t self, float val) {
r_cast<BodyDef*>(self)->setAngularDamping(val);
}
float bodydef_get_angular_damping(int64_t self) {
return r_cast<BodyDef*>(self)->getAngularDamping();
}
void bodydef_set_linear_acceleration(int64_t self, int64_t var) {
r_cast<BodyDef*>(self)->setLinearAcceleration(Vec2_From(var));
void bodydef_set_linear_acceleration(int64_t self, int64_t val) {
r_cast<BodyDef*>(self)->setLinearAcceleration(Vec2_From(val));
}
int64_t bodydef_get_linear_acceleration(int64_t self) {
return Vec2_Retain(r_cast<BodyDef*>(self)->getLinearAcceleration());
}
void bodydef_set_fixed_rotation(int64_t self, int32_t var) {
r_cast<BodyDef*>(self)->setFixedRotation(var != 0);
void bodydef_set_fixed_rotation(int64_t self, int32_t val) {
r_cast<BodyDef*>(self)->setFixedRotation(val != 0);
}
int32_t bodydef_is_fixed_rotation(int64_t self) {
return r_cast<BodyDef*>(self)->isFixedRotation() ? 1 : 0;
}
void bodydef_set_bullet(int64_t self, int32_t var) {
r_cast<BodyDef*>(self)->setBullet(var != 0);
void bodydef_set_bullet(int64_t self, int32_t val) {
r_cast<BodyDef*>(self)->setBullet(val != 0);
}
int32_t bodydef_is_bullet(int64_t self) {
return r_cast<BodyDef*>(self)->isBullet() ? 1 : 0;
}
int64_t bodydef_polygon_with_center(int64_t center, float width, float height, float angle, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::polygon(Vec2_From(center), width, height, angle, density, friction, restitution));
return Object_From(BodyDef::polygon(Vec2_From(center), width, height, angle, density, friction, restitution));
}
int64_t bodydef_polygon(float width, float height, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::polygon(width, height, density, friction, restitution));
return Object_From(BodyDef::polygon(width, height, density, friction, restitution));
}
int64_t bodydef_polygon_with_vertices(int64_t vertices, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::polygon(Vec_FromVec2(vertices), density, friction, restitution));
return Object_From(BodyDef::polygon(Vec_FromVec2(vertices), density, friction, restitution));
}
void bodydef_attach_polygon_with_center(int64_t self, int64_t center, float width, float height, float angle, float density, float friction, float restitution) {
r_cast<BodyDef*>(self)->attachPolygon(Vec2_From(center), width, height, angle, density, friction, restitution);
Expand All @@ -90,16 +90,16 @@ void bodydef_attach_polygon_with_vertices(int64_t self, int64_t vertices, float
r_cast<BodyDef*>(self)->attachPolygon(Vec_FromVec2(vertices), density, friction, restitution);
}
int64_t bodydef_multi(int64_t vertices, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::multi(Vec_FromVec2(vertices), density, friction, restitution));
return Object_From(BodyDef::multi(Vec_FromVec2(vertices), density, friction, restitution));
}
void bodydef_attach_multi(int64_t self, int64_t vertices, float density, float friction, float restitution) {
r_cast<BodyDef*>(self)->attachMulti(Vec_FromVec2(vertices), density, friction, restitution);
}
int64_t bodydef_disk_with_center(int64_t center, float radius, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::disk(Vec2_From(center), radius, density, friction, restitution));
return Object_From(BodyDef::disk(Vec2_From(center), radius, density, friction, restitution));
}
int64_t bodydef_disk(float radius, float density, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::disk(radius, density, friction, restitution));
return Object_From(BodyDef::disk(radius, density, friction, restitution));
}
void bodydef_attach_disk_with_center(int64_t self, int64_t center, float radius, float density, float friction, float restitution) {
r_cast<BodyDef*>(self)->attachDisk(Vec2_From(center), radius, density, friction, restitution);
Expand All @@ -108,7 +108,7 @@ void bodydef_attach_disk(int64_t self, float radius, float density, float fricti
r_cast<BodyDef*>(self)->attachDisk(radius, density, friction, restitution);
}
int64_t bodydef_chain(int64_t vertices, float friction, float restitution) {
return r_cast<int64_t>(BodyDef::chain(Vec_FromVec2(vertices), friction, restitution));
return Object_From(BodyDef::chain(Vec_FromVec2(vertices), friction, restitution));
}
void bodydef_attach_chain(int64_t self, int64_t vertices, float friction, float restitution) {
r_cast<BodyDef*>(self)->attachChain(Vec_FromVec2(vertices), friction, restitution);
Expand Down
54 changes: 27 additions & 27 deletions Source/Wasm/Dora/BodyWasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,56 +23,56 @@ float body_get_mass(int64_t self) {
int32_t body_is_sensor(int64_t self) {
return r_cast<Body*>(self)->isSensor() ? 1 : 0;
}
void body_set_velocity_x(int64_t self, float var) {
r_cast<Body*>(self)->setVelocityX(var);
void body_set_velocity_x(int64_t self, float val) {
r_cast<Body*>(self)->setVelocityX(val);
}
float body_get_velocity_x(int64_t self) {
return r_cast<Body*>(self)->getVelocityX();
}
void body_set_velocity_y(int64_t self, float var) {
r_cast<Body*>(self)->setVelocityY(var);
void body_set_velocity_y(int64_t self, float val) {
r_cast<Body*>(self)->setVelocityY(val);
}
float body_get_velocity_y(int64_t self) {
return r_cast<Body*>(self)->getVelocityY();
}
void body_set_velocity(int64_t self, int64_t var) {
r_cast<Body*>(self)->setVelocity(Vec2_From(var));
void body_set_velocity(int64_t self, int64_t val) {
r_cast<Body*>(self)->setVelocity(Vec2_From(val));
}
int64_t body_get_velocity(int64_t self) {
return Vec2_Retain(r_cast<Body*>(self)->getVelocity());
}
void body_set_angular_rate(int64_t self, float var) {
r_cast<Body*>(self)->setAngularRate(var);
void body_set_angular_rate(int64_t self, float val) {
r_cast<Body*>(self)->setAngularRate(val);
}
float body_get_angular_rate(int64_t self) {
return r_cast<Body*>(self)->getAngularRate();
}
void body_set_group(int64_t self, int32_t var) {
r_cast<Body*>(self)->setGroup(s_cast<uint8_t>(var));
void body_set_group(int64_t self, int32_t val) {
r_cast<Body*>(self)->setGroup(s_cast<uint8_t>(val));
}
int32_t body_get_group(int64_t self) {
return s_cast<int32_t>(r_cast<Body*>(self)->getGroup());
}
void body_set_linear_damping(int64_t self, float var) {
r_cast<Body*>(self)->setLinearDamping(var);
void body_set_linear_damping(int64_t self, float val) {
r_cast<Body*>(self)->setLinearDamping(val);
}
float body_get_linear_damping(int64_t self) {
return r_cast<Body*>(self)->getLinearDamping();
}
void body_set_angular_damping(int64_t self, float var) {
r_cast<Body*>(self)->setAngularDamping(var);
void body_set_angular_damping(int64_t self, float val) {
r_cast<Body*>(self)->setAngularDamping(val);
}
float body_get_angular_damping(int64_t self) {
return r_cast<Body*>(self)->getAngularDamping();
}
void body_set_owner(int64_t self, int64_t var) {
r_cast<Body*>(self)->setOwner(r_cast<Object*>(var));
void body_set_owner(int64_t self, int64_t val) {
r_cast<Body*>(self)->setOwner(r_cast<Object*>(val));
}
int64_t body_get_owner(int64_t self) {
return Object_From(r_cast<Body*>(self)->getOwner());
}
void body_set_receiving_contact(int64_t self, int32_t var) {
r_cast<Body*>(self)->setReceivingContact(var != 0);
void body_set_receiving_contact(int64_t self, int32_t val) {
r_cast<Body*>(self)->setReceivingContact(val != 0);
}
int32_t body_is_receiving_contact(int64_t self) {
return r_cast<Body*>(self)->isReceivingContact() ? 1 : 0;
Expand All @@ -98,16 +98,16 @@ void body_attach(int64_t self, int64_t fixture_def) {
int64_t body_attach_sensor(int64_t self, int32_t tag, int64_t fixture_def) {
return Object_From(r_cast<Body*>(self)->attachSensor(s_cast<int>(tag), r_cast<FixtureDef*>(fixture_def)));
}
void body_on_contact_filter(int64_t self, int32_t func, int64_t stack) {
std::shared_ptr<void> deref(nullptr, [func](auto) {
SharedWasmRuntime.deref(func);
void body_on_contact_filter(int64_t self, int32_t func0, int64_t stack0) {
std::shared_ptr<void> deref0(nullptr, [func0](auto) {
SharedWasmRuntime.deref(func0);
});
auto args = r_cast<CallStack*>(stack);
r_cast<Body*>(self)->onContactFilter([func, args, deref](Body* body) {
args->clear();
args->push(body);
SharedWasmRuntime.invoke(func);
return std::get<bool>(args->pop());
auto args0 = r_cast<CallStack*>(stack0);
r_cast<Body*>(self)->onContactFilter([func0, args0, deref0](Body* body) {
args0->clear();
args0->push(body);
SharedWasmRuntime.invoke(func0);
return std::get<bool>(args0->pop());
});
}
int64_t body_new(int64_t def, int64_t world, int64_t pos, float rot) {
Expand Down
4 changes: 2 additions & 2 deletions Source/Wasm/Dora/BufferWasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ using namespace Dora;
int32_t buffer_type() {
return DoraType<Buffer>();
}
void buffer_set_text(int64_t self, int64_t var) {
r_cast<Buffer*>(self)->setText(*Str_From(var));
void buffer_set_text(int64_t self, int64_t val) {
r_cast<Buffer*>(self)->setText(*Str_From(val));
}
int64_t buffer_get_text(int64_t self) {
return Str_Retain(r_cast<Buffer*>(self)->getText());
Expand Down
22 changes: 11 additions & 11 deletions Source/Wasm/Dora/C45Wasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

extern "C" {
using namespace Dora;
void c45_build_decision_tree_async(int64_t data, int32_t max_depth, int32_t func, int64_t stack) {
std::shared_ptr<void> deref(nullptr, [func](auto) {
SharedWasmRuntime.deref(func);
void c45_build_decision_tree_async(int64_t data, int32_t max_depth, int32_t func0, int64_t stack0) {
std::shared_ptr<void> deref0(nullptr, [func0](auto) {
SharedWasmRuntime.deref(func0);
});
auto args = r_cast<CallStack*>(stack);
MLBuildDecisionTreeAsync(*Str_From(data), s_cast<int>(max_depth), [func, args, deref](double depth, String name, String op, String value) {
args->clear();
args->push(depth);
args->push(name);
args->push(op);
args->push(value);
SharedWasmRuntime.invoke(func);
auto args0 = r_cast<CallStack*>(stack0);
MLBuildDecisionTreeAsync(*Str_From(data), s_cast<int>(max_depth), [func0, args0, deref0](double depth, String name, String op, String value) {
args0->clear();
args0->push(depth);
args0->push(name);
args0->push(op);
args0->push(value);
SharedWasmRuntime.invoke(func0);
});
}
} // extern "C"
Expand Down
Loading

0 comments on commit 9e45483

Please sign in to comment.