Skip to content

Commit a39667e

Browse files
author
Aidan Lee
committed
Merge branch 'master' into asys_single_loop
2 parents b98fc75 + 1111d9e commit a39667e

70 files changed

Lines changed: 1418 additions & 830 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@ name: main
22
on: [push, pull_request]
33

44
jobs:
5+
check-headers:
6+
name: Check headers
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: checkout
10+
uses: actions/checkout@v4
11+
12+
- name: Install pcre2grep
13+
run: sudo apt-get update && sudo apt-get install -y pcre2-utils
14+
15+
- run: |
16+
# macros in public headers must use the global namespace to qualify types
17+
! pcre2grep --buffer-size=1M --recursive --multiline --line-number --include='.*\.h$' \
18+
'#define\s+(?:.*\\\r?\n)*.*?\K(?<!:)\b(Enum|String|StringOffset|Array|ArrayClassID|Math|Math_obj|Void|null|Dynamic|hx::|cpp::)\b' \
19+
include
20+
name: Check public headers
21+
522
Windows32:
623
strategy:
724
fail-fast: false

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,16 @@ jobs:
221221
run: haxe compile-cpp.hxml -D ${{ env.HXCPP_ARCH_FLAG }} -D no_http
222222
- name: run
223223
run: bin${{ inputs.sep }}cpp${{ inputs.sep }}TestMain-debug
224+
build_tool:
225+
runs-on: ${{ inputs.os }}
226+
name: build tool tests
227+
steps:
228+
- name: checkout
229+
uses: actions/checkout@v4
230+
- name: setup
231+
uses: ./.github/workflows/setup
232+
with:
233+
haxe: ${{ inputs.haxe }}
234+
- name: test c/cxx_standard attributes
235+
working-directory: test/cxx_standard
236+
run: haxelib run hxcpp Build.xml

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ hxcpp.n
2929

3030
.vscode
3131

32+
test/cxx_standard/main
33+
test/cxx_standard/main.hash
34+
test/cxx_standard/main.exe
35+
test/cxx_standard/main.exe.hash
36+
3237
# Created by https://www.toptal.com/developers/gitignore/api/visualstudio
3338
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudio
3439

docs/build_xml/Defines.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ Defines affecting how the code is compiled. These can be on the command line wh
3737
| *HXCPP_CHECK_POINTER* | Add null-pointer checks,even in release mode. |
3838
| *HXCPP_PROFILER* | Add profiler support |
3939
| *HXCPP_TELEMETRY* | Add telemetry support |
40-
| *HXCPP_CPP11* | Use c++11 features and link libraries |
41-
| *HXCPP_CPP17* | Use c++17 features and link libraries |
40+
| *HXCPP_C_STANDARD* | Set default C standard |
41+
| *HXCPP_CXX_STANDARD* | Set default C++ standard |
42+
| *HXCPP_OBJC_STANDARD* | Set default Objective-C standard |
43+
| *HXCPP_OBJCXX_STANDARD* | Set default Objective-C++ standard |
4244
| *exe_link* | Generate executable file (rather than dynamic library on android) |
4345
| *static_link* | Generate static library |
4446
| *dll_link* | Generate dynamic library |

docs/build_xml/Files.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ Files
22
------
33
The files node defines a group of files that all share the same attributes, including relative directory, default compiler flags and dependencies. The node can be used to define a set of header files on which other files can depend, or a set of source files to be compiled and included in a target.
44

