Skip to content

Commit

Permalink
More WA bindings added. [skip CI]
Browse files Browse the repository at this point in the history
  • Loading branch information
pigpigyyy committed Dec 30, 2024
1 parent 76f0e03 commit d077f7b
Show file tree
Hide file tree
Showing 77 changed files with 3,856 additions and 369 deletions.
307 changes: 168 additions & 139 deletions Tools/WasmGen/gen.yue

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Tools/dora-wa/vendor/dora/action.wa
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func Action.UpdateTo(elapsed: f32, reversed: bool) {
action_update_to(*this.raw, elapsed, ToDoraBool(reversed))
}
func NewAction(def: ActionDef) => Action {
object := Action{}
raw := action_new(def.GetRaw())
object := Action{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
Expand Down
26 changes: 25 additions & 1 deletion Tools/dora-wa/vendor/dora/align_node.wa
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,28 @@ func alignnode_type() => i32
#wa:import dora alignnode_css
func alignnode_css(slf: i64, style: i64)
#wa:import dora alignnode_new
func alignnode_new(is_window_root: i32) => i64
func alignnode_new(is_window_root: i32) => i64
type AlignNode struct { Node }
func AlignNodeFrom(raw: i64) => *AlignNode {
if raw == 0 {
return nil
}
object := AlignNode{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
result := &object
return result
}
func AlignNode.GetTypeId() => i32 {
return alignnode_type()
}
func AlignNode.Css(style: string) {
alignnode_css(*this.raw, ToDoraString(style))
}
func NewAlignNode(is_window_root: bool) => AlignNode {
raw := alignnode_new(ToDoraBool(is_window_root))
object := AlignNode{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
2 changes: 1 addition & 1 deletion Tools/dora-wa/vendor/dora/array.wa
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ func Array.FastRemoveAt(index: i32) => bool {
return array_fast_remove_at(*this.raw, index) != 0
}
func NewArray() => Array {
object := Array{}
raw := array_new()
object := Array{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
Expand Down
16 changes: 15 additions & 1 deletion Tools/dora-wa/vendor/dora/audio.wa
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,18 @@ func audio_stop(handle: i32)
#wa:import dora audio_play_stream
func audio_play_stream(filename: i64, looping: i32, cross_fade_time: f32)
#wa:import dora audio_stop_stream
func audio_stop_stream(fade_time: f32)
func audio_stop_stream(fade_time: f32)
type _Audio struct { }
global Audio = _Audio{}
func _Audio.Play(filename: string, looping: bool) => i32 {
return audio_play(ToDoraString(filename), ToDoraBool(looping))
}
func _Audio.Stop(handle: i32) {
audio_stop(handle)
}
func _Audio.PlayStream(filename: string, looping: bool, cross_fade_time: f32) {
audio_play_stream(ToDoraString(filename), ToDoraBool(looping), cross_fade_time)
}
func _Audio.StopStream(fade_time: f32) {
audio_stop_stream(fade_time)
}
2 changes: 1 addition & 1 deletion Tools/dora-wa/vendor/dora/body.wa
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func Body.OnContactFilter(filter: func(body: Body) => bool) {
body_on_contact_filter(*this.raw, func_id0, *stack0.raw)
}
func NewBody(def: BodyDef, world: PhysicsWorld, pos: Vec2, rot: f32) => Body {
object := Body{}
raw := body_new(def.GetRaw(), world.GetRaw(), pos.ToValue(), rot)
object := Body{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
Expand Down
2 changes: 1 addition & 1 deletion Tools/dora-wa/vendor/dora/body_def.wa
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ func BodyDef.AttachDiskSensor(tag: i32, radius: f32) {
bodydef_attach_disk_sensor(*this.raw, tag, radius)
}
func NewBodyDef() => BodyDef {
object := BodyDef{}
raw := bodydef_new()
object := BodyDef{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
Expand Down
41 changes: 40 additions & 1 deletion Tools/dora-wa/vendor/dora/camera_2d.wa
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,43 @@ func camera2d_set_position(slf: i64, val: i64);
#wa:import dora camera2d_get_position
func camera2d_get_position(slf: i64) => i64
#wa:import dora camera2d_new
func camera2d_new(name: i64) => i64
func camera2d_new(name: i64) => i64
type Camera2D struct { Camera }
func Camera2DFrom(raw: i64) => *Camera2D {
if raw == 0 {
return nil
}
object := Camera2D{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
result := &object
return result
}
func Camera2D.GetTypeId() => i32 {
return camera2d_type()
}
func Camera2D.SetRotation(val: f32) {
camera2d_set_rotation(*this.raw, val)
}
func Camera2D.GetRotation() => f32 {
return camera2d_get_rotation(*this.raw)
}
func Camera2D.SetZoom(val: f32) {
camera2d_set_zoom(*this.raw, val)
}
func Camera2D.GetZoom() => f32 {
return camera2d_get_zoom(*this.raw)
}
func Camera2D.SetPosition(val: Vec2) {
camera2d_set_position(*this.raw, val.ToValue())
}
func Camera2D.GetPosition() => Vec2 {
return Vec2FromValue(camera2d_get_position(*this.raw))
}
func NewCamera2D(name: string) => Camera2D {
raw := camera2d_new(ToDoraString(name))
object := Camera2D{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
29 changes: 28 additions & 1 deletion Tools/dora-wa/vendor/dora/camera_otho.wa
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,31 @@ func cameraotho_set_position(slf: i64, val: i64);
#wa:import dora cameraotho_get_position
func cameraotho_get_position(slf: i64) => i64
#wa:import dora cameraotho_new
func cameraotho_new(name: i64) => i64
func cameraotho_new(name: i64) => i64
type CameraOtho struct { Camera }
func CameraOthoFrom(raw: i64) => *CameraOtho {
if raw == 0 {
return nil
}
object := CameraOtho{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
result := &object
return result
}
func CameraOtho.GetTypeId() => i32 {
return cameraotho_type()
}
func CameraOtho.SetPosition(val: Vec2) {
cameraotho_set_position(*this.raw, val.ToValue())
}
func CameraOtho.GetPosition() => Vec2 {
return Vec2FromValue(cameraotho_get_position(*this.raw))
}
func NewCameraOtho(name: string) => CameraOtho {
raw := cameraotho_new(ToDoraString(name))
object := CameraOtho{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
41 changes: 40 additions & 1 deletion Tools/dora-wa/vendor/dora/clip_node.wa
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,43 @@ func clipnode_set_inverted(slf: i64, val: i32);
#wa:import dora clipnode_is_inverted
func clipnode_is_inverted(slf: i64) => i32
#wa:import dora clipnode_new
func clipnode_new(stencil: i64) => i64
func clipnode_new(stencil: i64) => i64
type ClipNode struct { Node }
func ClipNodeFrom(raw: i64) => *ClipNode {
if raw == 0 {
return nil
}
object := ClipNode{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
result := &object
return result
}
func ClipNode.GetTypeId() => i32 {
return clipnode_type()
}
func ClipNode.SetStencil(val: Node) {
clipnode_set_stencil(*this.raw, val.GetRaw())
}
func ClipNode.GetStencil() => Node {
return *NodeFrom(clipnode_get_stencil(*this.raw))
}
func ClipNode.SetAlphaThreshold(val: f32) {
clipnode_set_alpha_threshold(*this.raw, val)
}
func ClipNode.GetAlphaThreshold() => f32 {
return clipnode_get_alpha_threshold(*this.raw)
}
func ClipNode.SetInverted(val: bool) {
clipnode_set_inverted(*this.raw, ToDoraBool(val))
}
func ClipNode.IsInverted() => bool {
return clipnode_is_inverted(*this.raw) != 0
}
func NewClipNode(stencil: Node) => ClipNode {
raw := clipnode_new(stencil.GetRaw())
object := ClipNode{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
16 changes: 15 additions & 1 deletion Tools/dora-wa/vendor/dora/controller.wa
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,18 @@ func controller__is_button_up(controller_id: i32, name: i64) => i32
#wa:import dora controller__is_button_pressed
func controller__is_button_pressed(controller_id: i32, name: i64) => i32
#wa:import dora controller__get_axis
func controller__get_axis(controller_id: i32, name: i64) => f32
func controller__get_axis(controller_id: i32, name: i64) => f32
type _Controller struct { }
global Controller = _Controller{}
func _Controller.IsButtonDown(controller_id: i32, name: string) => bool {
return controller__is_button_down(controller_id, ToDoraString(name)) != 0
}
func _Controller.IsButtonUp(controller_id: i32, name: string) => bool {
return controller__is_button_up(controller_id, ToDoraString(name)) != 0
}
func _Controller.IsButtonPressed(controller_id: i32, name: string) => bool {
return controller__is_button_pressed(controller_id, ToDoraString(name)) != 0
}
func _Controller.GetAxis(controller_id: i32, name: string) => f32 {
return controller__get_axis(controller_id, ToDoraString(name))
}
61 changes: 60 additions & 1 deletion Tools/dora-wa/vendor/dora/db.wa
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,63 @@ func db_query_with_params_async(sql: i64, params: i64, with_columns: i32, func0:
#wa:import dora db_insert_async
func db_insert_async(table_name: i64, values: i64, func0: i32, stack0: i64)
#wa:import dora db_exec_async
func db_exec_async(sql: i64, values: i64, func0: i32, stack0: i64)
func db_exec_async(sql: i64, values: i64, func0: i32, stack0: i64)
type _DB struct { }
global DB = _DB{}
func _DB.Exist(table_name: string) => bool {
return db_exist(ToDoraString(table_name)) != 0
}
func _DB.ExistSchema(table_name: string, schema: string) => bool {
return db_exist_schema(ToDoraString(table_name), ToDoraString(schema)) != 0
}
func _DB.Exec(sql: string) => i32 {
return db_exec(ToDoraString(sql))
}
func _DB.Transaction(query: DBQuery) => bool {
return db_transaction(query.GetRaw()) != 0
}
func _DB.TransactionAsync(query: DBQuery, callback: func(result: bool)) {
stack0 := NewCallStack()
func_id0 := PushFunction(func() {
result, _ := stack0.PopBool()
callback(result)
})
db_transaction_async(query.GetRaw(), func_id0, *stack0.raw)
}
func _DB.Query(sql: string, with_columns: bool) => DBRecord {
return *DBRecordFrom(db_query(ToDoraString(sql), ToDoraBool(with_columns)))
}
func _DB.QueryWithParams(sql: string, params: Array, with_columns: bool) => DBRecord {
return *DBRecordFrom(db_query_with_params(ToDoraString(sql), params.GetRaw(), ToDoraBool(with_columns)))
}
func _DB.Insert(table_name: string, values: DBParams) {
db_insert(ToDoraString(table_name), values.GetRaw())
}
func _DB.ExecWithRecords(sql: string, values: DBParams) => i32 {
return db_exec_with_records(ToDoraString(sql), values.GetRaw())
}
func _DB.QueryWithParamsAsync(sql: string, params: Array, with_columns: bool, callback: func(result: DBRecord)) {
stack0 := NewCallStack()
func_id0 := PushFunction(func() {
result_raw, _ := stack0.PopI64()
result := *DBRecordFrom(result_raw)
callback(result)
})
db_query_with_params_async(ToDoraString(sql), params.GetRaw(), ToDoraBool(with_columns), func_id0, *stack0.raw)
}
func _DB.InsertAsync(table_name: string, values: DBParams, callback: func(result: bool)) {
stack0 := NewCallStack()
func_id0 := PushFunction(func() {
result, _ := stack0.PopBool()
callback(result)
})
db_insert_async(ToDoraString(table_name), values.GetRaw(), func_id0, *stack0.raw)
}
func _DB.ExecAsync(sql: string, values: DBParams, callback: func(row_changes: i64)) {
stack0 := NewCallStack()
func_id0 := PushFunction(func() {
rowChanges, _ := stack0.PopI64()
callback(rowChanges)
})
db_exec_async(ToDoraString(sql), values.GetRaw(), func_id0, *stack0.raw)
}
29 changes: 28 additions & 1 deletion Tools/dora-wa/vendor/dora/dbparams.wa
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,31 @@ func dbparams_release(raw: i64)
#wa:import dora dbparams_add
func dbparams_add(slf: i64, params: i64)
#wa:import dora dbparams_new
func dbparams_new() => i64
func dbparams_new() => i64
type DBParams struct { raw: *i64 }
func DBParams.GetRaw() => i64 {
return *this.raw
}
func d_b_params_finalizer(ptr: u32) {
dbparams_release(GetPtr(ptr))
}
func DBParamsFrom(raw: i64) => *DBParams {
if raw == 0 {
return nil
}
item := DBParams{}
item.raw = &raw
setFinalizer(item.raw, d_b_params_finalizer)
result := &item
return result
}
func DBParams.Add(params: Array) {
dbparams_add(*this.raw, params.GetRaw())
}
func NewDBParams() => DBParams {
raw := dbparams_new()
object := DBParams{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
32 changes: 31 additions & 1 deletion Tools/dora-wa/vendor/dora/dbquery.wa
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,34 @@ func dbquery_add_with_params(slf: i64, sql: i64, params: i64)
#wa:import dora dbquery_add
func dbquery_add(slf: i64, sql: i64)
#wa:import dora dbquery_new
func dbquery_new() => i64
func dbquery_new() => i64
type DBQuery struct { raw: *i64 }
func DBQuery.GetRaw() => i64 {
return *this.raw
}
func d_b_query_finalizer(ptr: u32) {
dbquery_release(GetPtr(ptr))
}
func DBQueryFrom(raw: i64) => *DBQuery {
if raw == 0 {
return nil
}
item := DBQuery{}
item.raw = &raw
setFinalizer(item.raw, d_b_query_finalizer)
result := &item
return result
}
func DBQuery.AddWithParams(sql: string, params: DBParams) {
dbquery_add_with_params(*this.raw, ToDoraString(sql), params.GetRaw())
}
func DBQuery.Add(sql: string) {
dbquery_add(*this.raw, ToDoraString(sql))
}
func NewDBQuery() => DBQuery {
raw := dbquery_new()
object := DBQuery{}
object.raw = &raw
setFinalizer(object.raw, ObjectFinalizer)
return object
}
Loading

0 comments on commit d077f7b

Please sign in to comment.