From c1ab986c4393cce474818075d95fd1629887a298 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 20 Sep 2025 17:06:37 +0100 Subject: [PATCH 1/3] Fix typos in hxcpp pointers guide --- .../content/cookbook/Other/hxcpp-pointers.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/assets/content/cookbook/Other/hxcpp-pointers.md b/assets/content/cookbook/Other/hxcpp-pointers.md index 89bfb0cc..70157edb 100644 --- a/assets/content/cookbook/Other/hxcpp-pointers.md +++ b/assets/content/cookbook/Other/hxcpp-pointers.md @@ -9,7 +9,7 @@ This page covers the differences and use cases of the three main pointer types; As the name says, just bog standard c pointers. e.g. the following haxe function ```haxe -function foo(cpp.RawPointer bar) {} +function foo(bar:cpp.RawPointer) {} ``` will produce the following C++ function @@ -30,7 +30,7 @@ could be externed with the following haxe class and the `foo` variable could be ```haxe extern class Foo { - var cpp.RawPointer bar; + var bar:cpp.RawPointer; } ``` @@ -47,10 +47,10 @@ function myFunc(foo:cpp.RawPointer) { } ``` -They also cannot be used in any situations where Dynamic is expected (explicitely or implicitly). +They also cannot be used in any situations where Dynamic is expected (explicitly or implicitly). ```haxe -Array> // Will generate code which gives C++ compiler errors. +Array> // Will generate code which gives C++ compiler errors. ``` ## cpp.Pointer @@ -58,7 +58,7 @@ Array> // Will generate code which gives C++ compiler errors Similar to the above, but with some key differences. The code they generate does not map directly to pointers, but instead to a special `::cpp::Pointer` struct. ```haxe -function foo(cpp.Pointer p) {} +function foo(p:cpp.Pointer) {} ``` ```cpp @@ -76,7 +76,7 @@ void foo(int* v) {} with this haxe function ```haxe -void foo(v:cpp.Pointer) {} +function foo(v:cpp.Pointer) {} ``` You don't need to use `cpp.RawPointer` here, you can use `cpp.Pointer` and all the convenience it provides. So why would you ever want to use `cpp.RawPointer` if `cpp.Pointer` does everything it does and is compatible with more of haxe's type system. @@ -93,20 +93,19 @@ void foo(bar func) {} you could not use the following haxe function to generate a function pointer to pass into it. -``` -function haxe_foo(cpp.Pointer v) {} +```haxe +function haxe_foo(v:cpp.Pointer) {} function main() { cpp.Callable.fromStaticFunction(haxe_foo); } - ``` That `fromStaticFunction` call will generate a function pointer with the signature of `void(*)(::cpp::Pointer)` which is not compatible with the function pointer `bar`. ## cpp.Star -This is the last pointer types and like `cpp.RawPointer` it generates raw C pointers in the output code, the key difference is that this type does not support array access and will auto de-reference when accessing the underlying data. This means it's ideal for representing pointers to objects. E.g. the following C++ +This is the last pointer type and like `cpp.RawPointer` it generates raw C pointers in the output code, the key difference is that this type does not support array access and will auto de-reference when accessing the underlying data. This means it's ideal for representing pointers to objects. E.g. the following C++ ```c++ struct Bar { From 571d535039e7ffe9d746d7eb30b2ad96e5149a9f Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 20 Sep 2025 17:07:17 +0100 Subject: [PATCH 2/3] Mention ConstStar on cpp pointers page --- assets/content/cookbook/Other/hxcpp-pointers.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/content/cookbook/Other/hxcpp-pointers.md b/assets/content/cookbook/Other/hxcpp-pointers.md index 70157edb..04c6a36a 100644 --- a/assets/content/cookbook/Other/hxcpp-pointers.md +++ b/assets/content/cookbook/Other/hxcpp-pointers.md @@ -2,7 +2,11 @@ # Hxcpp Pointers -This page covers the differences and use cases of the three main pointer types; `cpp.ConstRawPointer` and `cpp.RawPointer`, `cpp.ConstPointer` and `cpp.Pointer`, and `cpp.Star`. +This page covers the differences and use cases of the three main pointer types: + +- `cpp.ConstRawPointer` and `cpp.RawPointer` +- `cpp.ConstPointer` and `cpp.Pointer` +- `cpp.ConstStar` and `cpp.Star`. ## cpp.RawPointer From ccc4140b9e18abffec68939442f0eabc770e9291 Mon Sep 17 00:00:00 2001 From: Tobiasz Laskowski Date: Sat, 20 Sep 2025 17:26:02 +0100 Subject: [PATCH 3/3] Clean up punctuation and wording --- assets/content/cookbook/Other/hxcpp-pointers.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/content/cookbook/Other/hxcpp-pointers.md b/assets/content/cookbook/Other/hxcpp-pointers.md index 04c6a36a..25c90a62 100644 --- a/assets/content/cookbook/Other/hxcpp-pointers.md +++ b/assets/content/cookbook/Other/hxcpp-pointers.md @@ -38,7 +38,7 @@ extern class Foo { } ``` -The downside with these is that its not ergonomic from a haxe pov to represent and consume pointers to objects. +The downside with these is that its not ergonomic in haxe code to represent and consume pointers to objects. ```haxe extern class Foo { @@ -71,7 +71,7 @@ void foo(::cpp::Pointer p) {} This type lives on the stack so does not contribute to GC pressure, it also is compatible with Dynamic, so you can pass `cpp.Pointer` types into dynamic places and use them with generic arguments. This type also contains loads of convenience functions for reinterpreting the pointer, arithmetic, conversions to haxe arrays and vectors, etc, etc. There are also member fields for accessing the `cpp.Pointer` as a `cpp.RawPointer` or `cpp.Star`. -It also retains the array access that `cpp.RawPointer` does. On top of this the `::cpp::Pointer` type has implicit to and from conversions for the underlying pointer, which means you can extern the following function +It also retains the array access that `cpp.RawPointer` supports. On top of this the `::cpp::Pointer` type has implicit to and from conversions for the underlying pointer, which means you can extern the following function ```cpp void foo(int* v) {} @@ -83,7 +83,7 @@ with this haxe function function foo(v:cpp.Pointer) {} ``` -You don't need to use `cpp.RawPointer` here, you can use `cpp.Pointer` and all the convenience it provides. So why would you ever want to use `cpp.RawPointer` if `cpp.Pointer` does everything it does and is compatible with more of haxe's type system. +You don't need to use `cpp.RawPointer` here, you can use `cpp.Pointer` and all the convenience it provides. So why would you ever want to use `cpp.RawPointer` if `cpp.Pointer` does everything it does and is compatible with more of haxe's type system? Function signatures. @@ -109,7 +109,7 @@ That `fromStaticFunction` call will generate a function pointer with the signatu ## cpp.Star -This is the last pointer type and like `cpp.RawPointer` it generates raw C pointers in the output code, the key difference is that this type does not support array access and will auto de-reference when accessing the underlying data. This means it's ideal for representing pointers to objects. E.g. the following C++ +This is the last pointer type and like `cpp.RawPointer` it generates raw C pointers in the output code. The key difference is that this type does not support array access and will auto de-reference when accessing the underlying data. This means it's ideal for representing pointers to objects. E.g. the following C++ ```c++ struct Bar {