mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 08:59:07 +00:00
feat(handle): improve handle macros
This commit is contained in:
parent
5121638c27
commit
595e431d92
3 changed files with 31 additions and 6 deletions
|
|
@ -1,10 +1,12 @@
|
||||||
#ifndef STORM_HANDLE_HPP
|
#ifndef STORM_HANDLE_HPP
|
||||||
#define STORM_HANDLE_HPP
|
#define STORM_HANDLE_HPP
|
||||||
|
|
||||||
#if !defined(DECLARE_HANDLE)
|
#define DECLARE_STORM_HANDLE(name) \
|
||||||
#define DECLARE_HANDLE(name) \
|
struct name##__ { int32_t unused; }; \
|
||||||
struct name##__; \
|
typedef struct name##__* name
|
||||||
|
|
||||||
|
#define DECLARE_STORM_CHILD_HANDLE(name, super) \
|
||||||
|
struct name##__ : public super##__ { int32_t unused; }; \
|
||||||
typedef struct name##__* name
|
typedef struct name##__* name
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
#include "storm/Handle.hpp"
|
#include "storm/Handle.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
DECLARE_HANDLE(HSRGN);
|
DECLARE_STORM_HANDLE(HSRGN);
|
||||||
|
|
||||||
DECLARE_HANDLE(HLOCKEDRGN);
|
DECLARE_STORM_HANDLE(HLOCKEDRGN);
|
||||||
|
|
||||||
struct RECTF {
|
struct RECTF {
|
||||||
float left;
|
float left;
|
||||||
|
|
|
||||||
23
test/Handle.cpp
Normal file
23
test/Handle.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include "storm/Handle.hpp"
|
||||||
|
#include "test/Test.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("DECLARE_STORM_HANDLE", "[handle]") {
|
||||||
|
SECTION("declares handle") {
|
||||||
|
DECLARE_STORM_HANDLE(HTEST);
|
||||||
|
HTEST test;
|
||||||
|
|
||||||
|
SUCCEED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("DECLARE_STORM_CHILD_HANDLE", "[handle]") {
|
||||||
|
SECTION("declares child handle") {
|
||||||
|
DECLARE_STORM_HANDLE(HPARENT);
|
||||||
|
DECLARE_STORM_CHILD_HANDLE(HCHILD, HPARENT);
|
||||||
|
|
||||||
|
HPARENT parent;
|
||||||
|
HCHILD child;
|
||||||
|
|
||||||
|
SUCCEED();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue