Merge pull request #72 from RobLoach/const-functions

Use const functions
This commit is contained in:
Rob Loach
2020-10-25 13:12:23 -04:00
committed by GitHub
27 changed files with 89 additions and 91 deletions

View File

@@ -51,7 +51,7 @@ namespace raylib {
/**
* Check if audio device has been initialized successfully.
*/
inline bool IsReady() {
inline bool IsReady() const {
return ::IsAudioDeviceReady();
}

View File

@@ -72,7 +72,7 @@ namespace raylib {
/**
* Check if any audio stream buffers requires refill
*/
inline bool IsProcessed() {
inline bool IsProcessed() const {
return ::IsAudioStreamProcessed(*this);
}
@@ -103,7 +103,7 @@ namespace raylib {
/**
* Check if audio stream is playing
*/
inline bool IsPlaying() {
inline bool IsPlaying() const {
return ::IsAudioStreamPlaying(*this);
}

View File

@@ -47,15 +47,15 @@ namespace raylib {
return *this;
}
inline bool CheckCollision(::BoundingBox box2) {
inline bool CheckCollision(::BoundingBox box2) const {
return CheckCollisionBoxes(*this, box2);
}
inline bool CheckCollision(::Vector3 center, float radius) {
inline bool CheckCollision(::Vector3 center, float radius) const {
return CheckCollisionBoxSphere(*this, center, radius);
}
inline bool CheckCollision(::Ray ray) {
inline bool CheckCollision(::Ray ray) const {
return CheckCollisionRayBox(ray, *this);
}
};

View File

@@ -60,13 +60,13 @@ namespace raylib {
return *this;
}
inline Matrix GetMatrix() {
inline Matrix GetMatrix() const {
return ::GetCameraMatrix2D(*this);
}
inline Vector2 GetWorldToScreen2D(Vector2 position) {
inline Vector2 GetWorldToScreen2D(Vector2 position) const {
return ::GetWorldToScreen2D(position, *this);
}
inline Vector2 GetScreenToWorld2D(Vector2 position) {
inline Vector2 GetScreenToWorld2D(Vector2 position) const {
return ::GetScreenToWorld2D(position, *this);
}
};

View File

@@ -66,7 +66,7 @@ namespace raylib {
return *this;
}
inline Matrix GetMatrix() {
inline Matrix GetMatrix() const {
return ::GetCameraMatrix(*this);
}
@@ -100,11 +100,11 @@ namespace raylib {
return *this;
}
inline Ray GetMouseRay(::Vector2 mousePosition) {
inline Ray GetMouseRay(::Vector2 mousePosition) const {
return ::GetMouseRay(mousePosition, *this);
}
inline Vector2 GetWorldToScreen(::Vector3 position) {
inline Vector2 GetWorldToScreen(::Vector3 position) const {
return ::GetWorldToScreen(position, *this);
}

View File

@@ -90,23 +90,21 @@ namespace raylib {
static Color Magenta;
static Color RayWhite;
int ToInt() {
int ToInt() const {
return ::ColorToInt(*this);
}
operator int() const { return ::ColorToInt(*this); }
Color Fade(float alpha) {
Color a;
a.set(::Fade(*this, alpha));
return a;
Color Fade(float alpha) const {
return ::Fade(*this, alpha);
}
Vector4 Normalize() {
Vector4 Normalize() const {
return ::ColorNormalize(*this);
}
Vector3 ToHSV() {
Vector3 ToHSV() const {
return ::ColorToHSV(*this);
}

View File

@@ -32,7 +32,7 @@ namespace raylib {
/**
* Check if a file has been dropped into window.
*/
inline bool IsFileDropped() {
inline bool IsFileDropped() const {
return ::IsFileDropped();
}
@@ -52,15 +52,15 @@ namespace raylib {
return at(pos);
}
inline int Count() {
inline int Count() const {
return m_count;
}
inline int size() {
inline int size() const {
return m_count;
}
inline bool empty() {
inline bool empty() const {
return m_count == 0;
}
@@ -68,15 +68,15 @@ namespace raylib {
Clear();
}
inline std::string front() {
inline std::string front() const {
return at(0);
}
inline std::string back() {
inline std::string back() const {
return at(m_count - 1);
}
std::string at(int pos) {
std::string at(int pos) const {
if (m_files != NULL && pos < m_count && pos >= 0) {
return std::string(m_files[pos]);
}

View File

@@ -93,7 +93,7 @@ namespace raylib {
return ::MeasureTextEx(*this, text.c_str(), fontSize, spacing);
}
inline int GetGlyphIndex(int character) {
inline int GetGlyphIndex(int character) const {
return ::GetGlyphIndex(*this, character);
}
};

View File

@@ -34,39 +34,39 @@ namespace raylib {
operator int() const { return number; }
inline bool IsAvailable() {
inline bool IsAvailable() const {
return ::IsGamepadAvailable(number);
}
inline bool IsName(const std::string& name) {
inline bool IsName(const std::string& name) const {
return ::IsGamepadName(number, name.c_str());
}
std::string GetName() {
std::string GetName() const {
return std::string(::GetGamepadName(number));
}
inline bool IsButtonPressed(int button) {
inline bool IsButtonPressed(int button) const {
return ::IsGamepadButtonPressed(number, button);
}
inline bool IsButtonDown(int button) {
inline bool IsButtonDown(int button) const {
return ::IsGamepadButtonDown(number, button);
}
inline bool IsButtonReleased(int button) {
inline bool IsButtonReleased(int button) const {
return ::IsGamepadButtonReleased(number, button);
}
inline bool IsButtonUp(int button) {
inline bool IsButtonUp(int button) const {
return ::IsGamepadButtonUp(number, button);
}
inline int GetButtonPressed() {
inline int GetButtonPressed() const {
return ::GetGamepadButtonPressed();
}
inline int GetAxisCount() {
inline int GetAxisCount() const {
return ::GetGamepadAxisCount(number);
}
inline float GetAxisMovement(int axis) {
inline float GetAxisMovement(int axis) const {
return ::GetGamepadAxisMovement(number, axis);
}
};

View File

@@ -247,7 +247,7 @@ namespace raylib {
return ::GetImagePalette(*this, maxPaletteSize, extractCount);
}
inline Rectangle GetAlphaBorder(float threshold) {
inline Rectangle GetAlphaBorder(float threshold) const {
return ::GetImageAlphaBorder(*this, threshold);
}

View File

@@ -198,7 +198,7 @@ namespace raylib {
return ::MatrixLookAt(eye, target, up);
}
float16 ToFloatV() {
inline float16 ToFloatV() {
return ::MatrixToFloatV(*this);
}
operator float16() {

View File

@@ -68,7 +68,7 @@ namespace raylib {
return *this;
}
inline RayHitInfo GetCollision(::Ray ray) {
inline RayHitInfo GetCollision(::Ray ray) const {
return ::GetCollisionRayModel(ray, *this);
}
@@ -77,7 +77,7 @@ namespace raylib {
return *this;
}
inline bool IsModelAnimationValid(::ModelAnimation anim) {
inline bool IsModelAnimationValid(::ModelAnimation anim) const {
return ::IsModelAnimationValid(*this, anim);
}
};

View File

@@ -54,11 +54,11 @@ namespace raylib {
return *this;
}
inline bool IsValid(::Model model) {
inline bool IsValid(::Model model) const {
return ::IsModelAnimationValid(model, *this);
}
inline bool IsModelAnimationValid(::Model model) {
inline bool IsModelAnimationValid(::Model model) const {
return ::IsModelAnimationValid(model, *this);
}
};

View File

@@ -14,22 +14,22 @@ extern "C"{
namespace raylib {
class Mouse {
public:
inline bool IsButtonPressed(int button) {
inline bool IsButtonPressed(int button) const {
return ::IsMouseButtonPressed(button);
}
inline bool IsButtonDown(int button) {
inline bool IsButtonDown(int button) const {
return ::IsMouseButtonDown(button);
}
inline bool IsButtonReleased(int button) {
inline bool IsButtonReleased(int button) const {
return ::IsMouseButtonReleased(button);
}
inline bool IsButtonUp(int button) {
inline bool IsButtonUp(int button) const {
return ::IsMouseButtonUp(button);
}
inline int GetX() {
inline int GetX() const {
return ::GetMouseX();
}
inline int GetY() {
inline int GetY() const {
return ::GetMouseY();
}
inline Mouse& SetX(int x) {
@@ -40,7 +40,7 @@ namespace raylib {
::SetMouseOffset(GetX(), y);
return *this;
}
inline Vector2 GetPosition() {
inline Vector2 GetPosition() const {
return ::GetMousePosition();
}
inline Mouse& SetPosition(int x, int y) {
@@ -55,16 +55,16 @@ namespace raylib {
::SetMouseScale(scaleX, scaleY);
return *this;
}
inline float GetWheelMove() {
inline float GetWheelMove() const {
return ::GetMouseWheelMove();
}
inline int GetTouchX() {
inline int GetTouchX() const {
return ::GetTouchX();
}
inline int GetTouchY() {
inline int GetTouchY() const {
return ::GetTouchY();
}
inline Vector2 GetTouchPosition(int index) {
inline Vector2 GetTouchPosition(int index) const {
return ::GetTouchPosition(index);
}
};

View File

@@ -75,7 +75,7 @@ namespace raylib {
::ResumeMusicStream(*this);
return *this;
}
inline bool IsPlaying() {
inline bool IsPlaying() const {
return ::IsMusicPlaying(*this);
}
inline Music& SetVolume(float volume) {
@@ -86,10 +86,10 @@ namespace raylib {
::SetMusicPitch(*this, pitch);
return *this;
}
inline float GetTimeLength() {
inline float GetTimeLength() const {
return ::GetMusicTimeLength(*this);
}
inline float GetTimePlayed() {
inline float GetTimePlayed() const {
return ::GetMusicTimePlayed(*this);
}

View File

@@ -77,19 +77,19 @@ namespace raylib {
::PhysicsShatter(body, position, force);
return *this;
}
inline int GetBodiesCount() {
inline int GetBodiesCount() const {
return ::GetPhysicsBodiesCount();
}
inline PhysicsBody GetBody(int index) {
inline PhysicsBody GetBody(int index) const {
return ::GetPhysicsBody(index);
}
inline int GetShapeType(int index) {
inline int GetShapeType(int index) const {
return ::GetPhysicsShapeType(index);
}
inline int GetShapeVerticesCount(int index) {
inline int GetShapeVerticesCount(int index) const {
return ::GetPhysicsShapeVerticesCount(index);
}
inline Vector2 GetShapeVertex(PhysicsBody body, int vertex) {
inline Vector2 GetShapeVertex(PhysicsBody body, int vertex) const {
return ::GetPhysicsShapeVertex(body, vertex);
}
inline Physics& SetBodyRotation(PhysicsBody body, float radians) {

View File

@@ -52,15 +52,15 @@ namespace raylib {
return *this;
}
inline bool CheckCollisionSphere(::Vector3 center, float radius) {
inline bool CheckCollisionSphere(::Vector3 center, float radius) const {
return CheckCollisionRaySphere(*this, center, radius);
}
inline bool CheckCollisionSphereEx(::Vector3 center, float radius, ::Vector3 *collisionPoint) {
inline bool CheckCollisionSphereEx(::Vector3 center, float radius, ::Vector3 *collisionPoint) const {
return CheckCollisionRaySphereEx(*this, center, radius, collisionPoint);
}
inline bool CheckCollisionBox(::BoundingBox box) {
inline bool CheckCollisionBox(::BoundingBox box) const {
return CheckCollisionRayBox(*this, box);
}

View File

@@ -90,15 +90,15 @@ namespace raylib {
return *this;
}
inline bool CheckCollision(::Rectangle rec2) {
inline bool CheckCollision(::Rectangle rec2) const {
return ::CheckCollisionRecs(*this, rec2);
}
inline Rectangle GetCollision(::Rectangle rec2) {
inline Rectangle GetCollision(::Rectangle rec2) const {
return ::GetCollisionRec(*this, rec2);
}
inline bool CheckCollision(::Vector2 point) {
inline bool CheckCollision(::Vector2 point) const {
return ::CheckCollisionPointRec(point, *this);
}
};

View File

@@ -72,7 +72,7 @@ namespace raylib {
return *this;
}
inline int GetLocation(const std::string& uniformName) {
inline int GetLocation(const std::string& uniformName) const {
return ::GetShaderLocation(*this, uniformName.c_str());
}
};

View File

@@ -87,7 +87,7 @@ namespace raylib {
return *this;
}
inline bool IsPlaying() {
inline bool IsPlaying() const {
return ::IsSoundPlaying(*this);
}
inline Sound& SetVolume(float volume) {

View File

@@ -84,7 +84,7 @@ namespace raylib {
return *this;
}
inline Image GetTextureData() {
inline Image GetTextureData() const {
return ::GetTextureData(*this);
}
inline operator raylib::Image() {

View File

@@ -152,7 +152,7 @@ namespace raylib {
return *this;
}
float Length() {
float Length() const {
return Vector2Length(*this);
}

View File

@@ -160,7 +160,7 @@ namespace raylib {
return *this;
}
float Length() {
float Length() const {
return Vector3Length(*this);
}

View File

@@ -89,7 +89,7 @@ namespace raylib {
return QuaternionToMatrix(*this);
}
float Length() {
float Length() const {
return QuaternionLength(*this);
}

View File

@@ -30,7 +30,7 @@ namespace raylib {
Close();
}
inline bool IsReady() {
inline bool IsReady() const {
return ::IsVrSimulatorReady();
}

View File

@@ -66,20 +66,20 @@ namespace raylib {
inline static bool IsReady() {
return ::IsWindowReady();
};
inline bool IsMinimized() {
inline bool IsMinimized() const {
return ::IsWindowMinimized();
}
inline bool IsFocused() {
inline bool IsFocused() const {
return ::IsWindowFocused();
}
inline bool IsResized() {
inline bool IsResized() const {
return ::IsWindowResized();
}
inline bool IsHidden() {
inline bool IsHidden() const {
return ::IsWindowHidden();
}
inline bool IsFullscreen() {
inline bool IsFullscreen() const {
return ::IsWindowFullscreen();
}
inline Window& ToggleFullscreen() {
@@ -118,7 +118,7 @@ namespace raylib {
::SetWindowSize(width, height);
return *this;
}
inline void* GetHandle() {
inline void* GetHandle() const {
return ::GetWindowHandle();
}
@@ -131,27 +131,27 @@ namespace raylib {
return *this;
}
inline int GetScreenWidth() {
inline int GetScreenWidth() const {
return ::GetScreenWidth();
}
inline int GetScreenHeight() {
inline int GetScreenHeight() const {
return ::GetScreenHeight();
}
inline Vector2 GetPosition() {
inline Vector2 GetPosition() const {
return ::GetWindowPosition();
}
inline Vector2 GetScaleDPI() {
inline Vector2 GetScaleDPI() const {
return ::GetWindowScaleDPI();
}
std::string GetMonitorName(int monitor) {
std::string GetMonitorName(int monitor) const {
return std::string(::GetMonitorName(monitor));
}
std::string GetClipboardText() {
std::string GetClipboardText() const {
return std::string(::GetClipboardText());
}
@@ -164,13 +164,13 @@ namespace raylib {
::SetTargetFPS(fps);
return *this;
}
inline int GetFPS() {
inline int GetFPS() const {
return ::GetFPS();
}
inline float GetFrameTime() {
inline float GetFrameTime() const {
return ::GetFrameTime();
}
inline double GetTime() {
inline double GetTime() const {
return ::GetTime();
}
};

View File

@@ -10,7 +10,7 @@
* @param name The machine-readable name of the property.
*/
#define GETTERSETTER(type, method, name) \
inline type Get##method() { return name; } \
inline type Get##method() const { return name; } \
inline void Set##method(type value) { name = value; }
#endif