Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@ name: main
on: [push, pull_request]

jobs:
check-headers:
name: Check headers
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4

- name: Install pcre2grep
run: sudo apt-get update && sudo apt-get install -y pcre2-utils

- run: |
# macros in public headers must use the global namespace to qualify types
! pcre2grep --buffer-size=1M --recursive --multiline --line-number --include='.*\.h$' \
'#define\s+(?:.*\\\r?\n)*.*?\K(?<!:)\b(Enum|String|StringOffset|Array|ArrayClassID|Math|Math_obj|Void|null|Dynamic|hx::|cpp::)\b' \
include
name: Check public headers

Windows32:
strategy:
fail-fast: false
Expand Down
34 changes: 17 additions & 17 deletions include/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ cpp::VirtualArray Array_obj<ELEM_>::map(MappingFunc inFunc)

#ifdef HXCPP_VISIT_ALLOCS
#define ARRAY_VISIT_FUNC \
void __Visit(hx::VisitContext *__inCtx) { HX_VISIT_MEMBER(mThis); }
void __Visit(::hx::VisitContext *__inCtx) { HX_VISIT_MEMBER(mThis); }
#else
#define ARRAY_VISIT_FUNC
#endif
Expand Down Expand Up @@ -1413,8 +1413,8 @@ namespace hx
{ \
struct _hx_array_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
{ \
Array<ELEM_> mThis; \
_hx_array_##name(Array<ELEM_> inThis) : mThis(inThis) \
::Array<ELEM_> mThis; \
_hx_array_##name(::Array<ELEM_> inThis) : mThis(inThis) \
{ \
HX_OBJ_WB_NEW_MARKED_OBJECT(this); \
} \
Expand All @@ -1423,13 +1423,13 @@ namespace hx
ret mThis->name(args_call); \
} \
void *__GetHandle() const override { return mThis.GetPtr(); } \
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
void __Mark(::hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
ARRAY_VISIT_FUNC \
int __Compare(const ::hx::Object* inRhs) const override \
{ \
auto casted = dynamic_cast<const _hx_array_##name *>(inRhs); \
if (!casted) return 1; \
if (!hx::IsPointerEq(mThis, casted->mThis)) return -1; \
if (!::hx::IsPointerEq(mThis, casted->mThis)) return -1; \
return 0; \
} \
}; \
Expand Down Expand Up @@ -1505,31 +1505,31 @@ template<class ELEM_>
hx::Val Array_obj<ELEM_>::__Field(const String& inString, hx::PropertyAccess inCallProp)
{
#define ARRAY_RUN_FUNC(ret,func,dynamic_arg_list,arg_list) \
Dynamic __run(dynamic_arg_list) \
::Dynamic __run(dynamic_arg_list) \
{ \
ret mThis->__##func(arg_list); return Dynamic(); \
ret mThis->__##func(arg_list); return ::Dynamic(); \
}

#define DEFINE_ARRAY_FUNC(ret,func,array_list,run_func,ARG_C) \
struct Reflective_##func : public hx::Object \
struct Reflective_##func : public ::hx::Object \
{ \
HX_IS_INSTANCE_OF enum { _hx_ClassId = hx::clsIdClosure }; \
HX_IS_INSTANCE_OF enum { _hx_ClassId = ::hx::clsIdClosure }; \
bool __IsFunction() const { return true; } \
Array_obj<ELEM_> *mThis; \
Reflective_##func(Array_obj<ELEM_> *inThis) : mThis(inThis) { } \
String toString() const{ return HX_CSTRING(#func) ; } \
String __ToString() const{ return HX_CSTRING(#func) ; } \
::Array_obj<ELEM_> *mThis; \
Reflective_##func(::Array_obj<ELEM_> *inThis) : mThis(inThis) { } \
::String toString() const{ return HX_CSTRING(#func) ; } \
::String __ToString() const{ return HX_CSTRING(#func) ; } \
int __GetType() const { return vtFunction; } \
void *__GetHandle() const { return mThis; } \
int __ArgCount() const { return ARG_C; } \
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
void __Mark(::hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
ARRAY_VISIT_FUNC \
Dynamic __Run(const Array<Dynamic> &inArgs) \
::Dynamic __Run(const ::Array<::Dynamic> &inArgs) \
{ \
ret mThis->__##func(array_list); return Dynamic(); \
ret mThis->__##func(array_list); return ::Dynamic(); \
} \
run_func \
int __Compare(const hx::Object *inRHS) const \
int __Compare(const ::hx::Object *inRHS) const \
{ \
if (!dynamic_cast<const Reflective_##func *>(inRHS)) return -1; \
return (mThis==inRHS->__GetHandle() ? 0 : -1); \
Expand Down
90 changes: 45 additions & 45 deletions include/Dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>


#define DYNAMIC_COMPARE_OP( op ) \
bool operator op (const String &inRHS) const { return mPtr && ((String)(*this) op inRHS); } \
bool operator op (const ::String &inRHS) const { return mPtr && ((::String)(*this) op inRHS); } \
bool operator op (double inRHS) const { return IsNumeric() && ((double)(*this) op inRHS); } \
bool operator op (cpp::Int64 inRHS) const { return IsNumeric() && ((cpp::Int64)(*this) op inRHS); } \
bool operator op (cpp::UInt64 inRHS) const { return IsNumeric() && ((cpp::Int64)(*this) op inRHS); } \
bool operator op (::cpp::Int64 inRHS) const { return IsNumeric() && ((::cpp::Int64)(*this) op inRHS); } \
bool operator op (::cpp::UInt64 inRHS) const { return IsNumeric() && ((::cpp::Int64)(*this) op inRHS); } \
bool operator op (float inRHS) const { return IsNumeric() && ((double)(*this) op inRHS); } \
bool operator op (int inRHS) const { return IsNumeric() && ((double)(*this) op (double)inRHS); } \
bool operator op (unsigned int inRHS) const { return IsNumeric() && ((double)(*this) op (double)inRHS); } \
Expand Down Expand Up @@ -198,8 +198,8 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>


#define DYNAMIC_COMPARE_OP_ALL( op ) \
bool operator op (const Dynamic &inRHS) const { return mPtr && (Compare(inRHS) op 0); } \
bool operator op (const cpp::Variant &inRHS) const { return *this op Dynamic(inRHS); } \
bool operator op (const ::Dynamic &inRHS) const { return mPtr && (Compare(inRHS) op 0); } \
bool operator op (const ::cpp::Variant &inRHS) const { return *this op ::Dynamic(inRHS); } \
DYNAMIC_COMPARE_OP(op)


Expand Down Expand Up @@ -259,36 +259,36 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>
double operator / (const int &inRHS) const { return (double)(*this) / (double)inRHS; }

#define DYNAMIC_ARITH( op ) \
Dynamic operator op (const cpp::Variant &inRHS) const \
::Dynamic operator op (const ::cpp::Variant &inRHS) const \
{ return mPtr->__GetType()==vtInt && inRHS.isInt() ? \
Dynamic((int)(*this) op (int)inRHS) : \
Dynamic( (double)(*this) op (double)inRHS); } \
Dynamic operator op (const Dynamic &inRHS) const \
::Dynamic((int)(*this) op (int)inRHS) : \
::Dynamic( (double)(*this) op (double)inRHS); } \
::Dynamic operator op (const ::Dynamic &inRHS) const \
{ return mPtr->__GetType()==vtInt && inRHS.mPtr->__GetType()==vtInt ? \
Dynamic((int)(*this) op (int)inRHS) : \
Dynamic( (double)(*this) op (double)inRHS); } \
::Dynamic((int)(*this) op (int)inRHS) : \
::Dynamic( (double)(*this) op (double)inRHS); } \
double operator op (const double &inRHS) const { return (double)(*this) op (double)inRHS; } \
double operator op (const float &inRHS) const { return (double)(*this) op (double)inRHS; } \
Dynamic operator op (const int &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const unsigned int &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const short &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const unsigned short &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const signed char &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const unsigned char &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const char16_t &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const char32_t &inRHS) const \
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const cpp::Int64 &inRHS) const \
{ return Dynamic((double)(*this) op inRHS); } \
Dynamic operator op (const cpp::UInt64 &inRHS) const \
{ return Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const int &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const unsigned int &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const short &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const unsigned short &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const signed char &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const unsigned char &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const char16_t &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const char32_t &inRHS) const \
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const ::cpp::Int64 &inRHS) const \
{ return ::Dynamic((double)(*this) op inRHS); } \
::Dynamic operator op (const ::cpp::UInt64 &inRHS) const \
{ return ::Dynamic((double)(*this) op inRHS); } \

DYNAMIC_ARITH( - )
DYNAMIC_ARITH( * )
Expand Down Expand Up @@ -425,8 +425,8 @@ inline bool Dynamic::IsClass< ::cpp::Int64>() { return mPtr && mPtr->__GetClass(
inline String Dynamic::operator+(const String &s) const { return Cast<String>() + s; }

#define HX_DYNAMIC_OP_ISEQ(T) \
inline bool operator == (const T &inLHS,const Dynamic &inRHS) { return inRHS==inLHS; } \
inline bool operator != (const T &inLHS,const Dynamic &inRHS) { return inRHS!=inLHS; }
inline bool operator == (const T &inLHS,const ::Dynamic &inRHS) { return inRHS==inLHS; } \
inline bool operator != (const T &inLHS,const ::Dynamic &inRHS) { return inRHS!=inLHS; }

HX_DYNAMIC_OP_ISEQ(String)
HX_DYNAMIC_OP_ISEQ(double)
Expand Down Expand Up @@ -466,18 +466,18 @@ COMPARE_DYNAMIC_OP( > )


#define ARITH_DYNAMIC( op ) \
inline double operator op (const cpp::Int64 &inLHS,const Dynamic &inRHS) { return inLHS op (cpp::Int64)inRHS;} \
inline double operator op (const cpp::UInt64 &inLHS,const Dynamic &inRHS) { return inLHS op (cpp::UInt64)inRHS;} \
inline double operator op (const double &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS;} \
inline double operator op (const float &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS;} \
inline double operator op (const int &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned int &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const short &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned short &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const signed char &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned char &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const char16_t &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const char32_t &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const ::cpp::Int64 &inLHS,const ::Dynamic &inRHS) { return inLHS op (::cpp::Int64)inRHS;} \
inline double operator op (const ::cpp::UInt64 &inLHS,const ::Dynamic &inRHS) { return inLHS op (::cpp::UInt64)inRHS;} \
inline double operator op (const double &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
inline double operator op (const float &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
inline double operator op (const int &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned int &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const short &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned short &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const signed char &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const unsigned char &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const char16_t &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
inline double operator op (const char32_t &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \

ARITH_DYNAMIC( - )
ARITH_DYNAMIC( + )
Expand Down
8 changes: 4 additions & 4 deletions include/cpp/CppInt32__.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ namespace cpp
{

#define HX_I32_DEF_FUNC1(Name) \
static inline Dynamic __##Name(const Dynamic &a) { return Name(a); } \
static inline Dynamic Name##_dyn() { return hx::CreateStaticFunction1(#Name,&CppInt32__::__##Name); }
static inline ::Dynamic __##Name(const ::Dynamic &a) { return Name(a); } \
static inline ::Dynamic Name##_dyn() { return ::hx::CreateStaticFunction1(#Name,&CppInt32__::__##Name); }

#define HX_I32_DEF_FUNC2(Name) \
static inline Dynamic __##Name(const Dynamic &a, const Dynamic &b) { return Name(a,b); } \
static inline Dynamic Name##_dyn() { return hx::CreateStaticFunction2(#Name,&CppInt32__::__##Name); }
static inline ::Dynamic __##Name(const ::Dynamic &a, const ::Dynamic &b) { return Name(a,b); } \
static inline ::Dynamic Name##_dyn() { return ::hx::CreateStaticFunction2(#Name,&CppInt32__::__##Name); }

class CppInt32__
{
Expand Down
Loading