Skip to content

Commit

Permalink
Update some Get/Set methods
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Mar 10, 2024
1 parent 473b922 commit ac5e553
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 48 deletions.
10 changes: 5 additions & 5 deletions include/AudioStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class AudioStream : public ::AudioStream {
Unload();
}

GETTERSETTER(rAudioBuffer *, Buffer, buffer)
GETTERSETTER(rAudioProcessor *, Processor, processor)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
GETTERSETTER(unsigned int, Channels, channels)
GETTER(rAudioBuffer *, Buffer, buffer)
GETTER(rAudioProcessor *, Processor, processor)
GETTER(unsigned int, SampleRate, sampleRate)
GETTER(unsigned int, SampleSize, sampleSize)
GETTER(unsigned int, Channels, channels)

AudioStream& operator=(const ::AudioStream& stream) {
set(stream);
Expand Down
6 changes: 3 additions & 3 deletions include/AutomationEventList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class AutomationEventList : public ::AutomationEventList {
Unload();
}

GETTERSETTER(unsigned int, Capacity, capacity)
GETTERSETTER(unsigned int, Count, count)
GETTERSETTER(AutomationEvent*, Events, events)
GETTER(unsigned int, Capacity, capacity)
GETTER(unsigned int, Count, count)
GETTER(AutomationEvent*, Events, events)

AutomationEventList& operator=(const ::AutomationEventList& other) {
set(other);
Expand Down
10 changes: 5 additions & 5 deletions include/Font.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ class Font : public ::Font {
}
}

GETTERSETTER(int, BaseSize, baseSize)
GETTERSETTER(int, GlyphCount, glyphCount)
GETTERSETTER(int, GlyphPadding, glyphPadding)
GETTERSETTER(::Rectangle*, Recs, recs)
GETTERSETTER(::GlyphInfo*, Glyphs, glyphs)
GETTER(int, BaseSize, baseSize)
GETTER(int, GlyphCount, glyphCount)
GETTER(int, GlyphPadding, glyphPadding)
GETTER(::Rectangle*, Recs, recs)
GETTER(::GlyphInfo*, Glyphs, glyphs)

/**
* Get the texture atlas containing the glyphs.
Expand Down
28 changes: 23 additions & 5 deletions include/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,11 +316,29 @@ class Image : public ::Image {
}
}

GETTERSETTER(void*, Data, data)
GETTERSETTER(int, Width, width)
GETTERSETTER(int, Height, height)
GETTERSETTER(int, Mipmaps, mipmaps)
GETTERSETTER(int, Format, format)
GETTER(void*, Data, data)
GETTER(int, Width, width)
GETTER(int, Height, height)
GETTER(int, Mipmaps, mipmaps)
GETTER(int, Format, format)

/**
* Set the width of the image canvas.
*
* @see ResizeCanvas
*/
void SetWidth(int width, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
ResizeCanvas(width, height, offsetX, offsetY, fill);
}

/**
* Set the height of the image canvas.
*
* @see ResizeCanvas
*/
void SetHeight(int height, int offsetX = 0, int offsetY = 0, ::Color fill = {255, 255, 255, 255}) {
ResizeCanvas(width, height, offsetX, offsetY, fill);
}

/**
* Retrieve the width and height of the image.
Expand Down
8 changes: 4 additions & 4 deletions include/Music.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ class Music : public ::Music {
Unload();
}

GETTERSETTER(::AudioStream, Stream, stream)
GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTER(::AudioStream, Stream, stream)
GETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(bool, Looping, looping)
GETTERSETTER(int, CtxType, ctxType)
GETTERSETTER(void*, CtxData, ctxData)
GETTER(int, CtxType, ctxType)
GETTER(void*, CtxData, ctxData)

Music& operator=(const ::Music& music) {
set(music);
Expand Down
2 changes: 1 addition & 1 deletion include/RenderTexture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RenderTexture : public ::RenderTexture {
other.depth = {};
}

GETTERSETTER(unsigned int, Id, id)
GETTER(unsigned int, Id, id)

/**
* Get the color buffer attachment texture.
Expand Down
4 changes: 2 additions & 2 deletions include/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ class Shader : public ::Shader {
return ::LoadShaderFromMemory(vsCode, fsCode);
}

GETTERSETTER(unsigned int, Id, id)
GETTERSETTER(int*, Locs, locs)
GETTER(unsigned int, Id, id)
GETTER(int*, Locs, locs)

Shader& operator=(const ::Shader& shader) {
set(shader);
Expand Down
4 changes: 2 additions & 2 deletions include/Sound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Sound : public ::Sound {
Unload();
}

GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(::AudioStream, Stream, stream)
GETTER(unsigned int, FrameCount, frameCount)
GETTER(::AudioStream, Stream, stream)

Sound& operator=(Sound&& other) noexcept {
if (this == &other) {
Expand Down
10 changes: 5 additions & 5 deletions include/TextureUnmanaged.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ class TextureUnmanaged : public ::Texture {
// Nothing.
}

GETTERSETTER(unsigned int, Id, id)
GETTERSETTER(int, Width, width)
GETTERSETTER(int, Height, height)
GETTERSETTER(int, Mipmaps, mipmaps)
GETTERSETTER(int, Format, format)
GETTER(unsigned int, Id, id)
GETTER(int, Width, width)
GETTER(int, Height, height)
GETTER(int, Mipmaps, mipmaps)
GETTER(int, Format, format)

TextureUnmanaged& operator=(const ::Texture& texture) {
set(texture);
Expand Down
10 changes: 5 additions & 5 deletions include/Wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ class Wave : public ::Wave {
Unload();
}

GETTERSETTER(unsigned int, FrameCount, frameCount)
GETTERSETTER(unsigned int, SampleRate, sampleRate)
GETTERSETTER(unsigned int, SampleSize, sampleSize)
GETTERSETTER(unsigned int, Channels, channels)
GETTERSETTER(void *, Data, data)
GETTER(unsigned int, FrameCount, frameCount)
GETTER(unsigned int, SampleRate, sampleRate)
GETTER(unsigned int, SampleSize, sampleSize)
GETTER(unsigned int, Channels, channels)
GETTER(void *, Data, data)

Wave& operator=(const ::Wave& wave) {
set(wave);
Expand Down
21 changes: 10 additions & 11 deletions include/raylib-cpp-utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,31 @@
#ifndef RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_
#define RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_

#ifndef GETTERSETTER
#ifndef GETTER
/**
* A utility to build get and set methods on top of a property.
* A utility to build a get method on top of a property.
*
* @param type The type of the property.
* @param method The human-readable name for the method.
* @param name The machine-readable name of the property.
*/
#define GETTERSETTER(type, method, name) \
#define GETTER(type, method, name) \
/** Retrieves the name value for the object. @return The name value of the object. */ \
type Get##method() const { return name; } \
/** Sets the name value for the object. @param value The value of which to set name to. */ \
void Set##method(type value) { name = value; }
type Get##method() const { return name; }
#endif

#ifndef GETTER
#ifndef GETTERSETTER
/**
* A utility to build get methods on top of a property.
* A utility to build get and set methods on top of a property.
*
* @param type The type of the property.
* @param method The human-readable name for the method.
* @param name The machine-readable name of the property.
*/
#define GETTER(type, method, name) \
/** Retrieves the name value for the object. @return The name value of the object. */ \
type Get##method() const { return name; }
#define GETTERSETTER(type, method, name) \
GETTER(type, method, name) \
/** Sets the name value for the object. @param value The value of which to set name to. */ \
void Set##method(type value) { name = value; }
#endif

#endif // RAYLIB_CPP_INCLUDE_RAYLIB_CPP_UTILS_HPP_

0 comments on commit ac5e553

Please sign in to comment.