-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsystem_gen.nim
176 lines (137 loc) · 4.24 KB
/
system_gen.nim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
#--- SFML/System ---#
#--- SFML/System/Clock ---#
#--- SFML/System/Time ---#
type Time* {.bycopy.} = object
## Represents a time value
microseconds*: int64
proc asSeconds*(time: Time): cfloat {.
cdecl, importc: "sfTime_asSeconds".}
## Return a time value as a number of seconds
##
## *Arguments*:
## - ``time``: Time value
##
## *Returns:* Time in seconds
proc asMilliseconds*(time: Time): int32 {.
cdecl, importc: "sfTime_asMilliseconds".}
## Return a time value as a number of milliseconds
##
## *Arguments*:
## - ``time``: Time value
##
## *Returns:* Time in milliseconds
proc asMicroseconds*(time: Time): int64 {.
cdecl, importc: "sfTime_asMicroseconds".}
## Return a time value as a number of microseconds
##
## *Arguments*:
## - ``time``: Time value
##
## *Returns:* Time in microseconds
proc seconds*(amount: cfloat): Time {.
cdecl, importc: "sfSeconds".}
## Construct a time value from a number of seconds
##
## *Arguments*:
## - ``amount``: Number of seconds
##
## *Returns:* Time value constructed from the amount of seconds
proc milliseconds*(amount: int32): Time {.
cdecl, importc: "sfMilliseconds".}
## Construct a time value from a number of milliseconds
##
## *Arguments*:
## - ``amount``: Number of milliseconds
##
## *Returns:* Time value constructed from the amount of milliseconds
proc microseconds*(amount: int64): Time {.
cdecl, importc: "sfMicroseconds".}
## Construct a time value from a number of microseconds
##
## *Arguments*:
## - ``amount``: Number of microseconds
##
## *Returns:* Time value constructed from the amount of microseconds
#--- SFML/System/Types ---#
type Clock* = ptr object
type Mutex* = ptr object
type Thread* = ptr object
proc newClock*(): Clock {.
cdecl, importc: "sfClock_create".}
## Create a new clock and start it
##
## *Returns:* A new Clock object
proc copy*(clock: Clock): Clock {.
cdecl, importc: "sfClock_copy".}
## Create a new clock by copying an existing one
##
## *Arguments*:
## - ``clock``: Clock to copy
##
## *Returns:* A new Clock object which is a copy of ``clock``
proc destroy*(clock: Clock) {.
cdecl, importc: "sfClock_destroy".}
## Destroy a clock
##
## *Arguments*:
## - ``clock``: Clock to destroy
proc elapsedTime*(clock: Clock): Time {.
cdecl, importc: "sfClock_getElapsedTime".}
## Get the time elapsed in a clock
##
## This function returns the time elapsed since the last call
## to Clock_restart (or the construction of the object if
## Clock_restart has not been called).
##
## *Arguments*:
## - ``clock``: Clock object
##
## *Returns:* Time elapsed
proc restart*(clock: Clock): Time {.
cdecl, importc: "sfClock_restart".}
## Restart a clock
##
## This function puts the time counter back to zero.
## It also returns the time elapsed since the clock was started.
##
## *Arguments*:
## - ``clock``: Clock object
##
## *Returns:* Time elapsed
#--- SFML/System/InputStream ---#
type InputStreamReadFunc* = proc(data: pointer; size: int64; userData: pointer): int64 {.cdecl.}
type InputStreamSeekFunc* = proc(position: int64; userData: pointer): int64 {.cdecl.}
type InputStreamTellFunc* = proc(userData: pointer): int64 {.cdecl.}
type InputStreamGetSizeFunc* = proc(userData: pointer): int64 {.cdecl.}
type InputStream* {.bycopy.} = object
## Set of callbacks that allow users to define custom file streams
read*: InputStreamReadFunc
seek*: InputStreamSeekFunc
tell*: InputStreamTellFunc
getSize*: InputStreamGetSizeFunc
userData*: pointer
#--- SFML/System/Sleep ---#
proc sleep*(duration: Time) {.
cdecl, importc: "sfSleep".}
## Make the current thread sleep for a given duration
##
## Sleep is the best way to block a program or one of its
## threads, as it doesn't consume any CPU power.
##
## *Arguments*:
## - ``duration``: Time to sleep
#--- SFML/System/Vector2 ---#
type Vector2i* {.bycopy.} = object
## 2-component vector of integers
x*: cint
y*: cint
type Vector2f* {.bycopy.} = object
## 2-component vector of floats
x*: cfloat
y*: cfloat
#--- SFML/System/Vector3 ---#
type Vector3f* {.bycopy.} = object
## 3-component vector of floats
x*: cfloat
y*: cfloat
z*: cfloat