Skip to content

Commit 0053fa3

Browse files
author
Aidan Lee
committed
Merge branch 'master' into typed-thread
2 parents aac3f9a + 18204ea commit 0053fa3

24 files changed

Lines changed: 978 additions & 125 deletions

.github/workflows/package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ jobs:
135135
uses: ncipollo/release-action@v1
136136
with:
137137
tag: v${{ env.hxcpp_release }}
138-
commit: ${{ github.head_ref }}
138+
commit: ${{ github.ref }}
139139
name: Release ${{ env.hxcpp_release }}
140140
draft: false
141141
prerelease: false
142-
artifacts: ./hxcpp-${{ env.hxcpp_release }}.zip
142+
artifacts: ./hxcpp-${{ env.hxcpp_release }}.zip

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,4 +233,9 @@ jobs:
233233
haxe: ${{ inputs.haxe }}
234234
- name: test c/cxx_standard attributes
235235
working-directory: test/cxx_standard
236-
run: haxelib run hxcpp Build.xml
236+
shell: bash
237+
run: |
238+
for xml in *.xml; do
239+
haxelib run hxcpp $xml
240+
haxelib run hxcpp $xml clean
241+
done

include/Dynamic.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>
168168
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); } \
170170
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); } \
171+
bool operator op (::cpp::UInt64 inRHS) const { return IsNumeric() && ((::cpp::UInt64)(*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); } \
@@ -183,7 +183,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic : public hx::ObjectPtr<hx::Object>
183183
bool operator != (const String &inRHS) const { return !mPtr || ((String)(*this) != inRHS); }
184184
bool operator != (double inRHS) const { return !IsNumeric() || ((double)(*this) != inRHS); }
185185
bool operator != (cpp::Int64 inRHS) const { return !IsNumeric() || ((cpp::Int64)(*this) != inRHS); }
186-
bool operator != (cpp::UInt64 inRHS) const { return !IsNumeric() || ((cpp::Int64)(*this) != inRHS); }
186+
bool operator != (cpp::UInt64 inRHS) const { return !IsNumeric() || ((cpp::UInt64)(*this) != inRHS); }
187187
bool operator != (float inRHS) const { return !IsNumeric() || ((double)(*this) != inRHS); }
188188
bool operator != (int inRHS) const { return !IsNumeric() || ((double)(*this) != (double)inRHS); }
189189
bool operator != (unsigned int inRHS) const { return !IsNumeric() || ((double)(*this) != (double)inRHS); }
@@ -381,9 +381,9 @@ inline int Dynamic::Cast<int>() const { return mPtr ? mPtr->__ToInt() : 0; }
381381
template<>
382382
inline bool Dynamic::Cast<bool>() const { return mPtr ? mPtr->__ToInt() : 0; }
383383
template<>
384-
inline double Dynamic::Cast<double>() const { return mPtr ? mPtr->__ToDouble() : 0; }
384+
inline double Dynamic::Cast<double>() const { return mPtr ? mPtr->__ToDouble() : 0.0; }
385385
template<>
386-
inline float Dynamic::Cast<float>() const { return mPtr ? mPtr->__ToDouble() : 0; }
386+
inline float Dynamic::Cast<float>() const { return (float)(mPtr ? mPtr->__ToDouble() : 0.0f); }
387387
template<>
388388
inline String Dynamic::Cast<String>() const { return mPtr ? mPtr->toString() : String(null()); }
389389

@@ -466,8 +466,8 @@ 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;} \
469+
inline double operator op (const ::cpp::Int64 &inLHS,const ::Dynamic &inRHS) { return (double)( inLHS op (::cpp::Int64)inRHS );} \
470+
inline double operator op (const ::cpp::UInt64 &inLHS,const ::Dynamic &inRHS) { return (double)( inLHS op (::cpp::UInt64)inRHS );} \
471471
inline double operator op (const double &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
472472
inline double operator op (const float &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS;} \
473473
inline double operator op (const int &inLHS,const ::Dynamic &inRHS) { return inLHS op (double)inRHS; } \

include/cpp/Variant.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace cpp
102102
inline operator double() const { return asDouble(); }
103103
inline operator int() const { return asInt(); }
104104
inline operator bool() const { return asInt(); }
105-
inline operator float () const { return asDouble(); }
105+
inline operator float () const { return (float)asDouble(); }
106106
inline operator unsigned int () const { return asInt(); }
107107
inline operator short () const { return asInt(); }
108108
inline operator unsigned short () const { return asInt(); }
@@ -345,7 +345,7 @@ namespace cpp
345345

346346
switch(type)
347347
{
348-
case typeDouble: return valDouble;
348+
case typeDouble: return (int)valDouble;
349349
case typeInt64: return (int)valInt64;
350350
case typeBool: return valBool;
351351
case typeObject: return valObject ? valObject->__ToInt() : 0;
@@ -363,7 +363,7 @@ namespace cpp
363363

364364
switch(type)
365365
{
366-
case typeDouble: return valDouble;
366+
case typeDouble: return (cpp::Int64)valDouble;
367367
case typeInt: return valInt;
368368
case typeBool: return valBool;
369369
case typeObject: return valObject ? valObject->__ToInt64() : 0;
@@ -381,7 +381,7 @@ namespace cpp
381381
else if (type==typeBool)
382382
return valBool ? 1.0 : 0.0;
383383
else if (type==typeInt64)
384-
return valInt64;
384+
return (double)valInt64;
385385
else if (type==typeObject)
386386
return valObject ? valObject->__ToDouble() : 0.0;
387387
return 0.0;

include/cpp/marshal/Marshal.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ inline void cpp::marshal::Marshal::writeLittleEndianUInt32(const View<uint8_t>&
414414
inline void cpp::marshal::Marshal::writeLittleEndianUInt64(const View<uint8_t>& view, const uint64_t& value)
415415
{
416416
#ifdef HXCPP_BIG_ENDIAN
417-
writeUInt16(view, reverse(value));
417+
writeUInt64(view, reverse(value));
418418
#else
419-
writeUInt16(view, value);
419+
writeUInt64(view, value);
420420
#endif
421421
}
422422

@@ -496,9 +496,9 @@ inline void cpp::marshal::Marshal::writeBigEndianUInt32(const View<uint8_t>& vie
496496
inline void cpp::marshal::Marshal::writeBigEndianUInt64(const View<uint8_t>& view, const uint64_t& value)
497497
{
498498
#ifndef HXCPP_BIG_ENDIAN
499-
writeUInt16(view, reverse(value));
499+
writeUInt64(view, reverse(value));
500500
#else
501-
writeUInt16(view, value);
501+
writeUInt64(view, value);
502502
#endif
503503
}
504504

include/hx/GC.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ namespace hx
329329

330330

331331

332-
class StackContext;
332+
struct StackContext;
333333

334334
EXTERN_FAST_TLS_DATA(StackContext, tlsStackContext);
335335

@@ -360,7 +360,7 @@ class ImmixAllocator
360360

361361

362362

363-
// These allocate the function using the garbage-colleced malloc
363+
// These allocate the function using the garbage-collected malloc
364364
inline static void *alloc(ImmixAllocator *alloc, size_t inSize, bool inContainer, const char *inName )
365365
{
366366
#ifdef HXCPP_GC_NURSERY
@@ -406,7 +406,7 @@ class ImmixAllocator
406406
// Ensure odd alignment in 8 bytes
407407
start += 4 - (start & 4);
408408
#endif
409-
int end = start + sizeof(int) + inSize;
409+
int end = start + (int)(sizeof(int) + inSize);
410410

411411
if ( end <= alloc->spaceEnd )
412412
{
@@ -420,11 +420,11 @@ class ImmixAllocator
420420

421421
if (inContainer)
422422
*buffer++ = (( (end+(IMMIX_LINE_LEN-1))>>IMMIX_LINE_BITS) -startRow) |
423-
(inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
423+
((int)inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
424424
hx::gMarkIDWithContainer;
425425
else
426426
*buffer++ = (( (end+(IMMIX_LINE_LEN-1))>>IMMIX_LINE_BITS) -startRow) |
427-
(inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
427+
((int)inSize<<IMMIX_ALLOC_SIZE_SHIFT) |
428428
hx::gMarkID;
429429

430430
#if defined(HXCPP_GC_CHECK_POINTER) && defined(HXCPP_GC_DEBUG_ALWAYS_MOVE)
@@ -439,7 +439,7 @@ class ImmixAllocator
439439
}
440440

441441
// Fall back to external method
442-
void *result = alloc->CallAlloc(inSize, inContainer ? IMMIX_ALLOC_IS_CONTAINER : 0);
442+
void *result = alloc->CallAlloc((int)inSize, inContainer ? IMMIX_ALLOC_IS_CONTAINER : 0);
443443

444444
#ifdef HXCPP_TELEMETRY
445445
__hxt_gc_new((hx::StackContext *)alloc,result, inSize, inName);

include/hx/LessThanEq.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ struct CompareTraits<double>
103103
{
104104
enum { type = (int)CompareAsDouble };
105105

106-
inline static int toInt(double inValue) { return inValue; }
106+
inline static int toInt(double inValue) { return (int)inValue; }
107107
inline static double toDouble(double inValue) { return inValue; }
108-
inline static cpp::Int64 toInt64(double inValue) { return inValue; }
108+
inline static cpp::Int64 toInt64(double inValue) { return (cpp::Int64)inValue; }
109109
inline static String toString(double inValue) { return String(); }
110110
inline static hx::Object *toObject(double inValue) { return 0; }
111111

@@ -122,7 +122,7 @@ struct CompareTraits<cpp::Int64>
122122
enum { type = (int)CompareAsInt64 };
123123

124124
inline static int toInt(cpp::Int64 inValue) { return (int)inValue; }
125-
inline static double toDouble(cpp::Int64 inValue) { return inValue; }
125+
inline static double toDouble(cpp::Int64 inValue) { return (double)inValue; }
126126
inline static cpp::Int64 toInt64(cpp::Int64 inValue) { return inValue; }
127127
inline static String toString(cpp::Int64 inValue) { return String(); }
128128
inline static hx::Object *toObject(cpp::Int64 inValue) { return 0; }
@@ -137,7 +137,7 @@ struct CompareTraits<cpp::UInt64>
137137
enum { type = (int)CompareAsInt64 };
138138

139139
inline static int toInt(cpp::UInt64 inValue) { return (int)inValue; }
140-
inline static double toDouble(cpp::UInt64 inValue) { return inValue; }
140+
inline static double toDouble(cpp::UInt64 inValue) { return (double)inValue; }
141141
// Return value is unsigned ...
142142
inline static cpp::UInt64 toInt64(cpp::UInt64 inValue) { return inValue; }
143143
inline static String toString(cpp::UInt64 inValue) { return String(); }

include/hx/Object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ HXCPP_EXTERN_CLASS_ATTRIBUTES null BadCast();
4242
// CPPIA_CALL = fastcall on x86(32), nothing otherwise
4343
#if (defined(_WIN32) && !defined(_M_X64) && !defined(__x86_64__) && !defined(_ARM_) ) || \
4444
defined(HXCPP_X86) || defined(__i386__) || defined(__i386) || \
45-
(!defined(_WIN32) && !defined(_ARM_) && !defined(__arm__) && !defined(__x86_64__) )
45+
(!defined(_WIN32) && !defined(_ARM_) && !defined(__arm__) && !defined(__aarch64__) && !defined(__x86_64__) )
4646

4747
#if defined(__GNUC__) && !defined(__APPLE__) && !defined(EMSCRIPTEN)
4848
#define CPPIA_CALL __attribute__ ((fastcall))

include/hx/Operators.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ template<> inline double ToDouble(double inValue) { return inValue; }
8282
template<> inline double ToDouble(int inValue) { return inValue; }
8383
template<> inline double ToDouble(bool inValue) { return inValue; }
8484
template<> inline double ToDouble(float inValue) { return inValue; }
85-
template<> inline double ToDouble(cpp::UInt64 inValue) { return inValue; }
86-
template<> inline double ToDouble(cpp::Int64 inValue) { return inValue; }
85+
template<> inline double ToDouble(cpp::UInt64 inValue) { return (double)inValue; }
86+
template<> inline double ToDouble(cpp::Int64 inValue) { return (double)inValue; }
8787
template<> inline double ToDouble(null inValue) { return 0; }
8888

8989

@@ -261,7 +261,7 @@ template<> inline float TCastObject<float>(hx::Object *inObj)
261261
{
262262
if (!inObj || (inObj->__GetType()!=::vtFloat && inObj->__GetType()!=::vtInt64 && inObj->__GetType()!=::vtInt))
263263
return hx::BadCast();
264-
return inObj->__ToDouble();
264+
return (float)inObj->__ToDouble();
265265
}
266266

267267
template<> inline String TCastObject<String>(hx::Object *inObj)

include/hxString.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES String
331331

332332
inline int cca(int inPos) const
333333
{
334-
if ((unsigned)inPos>=length) return 0;
334+
if ( (inPos>=length) || (inPos<0) ) return 0;
335335
#ifdef HX_SMART_STRINGS
336336
if (isUTF16Encoded())
337337
return __w[inPos];

0 commit comments

Comments
 (0)