Branch: refs/heads/master Author: David Yang davidyang6us@gmail.com Committer: David Yang davidyang6us@gmail.com Date: Sat, 15 Jan 2022 02:00:49 UTC Commit: c8653dbc4001a453a5cef9e5660fe6bbfd72aaae https://github.com/geany/geany/commit/c8653dbc4001a453a5cef9e5660fe6bbfd72aa...
Log Message: ----------- Add test files for GDScript
Modified Paths: -------------- tests/ctags/Makefile.am tests/ctags/gdscript-inner-class.gd tests/ctags/gdscript-inner-class.gd.tags tests/ctags/gdscript-modifiers.gd tests/ctags/gdscript-modifiers.gd.tags tests/ctags/gdscript-no-implicit-class.gd tests/ctags/gdscript-no-implicit-class.gd.tags
Modified: tests/ctags/Makefile.am 3 lines changed, 3 insertions(+), 0 deletions(-) =================================================================== @@ -166,6 +166,9 @@ test_sources = \ fortran_associate.f90 \ fortran_line_continuation.f90 \ func_typedef.h \ + gdscript-inner-class.gd \ + gdscript-modifiers.gd \ + gdscript-no-implicit-class.gd \ geany.nsi \ general.cs \ hex2dec.sql \
Modified: tests/ctags/gdscript-inner-class.gd 96 lines changed, 96 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,96 @@ +# Taken from godot-demo-projects/networking/webrtc_signaling/server/ws_webrtc_server.gd +# of https://github.com/godotengine/godot-demo-projects.git + +extends Node + +const TIMEOUT = 1000 # Unresponsive clients times out after 1 sec +const SEAL_TIME = 10000 # A sealed room will be closed after this time +const ALFNUM = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + +var _alfnum = ALFNUM.to_ascii() + +var rand: RandomNumberGenerator = RandomNumberGenerator.new() +var lobbies: Dictionary = {} +var server: WebSocketServer = WebSocketServer.new() +var peers: Dictionary = {} + +class Peer extends Reference: + var id = -1 + var lobby = "" + var time = OS.get_ticks_msec() + + func _init(peer_id): + id = peer_id + + + +class Lobby extends Reference: + var peers: Array = [] + var host: int = -1 + var sealed: bool = false + var time = 0 + + func _init(host_id: int): + host = host_id + + func join(peer_id, server) -> bool: + if sealed: return false + if not server.has_peer(peer_id): return false + var new_peer: WebSocketPeer = server.get_peer(peer_id) + new_peer.put_packet(("I: %d\n" % (1 if peer_id == host else peer_id)).to_utf8()) + for p in peers: + if not server.has_peer(p): + continue + server.get_peer(p).put_packet(("N: %d\n" % peer_id).to_utf8()) + new_peer.put_packet(("N: %d\n" % (1 if p == host else p)).to_utf8()) + peers.push_back(peer_id) + return true + + + func leave(peer_id, server) -> bool: + if not peers.has(peer_id): return false + peers.erase(peer_id) + var close = false + if peer_id == host: + # The room host disconnected, will disconnect all peers. + close = true + if sealed: return close + # Notify other peers. + for p in peers: + if not server.has_peer(p): return close + if close: + # Disconnect peers. + server.disconnect_peer(p) + else: + # Notify disconnection. + server.get_peer(p).put_packet(("D: %d\n" % peer_id).to_utf8()) + return close + + + func seal(peer_id, server) -> bool: + # Only host can seal the room. + if host != peer_id: return false + sealed = true + for p in peers: + server.get_peer(p).put_packet("S: \n".to_utf8()) + time = OS.get_ticks_msec() + return true + + +# Taken from godot-demo-projects/2d/physics_tests/test.gd +class Circle2D: + extends Node2D + var center + var radius + var color + + func _draw(): + draw_circle(center, radius, color) + +func _init(): + server.connect("data_received", self, "_on_data") + server.connect("client_connected", self, "_peer_connected") + server.connect("client_disconnected", self, "_peer_disconnected") + + +# ...
Modified: tests/ctags/gdscript-inner-class.gd.tags 39 lines changed, 39 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,39 @@ +# format=tagmanager +ALFNUM�16384�0 +Circle2D�1�0 +Lobby�1�0 +Peer�1�0 +SEAL_TIME�16384�0 +TIMEOUT�16384�0 +_alfnum�16384�0 +_draw�128�()�Circle2D�0 +_init�128�()�0 +_init�128�(host_id: int)�Lobby�0 +_init�128�(peer_id)�Peer�0 +center�16384�Circle2D�0 +close�524288�Lobby.leave�0 +color�16384�Circle2D�0 +host�16384�Lobby�0�int +host_id�524288�Lobby._init�0�int +id�16384�Peer�0 +join�128�(peer_id, server)�Lobby�0�bool +leave�128�(peer_id, server)�Lobby�0�bool +lobbies�16384�0�Dictionary +lobby�16384�Peer�0 +new_peer�524288�Lobby.join�0�WebSocketPeer +peer_id�524288�Lobby.join�0 +peer_id�524288�Lobby.leave�0 +peer_id�524288�Lobby.seal�0 +peer_id�524288�Peer._init�0 +peers�16384�0�Dictionary +peers�16384�Lobby�0�Array +radius�16384�Circle2D�0 +rand�16384�0�RandomNumberGenerator +seal�128�(peer_id, server)�Lobby�0�bool +sealed�16384�Lobby�0�bool +server�16384�0�WebSocketServer +server�524288�Lobby.join�0 +server�524288�Lobby.leave�0 +server�524288�Lobby.seal�0 +time�16384�Lobby�0 +time�16384�Peer�0
Modified: tests/ctags/gdscript-modifiers.gd 28 lines changed, 28 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,28 @@ +# Taken from godot-demo-projects/3d/voxel/world/chunk.gd +func _create_block_collider(block_sub_position): + var collider = CollisionShape.new() + collider.shape = BoxShape.new() + collider.shape.extents = Vector3.ONE / 2 + collider.transform.origin = block_sub_position + Vector3.ONE / 2 + add_child(collider) + +static func calculate_block_uvs(block_id): + # This method only supports square texture sheets. + var row = block_id / TEXTURE_SHEET_WIDTH + var col = block_id % TEXTURE_SHEET_WIDTH + + return [ + TEXTURE_TILE_SIZE * Vector2(col, row), + TEXTURE_TILE_SIZE * Vector2(col, row + 1), + TEXTURE_TILE_SIZE * Vector2(col + 1, row), + TEXTURE_TILE_SIZE * Vector2(col + 1, row + 1), + ] + +func id(a): + return a + +remote func r(b): + return b + +remote static func x(c): + return c
Modified: tests/ctags/gdscript-modifiers.gd.tags 14 lines changed, 14 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,14 @@ +# format=tagmanager +_create_block_collider�128�(block_sub_position)�0 +a�524288�id�0 +b�524288�r�0 +block_id�524288�calculate_block_uvs�0 +block_sub_position�524288�_create_block_collider�0 +c�524288�x�0 +calculate_block_uvs�128�(block_id)�0 +col�524288�calculate_block_uvs�0 +collider�524288�_create_block_collider�0 +id�128�(a)�0 +r�128�(b)�0 +row�524288�calculate_block_uvs�0 +x�128�(c)�0
Modified: tests/ctags/gdscript-no-implicit-class.gd 105 lines changed, 105 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,105 @@ +# Derived from https://docs.godotengine.org/en/latest/tutorials/scripting/gdscript/gdscript... + +# A file is a class but it has no name. The name is given only when +# class_name is used. + +# Inheritance + +extends BaseClass + +# (optional) class definition with a custom icon + +class_name MyClass, "res://path/to/optional/icon.svg" + + +# Signals +signal sig + + +# Member variables + +@export_range(start=0, end=100, step=1) var a = 5 +@export +var s = "Hello" +@onready var arr = [1, 2, 3] +var dict = {"key": "value", 2: 3} +var typed_var: int +@onready +@export_multiline +var\ +inferred_type\ +:=\ +"String" + +# Constants + +const ANSWER = 42 +const THE_NAME:String = "Charly" + +# Enums + +enum {UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALL} +enum Named {THING_1, THING_2, ANOTHER_THING=1} + +# Built-in vector types + +var v2 = Vector2(1, 2) +var v3 = Vector3(1, 2, 3) + + +# Function + +@master +func some_function(param1: Vector3, param2: int) -> int: + var local_var = 5 + + if param1 < local_var: + print(param1) + elif param2 > 5: + print(param2) + elif param2 == 2: + print(20) + elif param2 <= 2: + print((-20 % + + + +3) / 5) + else: + print("Fail!") + + for i in range(20): + print(i) + + while param2 != 0: + param2 -= 1 + + var local_var2 = param1 + 3 + return local_var2 + + +# Functions override functions with the same name on the base/parent class. +# If you still want to call them, use '.' (like 'super' in other languages). +@puppet +func something(p1, p2): + .something(p1, p2) + + +# Inner class + +class Something: + var a = 10 + const _private_var:String = "hi\n\escape" + func foooooooo() -> String: + print(""" + test\ + + test""") + return "" + +# Constructor + +func _init(): + print("Constructed!") + var lv = Something.new() + print(lv.a)
Modified: tests/ctags/gdscript-no-implicit-class.gd.tags 35 lines changed, 35 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,35 @@ +# format=tagmanager +ANOTHER_THING�16384�Named�0 +ANSWER�16384�0 +MyClass�1�0 +Named�2�0 +Something�1�0 +THE_NAME�16384�0�String +THING_1�16384�Named�0 +THING_2�16384�Named�0 +UNIT_ALL�16384�anon_enum_1�0 +UNIT_ENEMY�16384�anon_enum_1�0 +UNIT_NEUTRAL�16384�anon_enum_1�0 +_init�128�()�0 +_private_var�16384�Something�0�String +a�16384�0 +a�16384�Something�0 +anon_enum_1�2�0 +arr�16384�0 +dict�16384�0 +foooooooo�128�()�Something�0�String +inferred_type�16384�0 +local_var�524288�some_function�0 +local_var2�524288�some_function�0 +lv�524288�_init�0 +p1�524288�something�0 +p2�524288�something�0 +param1�524288�some_function�0�Vector3 +param2�524288�some_function�0�int +s�16384�0 +sig�16384�0 +some_function�128�(param1: Vector3, param2: int)�0�int +something�128�(p1, p2)�0 +typed_var�16384�0�int +v2�16384�0 +v3�16384�0
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).