Skip to content

Commit

Permalink
Use parenthesis for all assert statements and fix BitFlag
Browse files Browse the repository at this point in the history
Required in Godot 3.2
  • Loading branch information
aaronfranke committed Dec 1, 2019
1 parent 182fa8c commit c2368e8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
1 change: 0 additions & 1 deletion addons/godot-next/data/singleton_cache.tres
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@

[resource]
script = ExtResource( 1 )

66 changes: 33 additions & 33 deletions addons/godot-next/references/array_2d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ func has_cell(p_row: int, p_col: int) -> bool:
return len(data) > p_row and len(data[p_row]) > p_col

func set_cell(p_row: int, p_col: int, p_value):
assert has_cell(p_row, p_col)
assert(has_cell(p_row, p_col))
data[p_row][p_col] = p_value

func get_cell(p_row: int, p_col: int):
assert has_cell(p_row, p_col)
assert(has_cell(p_row, p_col))
return data[p_row][p_col]

func set_cell_if_exists(p_row: int, p_col: int, p_value) -> bool:
Expand All @@ -44,11 +44,11 @@ func has_cellv(p_pos: Vector2) -> bool:
return len(data) > p_pos.x and len(data[p_pos.x]) > p_pos.y

func set_cellv(p_pos: Vector2, p_value):
assert has_cellv(p_pos)
assert(has_cellv(p_pos))
data[p_pos.x][p_pos.y] = p_value

func get_cellv(p_pos: Vector2):
assert has_cellv(p_pos)
assert(has_cellv(p_pos))
return data[p_pos.x][p_pos.y]

func set_cellv_if_exists(p_pos: Vector2, p_value) -> bool:
Expand All @@ -58,39 +58,39 @@ func set_cellv_if_exists(p_pos: Vector2, p_value) -> bool:
return false

func get_row(p_idx: int):
assert len(data) > p_idx
assert p_idx >= 0
assert(len(data) > p_idx)
assert(p_idx >= 0)
return data[p_idx].duplicate()

func get_col(p_idx: int):
var result = []
for a_row in data:
assert len(a_row) > p_idx
assert p_idx >= 0
assert(len(a_row) > p_idx)
assert(p_idx >= 0)
result.push_back(a_row[p_idx])
return result

func get_row_ref(p_idx: int):
assert len(data) > p_idx
assert p_idx >= 0
assert(len(data) > p_idx)
assert(p_idx >= 0)
return data[p_idx]

func get_rows() -> Array:
return data

func set_row(p_idx: int, p_row):
assert len(data) > p_idx
assert p_idx >= 0
assert len(data) == len(p_row)
assert(len(data) > p_idx)
assert(p_idx >= 0)
assert(len(data) == len(p_row))
data[p_idx] = p_row

func set_col(p_idx: int, p_col):
assert len(data) > 0 and len(data[0]) > 0
assert len(data) == len(p_col)
assert(len(data) > 0 and len(data[0]) > 0)
assert(len(data) == len(p_col))
var idx = 0
for a_row in data:
assert len(a_row) > p_idx
assert p_idx >= 0
assert(len(a_row) > p_idx)
assert(p_idx >= 0)
a_row[p_idx] = p_col[idx]
idx += 1

Expand Down Expand Up @@ -163,31 +163,31 @@ func fill(p_value):
data[a_row][a_col] = p_value

func fill_row(p_idx: int, p_value):
assert p_idx >= 0
assert len(data) > p_idx
assert len(data[0]) > 0
assert(p_idx >= 0)
assert(len(data) > p_idx)
assert(len(data[0]) > 0)
var arr = []
for i in len(data[0]):
arr.push_back(p_value)
data[p_idx] = arr

func fill_col(p_idx: int, p_value):
assert p_idx >= 0
assert len(data) > 0
assert len(data[0]) > p_idx
assert(p_idx >= 0)
assert(len(data) > 0)
assert(len(data[0]) > p_idx)
var arr = []
for i in len(data):
arr.push_back(p_value)
set_col(p_idx, arr)

func remove_row(p_idx: int):
assert p_idx >= 0
assert len(data) > p_idx
assert(p_idx >= 0)
assert(len(data) > p_idx)
data.remove(p_idx)

func remove_col(p_idx: int):
assert len(data) > 0
assert p_idx >= 0 and len(data[0]) > p_idx
assert(len(data) > 0)
assert(p_idx >= 0 and len(data[0]) > p_idx)
for a_row in data:
a_row.remove(p_idx)

Expand All @@ -211,25 +211,25 @@ func invert() -> Array2D:
return self

func invert_row(p_idx: int) -> Array2D:
assert p_idx >= 0 and len(data) > p_idx
assert(p_idx >= 0 and len(data) > p_idx)
data[p_idx].invert()
return self

func invert_col(p_idx: int) -> Array2D:
assert len(data) > 0
assert p_idx >= 0 and len(data[0]) > p_idx
assert(len(data) > 0)
assert(p_idx >= 0 and len(data[0]) > p_idx)
var col = get_col(p_idx)
col.invert()
set_col(p_idx, col)
return self

func bsearch_row(p_idx: int, p_value, p_before: bool) -> int:
assert p_idx >= 0 and len(data) > p_idx
assert(p_idx >= 0 and len(data) > p_idx)
return data[p_idx].bsearch(p_value, p_before)

func bsearch_col(p_idx: int, p_value, p_before: bool) -> int:
assert len(data) > 0
assert p_idx >= 0 and len(data[0]) > p_idx
assert(len(data) > 0)
assert(p_idx >= 0 and len(data[0]) > p_idx)
var col = get_col(p_idx)
col.sort()
return col[p_idx].bsearch(p_value, p_before)
Expand Down
1 change: 1 addition & 0 deletions addons/godot-next/references/bit_flag.gd
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func _get_value_flags(p_value) -> int:
TYPE_INT:
return p_value
assert(false)
return -1

##### PUBLIC METHODS #####

Expand Down
2 changes: 1 addition & 1 deletion addons/godot-next/resources/behavior.gd
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func get_enabled() -> bool:
return enabled

func set_owner(p_owner: Node) -> void:
assert p_owner # must be assigned a valid owner at all times, except initially.
assert(p_owner) # must be assigned a valid owner at all times, except initially.
owner = p_owner

func get_owner() -> Node:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ func _get_property_list() -> Array:
# Append an element to the collection.
#warning-ignore:unused_argument
func _add_element(p_script: Script) -> void:
assert false
assert(false)

# Refresh the data upon type change.
func _refresh_data() -> void:
assert false
assert(false)

# Export properties within the 'data' group
func _export_data_group() -> Array:
Expand All @@ -86,7 +86,7 @@ func _parse_property(p_plugin: EditorInspectorPlugin, p_pinfo: PropertyInfo) ->
##### PUBLIC METHODS #####

func clear() -> void:
assert false
assert(false)

##### PRIVATE METHODS #####

Expand Down

0 comments on commit c2368e8

Please sign in to comment.