Skip to content

Commit 701047a

Browse files
committed
Corrections
1 parent f7556e2 commit 701047a

File tree

6 files changed

+36
-26
lines changed

6 files changed

+36
-26
lines changed

generate/generate.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def subname(name):
146146
if cls and cls in structs:
147147
cls = 'CSFML::'+cls
148148
if cls and cls not in objs[cmodule]:
149-
obj(cls, ('struct' if orcls in structs else 'class')+' '+cls)
149+
obj(cls, ('struct ' if orcls in structs else 'class ')+cls)
150150
sub = subname(name)
151151
suffix = '.value' if name.endswith('Count') else ''
152152
obj(cls, '{name} = CSFML::{nname}::{sub}{suffix}'.format(**locals()))
@@ -177,7 +177,7 @@ def handle_struct(name, items):
177177
if '*' in t:
178178
continue
179179
if name and name not in objs[cmodule]:
180-
obj(name, 'struct '+name)
180+
obj(name, 'struct CSFML::'+name)
181181

182182
obj(name, 'def {}'.format(n))
183183
if 'Vector2' in t:
@@ -239,7 +239,7 @@ def handle_function(main, params):
239239
nfname = 'self.'+nfname.split('_', 1)[1]
240240
cls = ofname.split('_')[0][2:]
241241
if cls and cls not in objs[cmodule]:
242-
obj(cls, ('struct' if cls in structs else 'class')+' '+cls)
242+
obj(cls, ('struct CSFML::' if cls in structs else 'class ')+cls)
243243

244244
nfname = rename_identifier(nfname)
245245
nftype = rename_type(ftype)
@@ -379,6 +379,7 @@ def handle_function(main, params):
379379
if cut and cls in structs and orparams and not orparams[0][0].startswith('const') and '*' in orparams[0][0]:
380380
for p in structs[cls]:
381381
obj(cls, ' self.{0} = cself.{0}'.format(p))
382+
obj(cls, ' self')
382383
obj(cls, 'end', '')
383384

384385

src/graphics.cr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require "./graphics_lib"
2323
module SF
2424
extend self
2525

26-
def color(red, green, blue, alpha=255)
26+
def color(red: Number, green: Number, blue: Number, alpha=255: Number)
2727
Color.new(r: red.to_u8, g: green.to_u8, b: blue.to_u8, a: alpha.to_u8)
2828
end
2929
struct CSFML::Color
@@ -55,10 +55,10 @@ module SF
5555
end
5656
end
5757

58-
def float_rect(left, top, width, height)
58+
def float_rect(left: Number, top: Number, width: Number, height: Number)
5959
FloatRect.new(left: left.to_f32, top: top.to_f32, width: width.to_f32, height: height.to_f32)
6060
end
61-
def int_rect(left, top, width, height)
61+
def int_rect(left: Number, top: Number, width: Number, height: Number)
6262
IntRect.new(left: left.to_i32, top: top.to_i32, width: width.to_i32, height: height.to_i32)
6363
end
6464

@@ -98,15 +98,15 @@ module SF
9898
x, y = offset
9999
translate(x, y)
100100
end
101-
def rotate(angle, center)
101+
def rotate(angle: Number, center)
102102
cx, cy = center
103103
rotate(angle, cx, cy)
104104
end
105105
def scale(factors)
106106
x, y = factors
107107
scale(x, y)
108108
end
109-
def scale(factors, center)
109+
def scale(factors, center: Number)
110110
x, y = factors
111111
cx, cy = center
112112
scale(x, y, cx, cy)
@@ -194,7 +194,7 @@ module SF
194194
end
195195

196196
class CircleShape
197-
def initialize(radius, point_count=30)
197+
def initialize(radius: Number, point_count=30: Int)
198198
initialize()
199199
self.radius = radius
200200
self.point_count = point_count
@@ -217,7 +217,7 @@ module SF
217217
end
218218

219219
class ConvexShape
220-
def initialize(point_count)
220+
def initialize(point_count: Int)
221221
initialize()
222222
self.point_count = point_count
223223
end
@@ -261,7 +261,7 @@ module SF
261261
end
262262

263263
class Text
264-
def initialize(string: String, font: Font, character_size=30)
264+
def initialize(string: String, font: Font, character_size=30: Int)
265265
initialize()
266266
self.string = string
267267
self.font = font
@@ -396,7 +396,7 @@ module SF
396396
@transformable = SF::Transformable.new() unless @transformable
397397
(@transformable || SF::Transformable.new()).position = position
398398
end
399-
def rotation=(angle)
399+
def rotation=(angle: Number)
400400
@transformable = SF::Transformable.new() unless @transformable
401401
(@transformable || SF::Transformable.new()).rotation = angle
402402
end
@@ -428,7 +428,7 @@ module SF
428428
@transformable = SF::Transformable.new() unless @transformable
429429
(@transformable || SF::Transformable.new()).move(offset)
430430
end
431-
def rotate(angle)
431+
def rotate(angle: Number)
432432
@transformable = SF::Transformable.new() unless @transformable
433433
(@transformable || SF::Transformable.new()).rotate(angle)
434434
end

