diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..b90b935 --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,12 @@ +name: linters +on: [pull_request] + +jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - run: bundle exec rubocop diff --git a/.rubocop.yml b/.rubocop.yml index e1a2317..110f650 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -9,3 +9,10 @@ require: AllCops: TargetRubyVersion: 3.1.2 NewCops: enable + Exclude: + - vendor/bundle/**/* + - "**/*_spec.rb" + +# It's common to have one-line methods for component helpers +Layout/EmptyLineBetweenDefs: + AllowAdjacentOneLineDefs: true diff --git a/Gemfile b/Gemfile index 48064e4..eac3245 100644 --- a/Gemfile +++ b/Gemfile @@ -6,5 +6,3 @@ path "." do end gemspec path: "./belts" - -gem "rspec" diff --git a/Gemfile.lock b/Gemfile.lock index 000fdcf..4e1325c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -120,7 +120,7 @@ PLATFORMS DEPENDENCIES belts! - rspec + rspec (~> 3.12) rubocop-rspec (~> 2.11) standard (~> 1.12) diff --git a/assimp_bindings/lib/assimp/node.rb b/assimp_bindings/lib/assimp/node.rb index 38e8029..655e5bf 100644 --- a/assimp_bindings/lib/assimp/node.rb +++ b/assimp_bindings/lib/assimp/node.rb @@ -8,7 +8,7 @@ class Node < FFI::Struct mChildren: NodePointer.ptr, mNumMeshes: :uint, mMeshes: :pointer, # TODO - mMetaData: :pointer, # TODO: MetaData.ptr + mMetaData: :pointer # TODO: MetaData.ptr ) end end diff --git a/belts/belts.gemspec b/belts/belts.gemspec index c4d8951..599803b 100644 --- a/belts/belts.gemspec +++ b/belts/belts.gemspec @@ -1,8 +1,8 @@ -VERSION ||= File.read(File.expand_path("../.belts-version", __dir__)).strip +version = File.read(File.expand_path("../.belts-version", __dir__)).strip Gem::Specification.new do |s| s.name = "belts" - s.version = VERSION + s.version = version s.summary = "A data-oriented game engine for Ruby." s.author = "Guilherme Graca" s.homepage = "https://github.com/ggraca/belts" @@ -12,8 +12,9 @@ Gem::Specification.new do |s| s.executable = "belts" s.required_ruby_version = ">= 3.1.2" - s.add_dependency "belts_engine", VERSION + s.add_dependency "belts_engine", version s.add_dependency "thor", "~> 1.2.1" s.add_development_dependency "standard", "~> 1.12" + s.add_development_dependency "rspec", "~> 3.12" s.add_development_dependency "rubocop-rspec", "~> 2.11" end diff --git a/belts_engine/belts_engine.gemspec b/belts_engine/belts_engine.gemspec index 11a364b..8240eb4 100644 --- a/belts_engine/belts_engine.gemspec +++ b/belts_engine/belts_engine.gemspec @@ -1,8 +1,8 @@ -VERSION ||= File.read(File.expand_path("../.belts-version", __dir__)).strip +version = File.read(File.expand_path("../.belts-version", __dir__)).strip Gem::Specification.new do |s| s.name = "belts_engine" - s.version = VERSION + s.version = version s.summary = "The core functionality of the Belts game engine" s.author = "Guilherme Graca" s.homepage = "https://github.com/ggraca/belts" @@ -11,5 +11,5 @@ Gem::Specification.new do |s| s.files = Dir.glob("lib/**/*") s.required_ruby_version = ">= 3.1.2" - s.add_dependency "belts_support", VERSION + s.add_dependency "belts_support", version end diff --git a/belts_engine/lib/belts_assets/config/model_mixin.rb b/belts_engine/lib/belts_assets/config/model_mixin.rb index a97f4bc..85f21d7 100644 --- a/belts_engine/lib/belts_assets/config/model_mixin.rb +++ b/belts_engine/lib/belts_assets/config/model_mixin.rb @@ -10,7 +10,7 @@ def included(base) module ClassMethods def model(key, file) @@models ||= {} - @@models[key] = { file: Dir["assets/#{file}"].first } + @@models[key] = {file: Dir["assets/#{file}"].first} end def models diff --git a/belts_engine/lib/belts_assets/importer.rb b/belts_engine/lib/belts_assets/importer.rb index 22a2838..b74100b 100644 --- a/belts_engine/lib/belts_assets/importer.rb +++ b/belts_engine/lib/belts_assets/importer.rb @@ -9,8 +9,7 @@ def initialize(key, file_path) @scene = Assimp.aiImportFile(file_path, Assimp::Process::Preset::TARGET_REALTIME_MAX_QUALITY | Assimp::Process::CONVERT_TO_LEFT_HANDED | - Assimp::Process::EMBED_TEXTURES - ) + Assimp::Process::EMBED_TEXTURES) @model = Model.new @model.id = @global_id = key @@ -22,7 +21,7 @@ def initialize(key, file_path) private def import_meshes - @scene[:mNumMeshes].times.map do |i| + Array.new(@scene[:mNumMeshes]) do |i| pointer = Assimp::MeshPointer.new(@scene[:mMeshes].to_ptr + i * Assimp::MeshPointer.size) import_mesh(pointer[:mesh], i) end @@ -34,7 +33,7 @@ def import_mesh(mesh_data, index) mesh.name = mesh_data[:mName][:data].to_s mesh.material_id = fetch_material_id(mesh_data[:mMaterialIndex]) - mesh_data[:mNumVertices].times.map do |i| + Array.new(mesh_data[:mNumVertices]) do |i| mesh.positions << Assimp::Vector3D.new(mesh_data[:mVertices].to_ptr + i * Assimp::Vector3D.size).values if !mesh_data[:mNormals].null? @@ -52,7 +51,7 @@ def import_mesh(mesh_data, index) mesh.colors << [1, 0, 0, 1] end - mesh_data[:mNumFaces].times.map do |i| + Array.new(mesh_data[:mNumFaces]) do |i| face = Assimp::Face.new(mesh_data[:mFaces] + i * Assimp::Face.size) mesh.indices << face[:mIndices].to_ptr.read_array_of_uint(face[:mNumIndices]) end @@ -63,7 +62,7 @@ def import_mesh(mesh_data, index) end def import_materials - @scene[:mNumMaterials].times.map do |i| + Array.new(@scene[:mNumMaterials]) do |i| pointer = Assimp::MaterialPointer.new(@scene[:mMaterials].to_ptr + i * Assimp::MaterialPointer.size) import_material(pointer[:material], i) end @@ -113,9 +112,9 @@ def import_nodes(parent_node = nil, cur_node_data = @scene[:mRootNode]) model_node.parent = parent_node local_ids = cur_node_data[:mMeshes].read_array_of_uint(cur_node_data[:mNumMeshes]) - model_node.mesh_ids = local_ids.map {|id| fetch_mesh_id(id) } + model_node.mesh_ids = local_ids.map { |id| fetch_mesh_id(id) } - cur_node_data[:mNumChildren].times.each do |i| + cur_node_data[:mNumChildren].times do |i| pointer = Assimp::NodePointer.new(cur_node_data[:mChildren].to_ptr + i * Assimp::NodePointer.size) child_node_data = pointer[:node] @@ -126,11 +125,11 @@ def import_nodes(parent_node = nil, cur_node_data = @scene[:mRootNode]) end def fetch_mesh_id(local_id) - "#{@global_id}_mesh_#{local_id}".to_sym + :"#{@global_id}_mesh_#{local_id}" end def fetch_material_id(local_id) - "#{@global_id}_material_#{local_id}".to_sym + :"#{@global_id}_material_#{local_id}" end end end diff --git a/belts_engine/lib/belts_assets/mesh.rb b/belts_engine/lib/belts_assets/mesh.rb index a63c913..3b8c9a4 100644 --- a/belts_engine/lib/belts_assets/mesh.rb +++ b/belts_engine/lib/belts_assets/mesh.rb @@ -13,7 +13,7 @@ def initialize end def vertices - @positions.size.times.map do |i| + Array.new(@positions.size) do |i| [*positions[i], *normals[i], *colors[i]] end.flatten end diff --git a/belts_engine/lib/belts_assets/tools/asset_manager/material_manager.rb b/belts_engine/lib/belts_assets/tools/asset_manager/material_manager.rb index c6e89b2..8cbe676 100644 --- a/belts_engine/lib/belts_assets/tools/asset_manager/material_manager.rb +++ b/belts_engine/lib/belts_assets/tools/asset_manager/material_manager.rb @@ -3,7 +3,7 @@ module Tools class AssetManager class MaterialManager < BaseManager def add_material(material) - raise 'Material must have an id' if material.id.nil? + raise "Material must have an id" if material.id.nil? self[material.id] = material end end diff --git a/belts_engine/lib/belts_bgfx/input_manager.rb b/belts_engine/lib/belts_bgfx/input_manager.rb index f8c7841..c51d850 100644 --- a/belts_engine/lib/belts_bgfx/input_manager.rb +++ b/belts_engine/lib/belts_bgfx/input_manager.rb @@ -34,7 +34,7 @@ def parse_events event = SDL::Event.new while SDL.PollEvent(event) != 0 event_type = event[:common][:type] - event_timestamp = event[:common][:timestamp] + _event_timestamp = event[:common][:timestamp] case event_type when SDL::KEYDOWN diff --git a/belts_engine/lib/belts_engine.rb b/belts_engine/lib/belts_engine.rb index 488e4fe..8dc1fd1 100644 --- a/belts_engine/lib/belts_engine.rb +++ b/belts_engine/lib/belts_engine.rb @@ -1,5 +1,5 @@ require "belts_support" -require_relative "./patches" +require_relative "patches" [:vec2, :vec3, :vec4, :quat, :mat4].each do |struct| require_relative "./belts_engine/structs/#{struct}" diff --git a/belts_engine/lib/belts_engine/application.rb b/belts_engine/lib/belts_engine/application.rb index ebc53f1..e28aa0e 100644 --- a/belts_engine/lib/belts_engine/application.rb +++ b/belts_engine/lib/belts_engine/application.rb @@ -1,5 +1,4 @@ module BeltsEngine - # The application ensures all libraries are loaded before starting the game. # It can also handle some pre-processing (e.g. compiling assets) class Application diff --git a/belts_engine/lib/belts_engine/components/camera.rb b/belts_engine/lib/belts_engine/components/camera.rb index 2bd6c68..fadad24 100644 --- a/belts_engine/lib/belts_engine/components/camera.rb +++ b/belts_engine/lib/belts_engine/components/camera.rb @@ -1,6 +1,6 @@ class Camera < BeltsSupport::Component layout( - projection_type: :ulong, + projection_type: :ulong ) class << self diff --git a/belts_engine/lib/belts_engine/components/light.rb b/belts_engine/lib/belts_engine/components/light.rb index c6c7f07..e7fb039 100644 --- a/belts_engine/lib/belts_engine/components/light.rb +++ b/belts_engine/lib/belts_engine/components/light.rb @@ -1,6 +1,6 @@ class Light < BeltsSupport::Component layout( - light_type: :ulong, + light_type: :ulong ) class << self diff --git a/belts_engine/lib/belts_engine/components/position.rb b/belts_engine/lib/belts_engine/components/position.rb index bbedf55..6e5c847 100644 --- a/belts_engine/lib/belts_engine/components/position.rb +++ b/belts_engine/lib/belts_engine/components/position.rb @@ -2,6 +2,6 @@ class Position < BeltsSupport::Component include Vec3::Behaviour def move!(dir) - self.set!(self + dir) + set!(self + dir) end end diff --git a/belts_engine/lib/belts_engine/components/render_data.rb b/belts_engine/lib/belts_engine/components/render_data.rb index 24b19e5..a140518 100644 --- a/belts_engine/lib/belts_engine/components/render_data.rb +++ b/belts_engine/lib/belts_engine/components/render_data.rb @@ -1,6 +1,6 @@ class RenderData < BeltsSupport::Component layout( - model: :ulong, + model: :ulong ) class << self diff --git a/belts_engine/lib/belts_engine/ecs/query.rb b/belts_engine/lib/belts_engine/ecs/query.rb index a608664..e1dd1e4 100644 --- a/belts_engine/lib/belts_engine/ecs/query.rb +++ b/belts_engine/lib/belts_engine/ecs/query.rb @@ -12,7 +12,7 @@ def initialize(flecs_query, flecs_world, filters) name: name, klass: klass, size: klass.size, - index: i + 1, # Component indexes start at 1 + index: i + 1 # Component indexes start at 1 } end end @@ -23,12 +23,12 @@ def each_with_components(&block) components_requested = @components.slice(*params) it = Flecs.ecs_query_iter(@flecs_world, @flecs_query) - while(Flecs.ecs_query_next(it)) + while Flecs.ecs_query_next(it) components = components_requested.values.map do |component| component.merge(pointer: Flecs.ecs_field_w_size(it, component[:size], component[:index])) end - it[:count].times.each do |i| + it[:count].times do |i| fields = {} if entity_requested diff --git a/belts_engine/lib/belts_engine/structs/quat.rb b/belts_engine/lib/belts_engine/structs/quat.rb index ae6a8ca..e31319e 100644 --- a/belts_engine/lib/belts_engine/structs/quat.rb +++ b/belts_engine/lib/belts_engine/structs/quat.rb @@ -6,7 +6,7 @@ def included(base) [:x, :y, :z, :w].each_with_index do |key, index| base.define_method(key) { self[:values][index] } - base.define_method("#{key}=") { |value| self[:values][index] = value } + base.define_method(:"#{key}=") { |value| self[:values][index] = value } end end end diff --git a/belts_engine/lib/belts_engine/structs/vec2.rb b/belts_engine/lib/belts_engine/structs/vec2.rb index 118cba4..b2b9681 100644 --- a/belts_engine/lib/belts_engine/structs/vec2.rb +++ b/belts_engine/lib/belts_engine/structs/vec2.rb @@ -6,7 +6,7 @@ def included(base) [:x, :y].each_with_index do |key, index| base.define_method(key) { self[:values][index] } - base.define_method("#{key}=") { |value| self[:values][index] = value } + base.define_method(:"#{key}=") { |value| self[:values][index] = value } end end end diff --git a/belts_engine/lib/belts_engine/structs/vec3.rb b/belts_engine/lib/belts_engine/structs/vec3.rb index 0bdc30c..b3a0c18 100644 --- a/belts_engine/lib/belts_engine/structs/vec3.rb +++ b/belts_engine/lib/belts_engine/structs/vec3.rb @@ -6,7 +6,7 @@ def included(base) [:x, :y, :z].each_with_index do |key, index| base.define_method(key) { self[:values][index] } - base.define_method("#{key}=") { |value| self[:values][index] = value } + base.define_method(:"#{key}=") { |value| self[:values][index] = value } end end end diff --git a/belts_engine/lib/belts_engine/structs/vec4.rb b/belts_engine/lib/belts_engine/structs/vec4.rb index a4c33fa..6edd7f6 100644 --- a/belts_engine/lib/belts_engine/structs/vec4.rb +++ b/belts_engine/lib/belts_engine/structs/vec4.rb @@ -6,7 +6,7 @@ def included(base) [:x, :y, :z, :w].each_with_index do |key, index| base.define_method(key) { self[:values][index] } - base.define_method("#{key}=") { |value| self[:values][index] = value } + base.define_method(:"#{key}=") { |value| self[:values][index] = value } end end end diff --git a/belts_engine/lib/belts_engine/system.rb b/belts_engine/lib/belts_engine/system.rb index 6be86b4..c53aa15 100644 --- a/belts_engine/lib/belts_engine/system.rb +++ b/belts_engine/lib/belts_engine/system.rb @@ -10,10 +10,12 @@ def initialize(game) end # Runs once before the first update - def start; end + def start + end # Runs once per frame - def update; end + def update + end def progress(ctx = nil) return update if @started @@ -29,19 +31,8 @@ def progress(ctx = nil) def register_tool_shortcuts @game.tools.each do |key, value| - instance_variable_set("@#{key}", value) + instance_variable_set(:"@#{key}", value) end end - - def debug(db = true) - return yield unless db - RubyProf.start - - yield - result = RubyProf.stop - printer = RubyProf::FlatPrinter.new(result) - printer.print(STDOUT) - exit - end end end diff --git a/belts_engine/lib/belts_engine/tools/ecs.rb b/belts_engine/lib/belts_engine/tools/ecs.rb index 3b68610..525869d 100644 --- a/belts_engine/lib/belts_engine/tools/ecs.rb +++ b/belts_engine/lib/belts_engine/tools/ecs.rb @@ -105,7 +105,7 @@ def init_phases on_validate: Flecs.EcsOnValidate, post_update: Flecs.EcsPostUpdate, pre_store: Flecs.EcsPreStore, - on_store: Flecs.EcsOnStore, + on_store: Flecs.EcsOnStore ) end diff --git a/belts_support/belts_support.gemspec b/belts_support/belts_support.gemspec index c3dcd16..5bd3ae0 100644 --- a/belts_support/belts_support.gemspec +++ b/belts_support/belts_support.gemspec @@ -1,8 +1,8 @@ -VERSION ||= File.read(File.expand_path("../.belts-version", __dir__)).strip +version = File.read(File.expand_path("../.belts-version", __dir__)).strip Gem::Specification.new do |s| s.name = "belts_support" - s.version = VERSION + s.version = version s.summary = "Common tools for the Belts game engine" s.author = "Guilherme Graca" s.homepage = "https://github.com/ggraca/belts" diff --git a/belts_support/lib/belts_support/extension.rb b/belts_support/lib/belts_support/extension.rb index fa2ee91..b85ed83 100644 --- a/belts_support/lib/belts_support/extension.rb +++ b/belts_support/lib/belts_support/extension.rb @@ -1,9 +1,11 @@ module BeltsSupport module Extension # Handle application installation (loading libraries, mixins, etc.) - def install; end + def install + end # Handle game initialization (registering tools, loading assets, etc.) - def init(game); end + def init(game) + end end end diff --git a/flecs_bindings/lib/flecs.rb b/flecs_bindings/lib/flecs.rb index 6bfcb3c..a35ea82 100644 --- a/flecs_bindings/lib/flecs.rb +++ b/flecs_bindings/lib/flecs.rb @@ -62,7 +62,7 @@ module Flecs :EcsOnValidate, :EcsPostUpdate, :EcsPreStore, - :EcsOnStore, + :EcsOnStore ].each do |name| attach_variable name, :ecs_entity_t end diff --git a/flecs_bindings/lib/flecs/component_desc.rb b/flecs_bindings/lib/flecs/component_desc.rb index 67d8bf9..98ae99d 100644 --- a/flecs_bindings/lib/flecs/component_desc.rb +++ b/flecs_bindings/lib/flecs/component_desc.rb @@ -3,7 +3,7 @@ class ComponentDesc < FFI::Struct layout( _canary: :int32, entity: :ecs_entity_t, - type: TypeInfo.by_value, + type: TypeInfo.by_value ) end end diff --git a/flecs_bindings/lib/flecs/filter.rb b/flecs_bindings/lib/flecs/filter.rb index ca62cb9..f1c907b 100644 --- a/flecs_bindings/lib/flecs/filter.rb +++ b/flecs_bindings/lib/flecs/filter.rb @@ -15,7 +15,7 @@ class Filter < FFI::Struct entity: :ecs_entity_t, iterable: Iterable.by_value, dtor: :ecs_poly_dtor_t, - world: :ecs_world_tp, + world: :ecs_world_tp ) end end diff --git a/flecs_bindings/lib/flecs/filter_desc.rb b/flecs_bindings/lib/flecs/filter_desc.rb index c99ee59..b35510b 100644 --- a/flecs_bindings/lib/flecs/filter_desc.rb +++ b/flecs_bindings/lib/flecs/filter_desc.rb @@ -9,7 +9,7 @@ class FilterDesc < FFI::Struct instanced: :bool, flags: :ecs_flags32_t, expr: :pointer, - entity: :ecs_entity_t, + entity: :ecs_entity_t ) end end diff --git a/flecs_bindings/lib/flecs/iter.rb b/flecs_bindings/lib/flecs/iter.rb index 150fed6..a41d76a 100644 --- a/flecs_bindings/lib/flecs/iter.rb +++ b/flecs_bindings/lib/flecs/iter.rb @@ -62,7 +62,7 @@ class Iter < FFI::Struct callback: :ecs_iter_action_t, set_var: :ecs_iter_action_t, fini: :ecs_iter_fini_action_t, - chain_it: Iter.by_ref, + chain_it: Iter.by_ref ) end end diff --git a/flecs_bindings/lib/flecs/iter_cache.rb b/flecs_bindings/lib/flecs/iter_cache.rb index 58eb8d3..a423f94 100644 --- a/flecs_bindings/lib/flecs/iter_cache.rb +++ b/flecs_bindings/lib/flecs/iter_cache.rb @@ -3,7 +3,7 @@ class IterCache < FFI::Struct layout( stack_cursor: StackCursor.by_ref, used: :ecs_flags8_t, - allocated: :ecs_flags8_t, + allocated: :ecs_flags8_t ) end end diff --git a/flecs_bindings/lib/flecs/iter_private.rb b/flecs_bindings/lib/flecs/iter_private.rb index 8f37844..395e565 100644 --- a/flecs_bindings/lib/flecs/iter_private.rb +++ b/flecs_bindings/lib/flecs/iter_private.rb @@ -8,14 +8,14 @@ class IterUnion < FFI::Union rule: RuleIter.by_value, snapshot: SnapshotIter.by_value, page: PageIter.by_value, - worker: WorkerIter.by_value, + worker: WorkerIter.by_value ) end layout( iter: IterUnion.by_value, entity_iter: :pointer, - cache: IterCache.by_value, + cache: IterCache.by_value ) end end diff --git a/flecs_bindings/lib/flecs/iterable.rb b/flecs_bindings/lib/flecs/iterable.rb index 034d2bc..ec1ee5b 100644 --- a/flecs_bindings/lib/flecs/iterable.rb +++ b/flecs_bindings/lib/flecs/iterable.rb @@ -1,7 +1,7 @@ module Flecs class Iterable < FFI::Struct layout( - init: :ecs_iter_init_action_t, + init: :ecs_iter_init_action_t ) end end diff --git a/flecs_bindings/lib/flecs/page_iter.rb b/flecs_bindings/lib/flecs/page_iter.rb index 8728b6a..8de2ded 100644 --- a/flecs_bindings/lib/flecs/page_iter.rb +++ b/flecs_bindings/lib/flecs/page_iter.rb @@ -3,7 +3,7 @@ class PageIter < FFI::Struct layout( offset: :int32, limit: :int32, - remaining: :int32, + remaining: :int32 ) end end diff --git a/flecs_bindings/lib/flecs/query_iter.rb b/flecs_bindings/lib/flecs/query_iter.rb index 529fe98..9e68e8c 100644 --- a/flecs_bindings/lib/flecs/query_iter.rb +++ b/flecs_bindings/lib/flecs/query_iter.rb @@ -9,7 +9,7 @@ class QueryIter < FFI::Struct sparse_first: :int32, table_count: :int32, bitset_first: :int32, - skip_count: :int32, + skip_count: :int32 ) end end diff --git a/flecs_bindings/lib/flecs/rule_iter.rb b/flecs_bindings/lib/flecs/rule_iter.rb index 920907c..d010cb9 100644 --- a/flecs_bindings/lib/flecs/rule_iter.rb +++ b/flecs_bindings/lib/flecs/rule_iter.rb @@ -10,7 +10,7 @@ class RuleIter < FFI::Struct source_set: :ecs_flags32_t, op: :int16, - sp: :int16, + sp: :int16 ) end end diff --git a/flecs_bindings/lib/flecs/snapshot_iter.rb b/flecs_bindings/lib/flecs/snapshot_iter.rb index 574fec7..8d772f6 100644 --- a/flecs_bindings/lib/flecs/snapshot_iter.rb +++ b/flecs_bindings/lib/flecs/snapshot_iter.rb @@ -3,7 +3,7 @@ class SnapshotIter < FFI::Struct layout( filter: Filter.by_value, tables: Vec.by_value, - index: :int32, + index: :int32 ) end end diff --git a/flecs_bindings/lib/flecs/stack_cursor.rb b/flecs_bindings/lib/flecs/stack_cursor.rb index b4885ce..5e397c6 100644 --- a/flecs_bindings/lib/flecs/stack_cursor.rb +++ b/flecs_bindings/lib/flecs/stack_cursor.rb @@ -4,7 +4,7 @@ class StackCursor < FFI::Struct prev: StackCursor.by_ref, page: :ecs_stack_page_tp, sp: :int16, - is_free: :bool, + is_free: :bool # owner: :ecs_stack_tp # NOTE: DEBUG ONLY ) end diff --git a/flecs_bindings/lib/flecs/system_desc.rb b/flecs_bindings/lib/flecs/system_desc.rb index d34f22b..27ff1b5 100644 --- a/flecs_bindings/lib/flecs/system_desc.rb +++ b/flecs_bindings/lib/flecs/system_desc.rb @@ -14,7 +14,7 @@ class SystemDesc < FFI::Struct rate: :int32, tick_source: :ecs_entity_t, multi_threaded: :bool, - no_readonly: :bool, + no_readonly: :bool ) end end diff --git a/flecs_bindings/lib/flecs/table_range.rb b/flecs_bindings/lib/flecs/table_range.rb index 17a9d5e..a0719e3 100644 --- a/flecs_bindings/lib/flecs/table_range.rb +++ b/flecs_bindings/lib/flecs/table_range.rb @@ -3,7 +3,7 @@ class TableRange < FFI::Struct layout( table: :ecs_table_tp, offset: :int32, - count: :int32, + count: :int32 ) end end diff --git a/flecs_bindings/lib/flecs/term.rb b/flecs_bindings/lib/flecs/term.rb index 1296e8a..201708b 100644 --- a/flecs_bindings/lib/flecs/term.rb +++ b/flecs_bindings/lib/flecs/term.rb @@ -12,7 +12,7 @@ class Term < FFI::Struct field_index: :int32, idr: :ecs_id_record_tp, flags: :ecs_flags16_t, - move: :bool, + move: :bool ) end end diff --git a/flecs_bindings/lib/flecs/term_id.rb b/flecs_bindings/lib/flecs/term_id.rb index ff5b62b..4eb03d3 100644 --- a/flecs_bindings/lib/flecs/term_id.rb +++ b/flecs_bindings/lib/flecs/term_id.rb @@ -4,7 +4,7 @@ class TermId < FFI::Struct entity: :ecs_entity_t, name: :pointer, trav: :ecs_entity_t, - flags: :ecs_flags32_t, + flags: :ecs_flags32_t ) end end diff --git a/flecs_bindings/lib/flecs/term_iter.rb b/flecs_bindings/lib/flecs/term_iter.rb index 676ce11..7214704 100644 --- a/flecs_bindings/lib/flecs/term_iter.rb +++ b/flecs_bindings/lib/flecs/term_iter.rb @@ -20,7 +20,7 @@ class TermIter < FFI::Struct column: :int32, subject: :ecs_entity_t, size: :ecs_size_t, - ptr: :pointer, + ptr: :pointer ) end end diff --git a/flecs_bindings/lib/flecs/type_info.rb b/flecs_bindings/lib/flecs/type_info.rb index 396f69e..2e7c76c 100644 --- a/flecs_bindings/lib/flecs/type_info.rb +++ b/flecs_bindings/lib/flecs/type_info.rb @@ -5,7 +5,7 @@ class TypeInfo < FFI::Struct alignment: :ecs_size_t, hooks: TypeHooks.by_value, component: :ecs_entity_t, - name: :pointer, + name: :pointer ) end end diff --git a/flecs_bindings/lib/flecs/var.rb b/flecs_bindings/lib/flecs/var.rb index 82ed141..4ce786d 100644 --- a/flecs_bindings/lib/flecs/var.rb +++ b/flecs_bindings/lib/flecs/var.rb @@ -2,7 +2,7 @@ module Flecs class Var < FFI::Struct layout( range: TableRange.by_value, - entity: :ecs_entity_t, + entity: :ecs_entity_t ) end end diff --git a/flecs_bindings/lib/flecs/vec.rb b/flecs_bindings/lib/flecs/vec.rb index c8420c5..3069981 100644 --- a/flecs_bindings/lib/flecs/vec.rb +++ b/flecs_bindings/lib/flecs/vec.rb @@ -3,7 +3,7 @@ class Vec < FFI::Struct layout( array: :pointer, count: :int32, - size: :int32, + size: :int32 ) end end diff --git a/flecs_bindings/lib/flecs/worker_iter.rb b/flecs_bindings/lib/flecs/worker_iter.rb index d8a004c..2e5e365 100644 --- a/flecs_bindings/lib/flecs/worker_iter.rb +++ b/flecs_bindings/lib/flecs/worker_iter.rb @@ -2,7 +2,7 @@ module Flecs class WorkerIter < FFI::Struct layout( index: :int32, - count: :int32, + count: :int32 ) end end diff --git a/flecs_bindings/spec/flecs_spec.rb b/flecs_bindings/spec/flecs_spec.rb index 596c050..43bb5f6 100644 --- a/flecs_bindings/spec/flecs_spec.rb +++ b/flecs_bindings/spec/flecs_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" # TODO: Add macros to the API and use them here instead of the raw low level calls. describe Flecs do @@ -7,7 +7,7 @@ Flecs.ecs_component_init( world, Flecs::ComponentDesc.new.tap do |component| - component[:type][:name] = FFI::MemoryPointer.from_string('Position') + component[:type][:name] = FFI::MemoryPointer.from_string("Position") component[:type][:size] = 8 component[:type][:alignment] = 4 end @@ -17,7 +17,7 @@ velocity = Flecs.ecs_component_init( world, Flecs::ComponentDesc.new.tap do |component| - component[:type][:name] = FFI::MemoryPointer.from_string('Velocity') + component[:type][:name] = FFI::MemoryPointer.from_string("Velocity") component[:type][:size] = 8 component[:type][:alignment] = 4 end @@ -28,11 +28,11 @@ Flecs.ecs_fini(world) end - specify 'world' do + specify "world" do # handled by callbacks end - specify 'entity' do + specify "entity" do id = Flecs.ecs_new_id(world) expect(Flecs.ecs_is_alive(world, id)).to be true Flecs.ecs_delete(world, id) @@ -42,7 +42,7 @@ expect(Flecs.ecs_is_alive(world, id)).to be true end - specify 'component' do + specify "component" do entity = Flecs.ecs_entity_init(world, Flecs::EntityDesc.new) Flecs.ecs_add_id(world, entity, position) expect(Flecs.ecs_has_id(world, entity, position)).to be true @@ -65,7 +65,7 @@ expect(Flecs.ecs_has_id(world, entity, position)).to be false end - specify 'tag' do + specify "tag" do enemy_tag = Flecs.ecs_new_id(world) entity = Flecs.ecs_new_id(world) @@ -76,7 +76,7 @@ expect(Flecs.ecs_has_id(world, entity, enemy_tag)).to be false end - specify 'pair' do + specify "pair" do likes = Flecs.ecs_new_id(world) bob = Flecs.ecs_new_id(world) alice = Flecs.ecs_new_id(world) @@ -95,12 +95,12 @@ expect(Flecs.ecs_has_id(world, alice, likes_bob)).to be true end - specify 'hierarchy' - specify 'instancing' - specify 'type' - specify 'singleton' + specify "hierarchy" + specify "instancing" + specify "type" + specify "singleton" - specify 'filter' do + specify "filter" do entity1 = Flecs.ecs_entity_init(world, Flecs::EntityDesc.new).tap do |entity| Flecs.ecs_add_id(world, entity, position) end @@ -122,10 +122,10 @@ iterated = false it = Flecs.ecs_filter_iter(world, filter) - while(Flecs.ecs_filter_next(it)) + while Flecs.ecs_filter_next(it) iterated = true - entity_ids = it[:count].times.map do |i| + entity_ids = Array.new(it[:count]) do |i| it[:entities][i * 8].read_int end end @@ -136,7 +136,7 @@ Flecs.ecs_filter_fini(filter) end - specify 'query' do + specify "query" do entity1 = Flecs.ecs_entity_init(world, Flecs::EntityDesc.new).tap do |entity| Flecs.ecs_add_id(world, entity, position) end @@ -158,10 +158,10 @@ iterated = false it = Flecs.ecs_query_iter(world, query) - while(Flecs.ecs_query_next(it)) + while Flecs.ecs_query_next(it) iterated = true - entity_ids = it[:count].times.map do |i| + entity_ids = Array.new(it[:count]) do |i| it[:entities][i * 8].read_int end end @@ -172,9 +172,9 @@ Flecs.ecs_query_fini(query) end - specify 'system' do + specify "system" do iterated = false - callback = Proc.new do |ctx| + callback = proc do |ctx| iterated = true end @@ -190,9 +190,9 @@ expect(iterated).to be true end - specify 'pipeline' do + specify "pipeline" do iterated = false - callback = Proc.new do |ctx| + callback = proc do |ctx| iterated = true end @@ -215,6 +215,6 @@ expect(iterated).to be true end - specify 'observer' - specify 'module' + specify "observer" + specify "module" end diff --git a/flecs_bindings/spec/spec_helper.rb b/flecs_bindings/spec/spec_helper.rb index 1c5cf2c..10ec888 100644 --- a/flecs_bindings/spec/spec_helper.rb +++ b/flecs_bindings/spec/spec_helper.rb @@ -1,4 +1,4 @@ -require 'flecs' +require "flecs" RSpec.configure do |config| end