File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -325,6 +325,11 @@ Struct::shouldFieldBreakCycle(const std::shared_ptr<Field> &field) const {
325
325
* changed if this struct has the biggest name compared to other structs
326
326
* in cycle that have fields of non-value type.
327
327
*/
328
+ if (baseNode.cycleNodes .empty ()) {
329
+ /* field references containing struct */
330
+ structTypesThatShouldBeReplaced.push_back (
331
+ shared_from_base<Struct>());
332
+ }
328
333
for (const auto &nextCycleNode : baseNode.cycleNodes ) {
329
334
std::vector<std::string> namesInCycle;
330
335
if (hasBiggestName (nextCycleNode, namesInCycle)) {
Original file line number Diff line number Diff line change
1
+ struct node {
2
+ int value ;
3
+ struct node * next ;
4
+ };
5
+
1
6
struct b ;
2
7
struct c ;
3
8
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import scala.scalanative.native._
6
6
@ native.link(" bindgentests" )
7
7
@ native.extern
8
8
object Cycles {
9
+ type struct_node = native.CStruct2 [native.CInt , native.Ptr [Byte ]]
9
10
type struct_b = native.CStruct1 [native.Ptr [native.Ptr [Byte ]]]
10
11
type struct_a = native.CStruct1 [native.Ptr [struct_b]]
11
12
type struct_c = native.CStruct1 [struct_a]
@@ -27,6 +28,15 @@ import Cycles._
27
28
28
29
object CyclesHelpers {
29
30
31
+ implicit class struct_node_ops (val p : native.Ptr [struct_node]) extends AnyVal {
32
+ def value : native.CInt = ! p._1
33
+ def value_= (value : native.CInt ): Unit = ! p._1 = value
34
+ def next : native.Ptr [struct_node] = (! p._2).cast[native.Ptr [struct_node]]
35
+ def next_= (value : native.Ptr [struct_node]): Unit = ! p._2 = value.cast[native.Ptr [Byte ]]
36
+ }
37
+
38
+ def struct_node ()(implicit z : native.Zone ): native.Ptr [struct_node] = native.alloc[struct_node]
39
+
30
40
implicit class struct_a_ops (val p : native.Ptr [struct_a]) extends AnyVal {
31
41
def bb : native.Ptr [struct_b] = ! p._1
32
42
def bb_= (value : native.Ptr [struct_b]): Unit = ! p._1 = value
You can’t perform that action at this time.
0 commit comments