From 40c85f535551663083ed233cb4c27019fb812d54 Mon Sep 17 00:00:00 2001 From: AutisticLulu Date: Thu, 13 Aug 2026 15:36:05 +0200 Subject: [PATCH 1/3] [cppia] Fix reported field type for booleans CppiaVar::linkVarTypes has two forms. The static form asks fieldStorageFromType, which answers fsBool for Bool. The member form switches on exprType instead, and TypeData::link has already mapped Bool onto etInt by the time it runs, so the field is laid out as fsInt and reads back through reflection as 1 rather than true. The member form now asks fieldStorageFromType as well. The slot stays the size of an int, leaving the layout and the AlignOffset call above it unchanged. --- src/hx/cppia/CppiaVars.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hx/cppia/CppiaVars.cpp b/src/hx/cppia/CppiaVars.cpp index 0aecb4792..62e56ef9e 100644 --- a/src/hx/cppia/CppiaVars.cpp +++ b/src/hx/cppia/CppiaVars.cpp @@ -179,13 +179,15 @@ void CppiaVar::linkVarTypes(CppiaModule &cppia, int &ioOffset) exprType = typeId==0 ? etObject : type->expressionType; AlignOffset(exprType, ioOffset); offset = ioOffset; - + + storeType = typeId==0 ? fsObject : fieldStorageFromType(type); + switch(exprType) { - case etInt: ioOffset += sizeof(int); storeType=fsInt; break; - case etFloat: ioOffset += sizeof(Float);storeType=fsFloat; break; - case etString: ioOffset += sizeof(String);storeType=fsString; break; - case etObject: ioOffset += sizeof(hx::Object *);storeType=fsObject; break; + case etInt: ioOffset += sizeof(int); break; + case etFloat: ioOffset += sizeof(Float); break; + case etString: ioOffset += sizeof(String); break; + case etObject: ioOffset += sizeof(hx::Object *); break; case etVoid: case etNull: break; From 6d9b9b869ace9bfa5705f4a051c2171fb7f8134c Mon Sep 17 00:00:00 2001 From: AutisticLulu Date: Tue, 18 Aug 2026 22:17:31 +0200 Subject: [PATCH 2/3] [cppia] Use sTypeSize for the member offset Every storage fieldStorageFromType returns maps onto an exprType with the same size, so the switch collapses to a table lookup and the offsets stay byte-identical. --- src/hx/cppia/CppiaVars.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/hx/cppia/CppiaVars.cpp b/src/hx/cppia/CppiaVars.cpp index 62e56ef9e..aea9eb863 100644 --- a/src/hx/cppia/CppiaVars.cpp +++ b/src/hx/cppia/CppiaVars.cpp @@ -181,17 +181,7 @@ void CppiaVar::linkVarTypes(CppiaModule &cppia, int &ioOffset) offset = ioOffset; storeType = typeId==0 ? fsObject : fieldStorageFromType(type); - - switch(exprType) - { - case etInt: ioOffset += sizeof(int); break; - case etFloat: ioOffset += sizeof(Float); break; - case etString: ioOffset += sizeof(String); break; - case etObject: ioOffset += sizeof(hx::Object *); break; - case etVoid: - case etNull: - break; - } + ioOffset += sTypeSize[exprType]; } } From eebb510dcec89e55cb24a3f01b815e17aca2ae6b Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Wed, 4 Nov 2026 11:25:13 +0000 Subject: [PATCH 3/3] [tests] Check cppia client bool fields --- test/cppia/cases/client/TestClient.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/cppia/cases/client/TestClient.hx b/test/cppia/cases/client/TestClient.hx index b44f0bae7..946c5220c 100644 --- a/test/cppia/cases/client/TestClient.hx +++ b/test/cppia/cases/client/TestClient.hx @@ -6,6 +6,8 @@ class TestClient extends Test { public static var clientBool2 = true; public static var clientBool3 = false; + var memberBool = true; + function testThread() { // See if it compiles Assert.notNull(sys.thread.Thread.current()); @@ -55,6 +57,9 @@ class TestClient extends Test { var hostBools = HostBase.hostBool0 + "/" + HostBase.hostBool1 + "/" + HostBase.hostBool2 + "/" + HostBase.hostBool3; var clientBools = clientBool0 + "/" + clientBool1 + "/" + clientBool2 + "/" + clientBool3; Assert.equals(hostBools, clientBools); + + Assert.same(Type.ValueType.TBool, Type.typeof(clientBool0)); + Assert.same(Type.ValueType.TBool, Type.typeof(memberBool)); } function testIssue926() {