Skip to content

Commit

Permalink
Generate sources (1024f20)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robot committed Dec 7, 2016
1 parent 07c2377 commit 089da93
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 42 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ crystal snakes.cr

#### Make CrSFML available to your project

Create a symbolic link to *CrSFML* in your project's *libs* folder.
Create a symbolic link to *CrSFML* in your project's *lib* folder.

```bash
cd ~/my-project
mkdir libs
ln -s /full/path/to/crsfml/src libs/crsfml
mkdir lib
ln -s /full/path/to/crsfml/src lib/crsfml

# Try importing it:
echo 'require "crsfml"' >> my_project.cr
Expand Down
File renamed without changes.
7 changes: 6 additions & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: crsfml
version: 2.4.2
version: 2.4.3

authors:
- Oleh Prypin <oleh@pryp.in>
Expand All @@ -8,3 +8,8 @@ description: |
Crystal bindings to SFML multimedia/game library
license: zlib

crystal: 0.20.1

libraries:
SFML: 2.4.1
2 changes: 1 addition & 1 deletion src/audio/obj.cr
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ module SF
# Sound is playing
Playing
end
_sf_enum SoundSource::Status
Util.extract SoundSource::Status
# Destructor
def finalize()
VoidCSFML.soundsource_finalize(to_unsafe)
Expand Down
20 changes: 12 additions & 8 deletions src/common.cr
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
require "./sizes"

module SF
VERSION = "2.4.2"
SFML_VERSION = "2.4.0"
VERSION = "2.4.3"
SFML_VERSION = "2.4.1"

# Raised in shorthand class methods if initialization or resource loading fails
class InitError < Exception
end

private module Util
# Copy all constants from the namespace into the current namespace
macro extract(from)
{% for c in from.resolve.constants %}
# :nodoc:
{{c}} = {{from}}::{{c}}{% if c.id.ends_with? "Count" %}.value{% end %}
{% end %}
end
end
end

# :nodoc:
macro _sf_enum(from)
{% for c in from.resolve.constants %}
# :nodoc:
{{c}} = {{from}}::{{c}}{% if c.id.ends_with? "Count" %}.value{% end %}
{% end %}
end
4 changes: 2 additions & 2 deletions src/graphics/graphics.cr
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ module SF
# Forwards calls like `shader.param(arg1, arg2)` to
# `shader.set_parameter("param", arg1, arg2)`
macro method_missing(call)
set_parameter {{call.name.stringify}}, {{call.args.argify}}
set_parameter {{call.name.stringify}}, {{call.args.splat}}
end
end

Expand Down Expand Up @@ -281,5 +281,5 @@ module SF
# Overwrite dest with source
BlendNone = BlendMode.new(BlendMode::One, BlendMode::Zero)
end
_sf_enum BlendMode
Util.extract BlendMode
end
12 changes: 6 additions & 6 deletions src/graphics/obj.cr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module SF
# (1, 1, 1, 1) - (dst.a, dst.a, dst.a, dst.a)
OneMinusDstAlpha
end
_sf_enum BlendMode::Factor
Util.extract BlendMode::Factor
# Enumeration of the blending equations
#
# The equations are mapped directly to their OpenGL equivalents,
Expand All @@ -94,7 +94,7 @@ module SF
# Pixel = Dst * DstFactor - Src * SrcFactor
ReverseSubtract
end
_sf_enum BlendMode::Equation
Util.extract BlendMode::Equation
# Default constructor
#
# Constructs a blending mode that does alpha blending.
Expand Down Expand Up @@ -1542,7 +1542,7 @@ module SF
# *Deprecated:* Use TriangleFan instead
TrianglesFan = TriangleFan
end
_sf_enum PrimitiveType
Util.extract PrimitiveType
# Define a set of one or more 2D primitives
#
# `SF::VertexArray` is a very simple wrapper around a dynamic
Expand Down Expand Up @@ -3050,7 +3050,7 @@ module SF
# Texture coordinates in range `0.0 .. size`
Pixels
end
_sf_enum Texture::CoordinateType
Util.extract Texture::CoordinateType
# Default constructor
#
# Creates an empty texture.
Expand Down Expand Up @@ -5489,7 +5489,7 @@ module SF
# Fragment (pixel) shader
Fragment
end
_sf_enum Shader::Type
Util.extract Shader::Type
# Default constructor
#
# This constructor creates an invalid shader.
Expand Down Expand Up @@ -6262,7 +6262,7 @@ module SF
# Strike through characters
StrikeThrough = 1 << 3
end
_sf_enum Text::Style
Util.extract Text::Style
# Default constructor
#
# Creates an empty text.
Expand Down
20 changes: 11 additions & 9 deletions src/network/obj.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module SF
# An unexpected error happened
Error
end
_sf_enum Socket::Status
Util.extract Socket::Status
# Special value that tells the system to pick any available port
AnyPort = 0
# Destructor
Expand Down Expand Up @@ -87,7 +87,7 @@ module SF
# UDP protocol
Udp
end
_sf_enum Socket::Type
Util.extract Socket::Type
# Default constructor
#
# This constructor can only be accessed by derived classes.
Expand Down Expand Up @@ -436,7 +436,7 @@ module SF
# Text mode using EBCDIC encoding
Ebcdic
end
_sf_enum Ftp::TransferMode
Util.extract Ftp::TransferMode
# Define a FTP response
class Response
@_ftp_response : VoidCSFML::Ftp_Response_Buffer
Expand Down Expand Up @@ -529,7 +529,7 @@ module SF
# Not part of the FTP standard, generated by SFML when a local file cannot be read or written
InvalidFile = 1003
end
_sf_enum Ftp::Response::Status
Util.extract Ftp::Response::Status
# Default constructor
#
# This constructor is used by the FTP client to build
Expand Down Expand Up @@ -1257,7 +1257,7 @@ module SF
# Request in delete mode, useful for a REST API
Delete
end
_sf_enum Http::Request::Method
Util.extract Http::Request::Method
# Default constructor
#
# This constructor creates a GET request, with the root
Expand Down Expand Up @@ -1392,7 +1392,7 @@ module SF
# Connection with server failed
ConnectionFailed = 1001
end
_sf_enum Http::Response::Status
Util.extract Http::Response::Status
# Default constructor
#
# Constructs an empty response.
Expand Down Expand Up @@ -2239,9 +2239,11 @@ module SF
end
# Unbind the socket from the local port to which it is bound
#
# The port that the socket was previously using is immediately
# available after this function is called. If the
# socket is not bound to a port, this function has no effect.
# The port that the socket was previously bound to is immediately
# made available to the operating system after this function is called.
# This means that a subsequent call to bind() will be able to re-bind
# the port if no other process has done so in the mean time.
# If the socket is not bound to a port, this function has no effect.
#
# *See also:* `bind`
def unbind()
Expand Down
2 changes: 1 addition & 1 deletion src/sizes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ lib VoidCSFML
alias MemoryInputStream_Buffer = UInt8[24]
alias Thread_Buffer = UInt8[16]
alias ThreadLocal_Buffer = UInt8[8]
alias Context_Buffer = UInt8[8]
alias GlResource_Buffer = UInt8[1]
alias ContextSettings_Buffer = UInt8[28]
alias Context_Buffer = UInt8[8]
alias Joystick_Buffer = UInt8[1]
alias Joystick_Identification_Buffer = UInt8[40]
alias Keyboard_Buffer = UInt8[1]
Expand Down
16 changes: 7 additions & 9 deletions src/window/obj.cr
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module SF
# Debug attribute
Debug = 1 << 2
end
_sf_enum ContextSettings::Attribute
Util.extract ContextSettings::Attribute
# Default constructor
#
# * *depth* - Depth buffer bits
Expand Down Expand Up @@ -359,7 +359,7 @@ module SF
# The Y axis of the point-of-view hat
PovY
end
_sf_enum Joystick::Axis
Util.extract Joystick::Axis
# Structure holding a joystick's identification
class Identification
@_joystick_identification : VoidCSFML::Joystick_Identification_Buffer
Expand Down Expand Up @@ -723,7 +723,7 @@ module SF
# Keep last -- the total number of keyboard keys
KeyCount
end
_sf_enum Keyboard::Key
Util.extract Keyboard::Key
# Check if a key is pressed
#
# * *key* - Key to check
Expand Down Expand Up @@ -800,15 +800,15 @@ module SF
# Keep last -- the total number of mouse buttons
ButtonCount
end
_sf_enum Mouse::Button
Util.extract Mouse::Button
# Mouse wheels
enum Wheel
# The vertical mouse wheel
VerticalWheel
# The horizontal mouse wheel
HorizontalWheel
end
_sf_enum Mouse::Wheel
Util.extract Mouse::Wheel
# Check if a mouse button is pressed
#
# * *button* - Button to check
Expand Down Expand Up @@ -924,7 +924,7 @@ module SF
# Keep last -- the total number of sensor types
Count
end
_sf_enum Sensor::Type
Util.extract Sensor::Type
# Check if a sensor is available on the underlying platform
#
# * *sensor* - Sensor to check
Expand Down Expand Up @@ -2299,9 +2299,7 @@ module SF
# If set, grabs the mouse cursor inside this window's client
# area so it may no longer be moved outside its bounds.
# Note that grabbing is only active while the window has
# focus and calling this function for fullscreen windows
# won't have any effect (fullscreen windows always grab the
# cursor).
# focus.
#
# * *grabbed* - True to enable, false to disable
def mouse_cursor_grabbed=(grabbed : Bool)
Expand Down
5 changes: 3 additions & 2 deletions voidcsfml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,16 @@ if(SFML_OS_WINDOWS)
endif()
endif()

list(APPEND CMAKE_MODULE_PATH "/usr/share/SFML/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "/usr/local/share/SFML/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "/usr/local/opt/sfml/share/SFML/cmake/Modules") # Homebrew

find_package(SFML 2.4
COMPONENTS system window graphics audio network REQUIRED
)
if(NOT "2.4.0" STREQUAL "${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH}")
if(NOT "2.4.1" STREQUAL "${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH}")
message(WARNING
"Expecting SFML 2.4.0, "
"Expecting SFML 2.4.1, "
"found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH}"
)
endif()
Expand Down

0 comments on commit 089da93

Please sign in to comment.