5+
```xml
6+
<files id="foo" cxx_standard="14">
7+
<file name="foo.cpp"/>
8+
<file name="bar.c"/>
9+
</files>
10+
```
11+
12+
#### Attributes
13+
14+
+ `c_standard` = Default C standard for the file group
15+
+ `cxx_standard` = Default C++ standard for the file group
16+
+ `objc_standard` = Default Objective-C standard for the file group
17+
+ `objcxx_standard` = Default Objective-C++ standard for the file group
18+
#### Nodes
519
- *depend* - Declare that all files in the group depend on another file or another file group.
620
```xml
721
<depend name="filename" />
@@ -80,13 +94,17 @@ The files node defines a group of files that all share the same attributes, incl
8094

8195
- *file* - Add file to group, with optional attributes
8296
```xml
83-
<file name="filename" tags="tag,tag1" filterout="define" embedName="embed" >
97+
<file name="filename" tags="tag,tag1" filterout="define" embedName="embed" cxx_standard="17">
8498
<depend name="filename1" />
8599
<depend name="filename2" />
86100
</file>
87101
```
88102
+ name = name of file - may be absolute or relative to files.dir
89103
+ tags = optional override of group tags. See [Tags.md](Tags.md).
104+
+ `c_standard` = C standard for the file
105+
+ `cxx_standard` = C++ standard for the file
106+
+ `objc_standard` = Objective-C standard for the file
107+
+ `objcxx_standard` = Objective-C++ standard for the file
90108
+ filterout = allows files to be skipped at compile-time if the named define exists.
91109
This is useful when the define is set sometime after the file list is parsed.
92110
+ depend name = filename of additional dependency

include/Array.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ cpp::VirtualArray Array_obj<ELEM_>::map(MappingFunc inFunc)
13931393

13941394
#ifdef HXCPP_VISIT_ALLOCS
13951395
#define ARRAY_VISIT_FUNC \
1396-
void __Visit(hx::VisitContext *__inCtx) { HX_VISIT_MEMBER(mThis); }
1396+
void __Visit(::hx::VisitContext *__inCtx) { HX_VISIT_MEMBER(mThis); }
13971397
#else
13981398
#define ARRAY_VISIT_FUNC
13991399
#endif
@@ -1428,8 +1428,8 @@ namespace hx
14281428
{ \
14291429
struct _hx_array_##name final : public ::hx::AutoCallable_obj<value(args_list)> \
14301430
{ \
1431-
Array<ELEM_> mThis; \
1432-
_hx_array_##name(Array<ELEM_> inThis) : mThis(inThis) \
1431+
::Array<ELEM_> mThis; \
1432+
_hx_array_##name(::Array<ELEM_> inThis) : mThis(inThis) \
14331433
{ \
14341434
HX_OBJ_WB_NEW_MARKED_OBJECT(this); \
14351435
} \
@@ -1438,13 +1438,13 @@ namespace hx
14381438
ret mThis->name(args_call); \
14391439
} \
14401440
void *__GetHandle() const override { return mThis.GetPtr(); } \
1441-
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
1441+
void __Mark(::hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
14421442
ARRAY_VISIT_FUNC \
14431443
int __Compare(const ::hx::Object* inRhs) const override \
14441444
{ \
14451445
auto casted = dynamic_cast<const _hx_array_##name *>(inRhs); \
14461446
if (!casted) return 1; \
1447-
if (!hx::IsPointerEq(mThis, casted->mThis)) return -1; \
1447+
if (!::hx::IsPointerEq(mThis, casted->mThis)) return -1; \
14481448
return 0; \
14491449
} \
14501450
}; \
@@ -1520,31 +1520,31 @@ template<class ELEM_>
15201520
hx::Val Array_obj<ELEM_>::__Field(const String& inString, hx::PropertyAccess inCallProp)
15211521
{
15221522
#define ARRAY_RUN_FUNC(ret,func,dynamic_arg_list,arg_list) \
1523-
Dynamic __run(dynamic_arg_list) \
1523+
::Dynamic __run(dynamic_arg_list) \
15241524
{ \
1525-
ret mThis->__##func(arg_list); return Dynamic(); \
1525+
ret mThis->__##func(arg_list); return ::Dynamic(); \
15261526
}
15271527

15281528
#define DEFINE_ARRAY_FUNC(ret,func,array_list,run_func,ARG_C) \
1529-
struct Reflective_##func : public hx::Object \
1529+
struct Reflective_##func : public ::hx::Object \
15301530
{ \
1531-
HX_IS_INSTANCE_OF enum { _hx_ClassId = hx::clsIdClosure }; \
1531+
HX_IS_INSTANCE_OF enum { _hx_ClassId = ::hx::clsIdClosure }; \
15321532
bool __IsFunction() const { return true; } \
1533-
Array_obj<ELEM_> *mThis; \
1534-
Reflective_##func(Array_obj<ELEM_> *inThis) : mThis(inThis) { } \
1535-
String toString() const{ return HX_CSTRING(#func) ; } \
1536-
String __ToString() const{ return HX_CSTRING(#func) ; } \
1533+
::Array_obj<ELEM_> *mThis; \
1534+
Reflective_##func(::Array_obj<ELEM_> *inThis) : mThis(inThis) { } \
1535+
::String toString() const{ return HX_CSTRING(#func) ; } \
1536+
::String __ToString() const{ return HX_CSTRING(#func) ; } \
15371537
int __GetType() const { return vtFunction; } \
15381538
void *__GetHandle() const { return mThis; } \
15391539
int __ArgCount() const { return ARG_C; } \
1540-
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
1540+
void __Mark(::hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
15411541
ARRAY_VISIT_FUNC \
1542-
Dynamic __Run(const Array<Dynamic> &inArgs) \
1542+
::Dynamic __Run(const ::Array<::Dynamic> &inArgs) \
15431543
{ \
1544-
ret mThis->__##func(array_list); return Dynamic(); \
1544+
ret mThis->__##func(array_list); return ::Dynamic(); \
15451545
} \
15461546
run_func \
1547-
int __Compare(const hx::Object *inRHS) const \
1547+
int __Compare(const ::hx::Object *inRHS) const \
15481548
{ \
15491549
if (!dynamic_cast<const Reflective_##func *>(inRHS)) return -1; \
15501550
return (mThis==inRHS->__GetHandle() ? 0 : -1); \

include/Dynamic.h

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>
165165

166166

167167
#define DYNAMIC_COMPARE_OP( op ) \
168-
bool operator op (const String &inRHS) const { return mPtr && ((String)(*this) op inRHS); } \
168+
bool operator op (const ::String &inRHS) const { return mPtr && ((::String)(*this) op inRHS); } \
169169
bool operator op (double inRHS) const { return IsNumeric() && ((double)(*this) op inRHS); } \
170-
bool operator op (cpp::Int64 inRHS) const { return IsNumeric() && ((cpp::Int64)(*this) op inRHS); } \
171-
bool operator op (cpp::UInt64 inRHS) const { return IsNumeric() && ((cpp::Int64)(*this) op inRHS); } \
170+
bool operator op (::cpp::Int64 inRHS) const { return IsNumeric() && ((::cpp::Int64)(*this) op inRHS); } \
171+
bool operator op (::cpp::UInt64 inRHS) const { return IsNumeric() && ((::cpp::Int64)(*this) op inRHS); } \
172172
bool operator op (float inRHS) const { return IsNumeric() && ((double)(*this) op inRHS); } \
173173
bool operator op (int inRHS) const { return IsNumeric() && ((double)(*this) op (double)inRHS); } \
174174
bool operator op (unsigned int inRHS) const { return IsNumeric() && ((double)(*this) op (double)inRHS); } \
@@ -198,8 +198,8 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>
198198

199199

200200
#define DYNAMIC_COMPARE_OP_ALL( op ) \
201-
bool operator op (const Dynamic &inRHS) const { return mPtr && (Compare(inRHS) op 0); } \
202-
bool operator op (const cpp::Variant &inRHS) const { return *this op Dynamic(inRHS); } \
201+
bool operator op (const ::Dynamic &inRHS) const { return mPtr && (Compare(inRHS) op 0); } \
202+
bool operator op (const ::cpp::Variant &inRHS) const { return *this op ::Dynamic(inRHS); } \
203203
DYNAMIC_COMPARE_OP(op)
204204

205205

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

261261
#define DYNAMIC_ARITH( op ) \
262-
Dynamic operator op (const cpp::Variant &inRHS) const \
262+
::Dynamic operator op (const ::cpp::Variant &inRHS) const \
263263
{ return mPtr->__GetType()==vtInt && inRHS.isInt() ? \
264-
Dynamic((int)(*this) op (int)inRHS) : \
265-
Dynamic( (double)(*this) op (double)inRHS); } \
266-
Dynamic operator op (const Dynamic &inRHS) const \
264+
::Dynamic((int)(*this) op (int)inRHS) : \
265+
::Dynamic( (double)(*this) op (double)inRHS); } \
266+
::Dynamic operator op (const ::Dynamic &inRHS) const \
267267
{ return mPtr->__GetType()==vtInt && inRHS.mPtr->__GetType()==vtInt ? \
268-
Dynamic((int)(*this) op (int)inRHS) : \
269-
Dynamic( (double)(*this) op (double)inRHS); } \
268+
::Dynamic((int)(*this) op (int)inRHS) : \
269+
::Dynamic( (double)(*this) op (double)inRHS); } \
270270
double operator op (const double &inRHS) const { return (double)(*this) op (double)inRHS; } \
271271
double operator op (const float &inRHS) const { return (double)(*this) op (double)inRHS; } \
272-
Dynamic operator op (const int &inRHS) const \
273-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
274-
Dynamic operator op (const unsigned int &inRHS) const \
275-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
276-
Dynamic operator op (const short &inRHS) const \
277-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
278-
Dynamic operator op (const unsigned short &inRHS) const \
279-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
280-
Dynamic operator op (const signed char &inRHS) const \
281-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
282-
Dynamic operator op (const unsigned char &inRHS) const \
283-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
284-
Dynamic operator op (const char16_t &inRHS) const \
285-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
286-
Dynamic operator op (const char32_t &inRHS) const \
287-
{ return mPtr->__GetType()==vtInt ? Dynamic((int)(*this) op inRHS) : Dynamic((double)(*this) op inRHS); } \
288-
Dynamic operator op (const cpp::Int64 &inRHS) const \
289-
{ return Dynamic((double)(*this) op inRHS); } \
290-
Dynamic operator op (const cpp::UInt64 &inRHS) const \
291-
{ return Dynamic((double)(*this) op inRHS); } \
272+
::Dynamic operator op (const int &inRHS) const \
273+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
274+
::Dynamic operator op (const unsigned int &inRHS) const \
275+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
276+
::Dynamic operator op (const short &inRHS) const \
277+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
278+
::Dynamic operator op (const unsigned short &inRHS) const \
279+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
280+
::Dynamic operator op (const signed char &inRHS) const \
281+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
282+
::Dynamic operator op (const unsigned char &inRHS) const \
283+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
284+
::Dynamic operator op (const char16_t &inRHS) const \
285+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
286+
::Dynamic operator op (const char32_t &inRHS) const \
287+
{ return mPtr->__GetType()==vtInt ? ::Dynamic((int)(*this) op inRHS) : ::Dynamic((double)(*this) op inRHS); } \
288+
::Dynamic operator op (const ::cpp::Int64 &inRHS) const \
289+
{ return ::Dynamic((double)(*this) op inRHS); } \
290+
::Dynamic operator op (const ::cpp::UInt64 &inRHS) const \
291+
{ return ::Dynamic((double)(*this) op inRHS); } \
292292

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

427427
#define HX_DYNAMIC_OP_ISEQ(T) \
428-
inline bool operator == (const T &inLHS,const Dynamic &inRHS) { return inRHS==inLHS; } \
429-
inline bool operator != (const T &inLHS,const Dynamic &inRHS) { return inRHS!=inLHS; }
428+
inline bool operator == (const T &inLHS,const ::Dynamic &inRHS) { return inRHS==inLHS; } \
429+
inline bool operator != (const T &inLHS,const ::Dynamic &inRHS) { return inRHS!=inLHS; }
430430

431431
HX_DYNAMIC_OP_ISEQ(String)
432432
HX_DYNAMIC_OP_ISEQ(double)
@@ -466,18 +466,18 @@ COMPARE_DYNAMIC_OP( > )
466466

467467

468468
#define ARITH_DYNAMIC( op ) \
469-
inline double operator op (const cpp::Int64 &inLHS,const Dynamic &inRHS) { return inLHS op (cpp::Int64)inRHS;} \
470-
inline double operator op (const cpp::UInt64 &inLHS,const Dynamic &inRHS) { return inLHS op (cpp::UInt64)inRHS;} \
471-
inline double operator op (const double &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS;} \
472-
inline double operator op (const float &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS;} \
473-
inline double operator op (const int &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
474-
inline double operator op (const unsigned int &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
475-
inline double operator op (const short &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
476-
inline double operator op (const unsigned short &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
477-
inline double operator op (const signed char &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
478-
inline double operator op (const unsigned char &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
479-
inline double operator op (const char16_t &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
480-
inline double operator op (const char32_t &inLHS,const Dynamic &inRHS) { return inLHS op (double)inRHS; } \
469+
inline double operator op (const ::cpp::Int64 &inLHS,const ::Dynamic &inRHS) { return inLHS op (::cpp::Int64)inRHS;} \
470+
inline double operator op (const ::cpp::UInt64 &inLHS,const ::Dynamic &inRHS) { return inLHS op (::cpp::UInt64)inRHS;} \
471+
inline double operator op (const double &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
472+
inline double operator op (const float &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
473+
inline double operator op (const int &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
474+
inline double operator op (const unsigned int &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
475+
inline double operator op (const short &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
476+
inline double operator op (const unsigned short &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
477+
inline double operator op (const signed char &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
478+
inline double operator op (const unsigned char &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
479+
inline double operator op (const char16_t &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
480+
inline double operator op (const char32_t &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \
481481

482482
ARITH_DYNAMIC( - )
483483
ARITH_DYNAMIC( + )

include/cpp/CppInt32__.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ namespace cpp
77
{
88

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

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

1717
class CppInt32__
1818
{

0 commit comments

Comments
 (0)