src/graphics_obj.cr

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module SF
4545
# Utility class for manpulating RGBA colors
4646
alias Color = CSFML::Color
4747

48-
struct Color
48+
struct CSFML::Color
4949
# Add two colors
5050
#
5151
# *Arguments*:
@@ -76,7 +76,7 @@ module SF
7676

7777
alias IntRect = CSFML::IntRect
7878

79-
struct FloatRect
79+
struct CSFML::FloatRect
8080
# Check if a point is inside a rectangle's area
8181
#
8282
# *Arguments*:
@@ -114,7 +114,7 @@ module SF
114114

115115
end
116116

117-
struct IntRect
117+
struct CSFML::IntRect
118118
def contains(x: Int32, y: Int32)
119119
cself = self
120120
CSFML.int_rect_contains(pointerof(cself), x, y) != 0
@@ -5030,7 +5030,7 @@ module SF
50305030
# Encapsulate a 3x3 transform matrix
50315031
alias Transform = CSFML::Transform
50325032

5033-
struct Transform
5033+
struct CSFML::Transform
50345034
# Return the 4x4 matrix of a transform
50355035
#
50365036
# This function fills an array of 16 floats with the transform
@@ -5113,6 +5113,7 @@ module SF
51135113
cself = self
51145114
CSFML.transform_combine(pointerof(cself), pother)
51155115
self.matrix = cself.matrix
5116+
self
51165117
end
51175118

51185119
# Combine a transform with a translation
@@ -5128,6 +5129,7 @@ module SF
51285129
cself = self
51295130
CSFML.transform_translate(pointerof(cself), x, y)
51305131
self.matrix = cself.matrix
5132+
self
51315133
end
51325134

51335135
# Combine the current transform with a rotation
@@ -5141,6 +5143,7 @@ module SF
51415143
cself = self
51425144
CSFML.transform_rotate(pointerof(cself), angle)
51435145
self.matrix = cself.matrix
5146+
self
51445147
end
51455148

51465149
# Combine the current transform with a rotation
@@ -5163,6 +5166,7 @@ module SF
51635166
cself = self
51645167
CSFML.transform_rotate_with_center(pointerof(cself), angle, center_x, center_y)
51655168
self.matrix = cself.matrix
5169+
self
51665170
end
51675171

51685172
# Combine the current transform with a scaling
@@ -5178,6 +5182,7 @@ module SF
51785182
cself = self
51795183
CSFML.transform_scale(pointerof(cself), scale_x, scale_y)
51805184
self.matrix = cself.matrix
5185+
self
51815186
end
51825187

51835188
# Combine the current transform with a scaling
@@ -5202,6 +5207,7 @@ module SF
52025207
cself = self
52035208
CSFML.transform_scale_with_center(pointerof(cself), scale_x, scale_y, center_x, center_y)
52045209
self.matrix = cself.matrix
5210+
self
52055211
end
52065212

52075213
end
@@ -5229,7 +5235,7 @@ module SF
52295235
# Define the states used for drawing to a RenderTarget
52305236
alias RenderStates = CSFML::RenderStates
52315237

5232-
struct RenderStates
5238+
struct CSFML::RenderStates
52335239
def texture
52345240
SF::Texture.wrap_ptr(@texture)
52355241
end
@@ -5240,7 +5246,7 @@ module SF
52405246

52415247
alias Vertex = CSFML::Vertex
52425248

5243-
struct Vertex
5249+
struct CSFML::Vertex
52445250
def position
52455251
SF.vector2(@position)
52465252
end

src/system.cr

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,15 @@ module SF
5656
SF.vector2(x - ox, y - oy)
5757
end
5858
def *(other)
59-
ox, oy = other
60-
SF.vector2(x * ox, y * oy)
59+
if other.responds_to? :[]
60+
ox, oy = other
61+
SF.vector2(x * ox, y * oy)
62+
else
63+
SF.vector2(x * other, y * other)
64+
end
6165
end
62-
def /(other)
63-
ox, oy = other
64-
SF.vector2(x / ox, y / oy)
66+
def /(o)
67+
SF.vector2(x / o, y / o)
6568
end
6669
def ==(other)
6770
ox, oy = other

src/system_obj.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module SF
77
# Represents a time value
88
alias Time = CSFML::Time
99

10-
struct Time
10+
struct CSFML::Time
1111
# Return a time value as a number of seconds
1212
#
1313
# *Arguments*:

src/window_obj.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ module SF
984984
# by the display device
985985
alias VideoMode = CSFML::VideoMode
986986

987-
struct VideoMode
987+
struct CSFML::VideoMode
988988
# Get the current desktop video mode
989989
#
990990
# *Returns*: Current desktop video mode

0 commit comments

Comments
 (0)