@@ -26,30 +26,30 @@ public static final class Factory
2626 implements PointerFactory <Builder , Reader >,
2727 SetPointerBuilder <Builder , Reader >
2828 {
29- public final Reader fromPointerReader (SegmentReader segment , int pointer , int nestingLimit ) {
30- return new Reader (segment , pointer , nestingLimit );
29+ public final Reader fromPointerReader (SegmentReader segment , CapTableReader capTable , int pointer , int nestingLimit ) {
30+ return new Reader (segment , capTable , pointer , nestingLimit );
3131 }
32- public final Builder fromPointerBuilder (SegmentBuilder segment , int pointer ) {
33- return new Builder (segment , pointer );
32+ public final Builder fromPointerBuilder (SegmentBuilder segment , CapTableBuilder capTable , int pointer ) {
33+ return new Builder (segment , capTable , pointer );
3434 }
35- public final Builder initFromPointerBuilder (SegmentBuilder segment , int pointer , int elementCount ) {
36- Builder result = new Builder (segment , pointer );
35+ public final Builder initFromPointerBuilder (SegmentBuilder segment , CapTableBuilder capTable , int pointer , int elementCount ) {
36+ Builder result = new Builder (segment , capTable , pointer );
3737 result .clear ();
3838 return result ;
3939 }
40- public void setPointerBuilder (SegmentBuilder segment , int pointer , Reader value ) {
40+ public void setPointerBuilder (SegmentBuilder segment , CapTableBuilder capTable , int pointer , Reader value ) {
4141 if (value .isNull ()) {
42- WireHelpers .zeroObject (segment , pointer );
42+ WireHelpers .zeroObject (segment , capTable , pointer );
4343 WireHelpers .zeroPointerAndFars (segment , pointer );
4444 }
4545 else {
46- WireHelpers .copyPointer (segment , pointer , value .segment , value .pointer , value .nestingLimit );
46+ WireHelpers .copyPointer (segment , capTable , pointer , value .segment , value . capTable , value .pointer , value .nestingLimit );
4747 }
4848 }
4949 }
5050 public static final Factory factory = new Factory ();
5151
52- public final static class Reader {
52+ public final static class Reader extends CapTableReader . ReaderContext {
5353 final SegmentReader segment ;
5454 final int pointer ; // offset in words
5555 final int nestingLimit ;
@@ -60,16 +60,29 @@ public Reader(SegmentReader segment, int pointer, int nestingLimit) {
6060 this .nestingLimit = nestingLimit ;
6161 }
6262
63+ public Reader (SegmentReader segment , CapTableReader capTable , int pointer , int nestingLimit ) {
64+ this .segment = segment ;
65+ this .pointer = pointer ;
66+ this .nestingLimit = nestingLimit ;
67+ this .capTable = capTable ;
68+ }
69+
70+ final Reader imbue (CapTableReader capTable ) {
71+ Reader result = new Reader (segment , pointer , nestingLimit );
72+ result .capTable = capTable ;
73+ return result ;
74+ }
75+
6376 public final boolean isNull () {
6477 return WirePointer .isNull (this .segment .buffer .getLong (this .pointer * Constants .BYTES_PER_WORD ));
6578 }
6679
6780 public final <T > T getAs (FromPointerReader <T > factory ) {
68- return factory .fromPointerReader (this .segment , this .pointer , this .nestingLimit );
81+ return factory .fromPointerReader (this .segment , this .capTable , this . pointer , this .nestingLimit );
6982 }
7083 }
7184
72- public static final class Builder {
85+ public static final class Builder extends CapTableBuilder . BuilderContext {
7386 final SegmentBuilder segment ;
7487 final int pointer ;
7588
@@ -78,34 +91,43 @@ public Builder(SegmentBuilder segment, int pointer) {
7891 this .pointer = pointer ;
7992 }
8093
94+ Builder (SegmentBuilder segment , CapTableBuilder capTable , int pointer ) {
95+ this .segment = segment ;
96+ this .pointer = pointer ;
97+ this .capTable = capTable ;
98+ }
99+
100+ final Builder imbue (CapTableBuilder capTable ) {
101+ return new Builder (segment , capTable , pointer );
102+ }
103+
81104 public final boolean isNull () {
82105 return WirePointer .isNull (this .segment .buffer .getLong (this .pointer * Constants .BYTES_PER_WORD ));
83106 }
84107
85108 public final <T > T getAs (FromPointerBuilder <T > factory ) {
86- return factory .fromPointerBuilder (this .segment , this .pointer );
109+ return factory .fromPointerBuilder (this .segment , this .capTable , this . pointer );
87110 }
88111
89112 public final <T > T initAs (FromPointerBuilder <T > factory ) {
90- return factory .initFromPointerBuilder (this .segment , this .pointer , 0 );
113+ return factory .initFromPointerBuilder (this .segment , this .capTable , this . pointer , 0 );
91114 }
92115
93116 public final <T > T initAs (FromPointerBuilder <T > factory , int elementCount ) {
94- return factory .initFromPointerBuilder (this .segment , this .pointer , elementCount );
117+ return factory .initFromPointerBuilder (this .segment , this .capTable , this . pointer , elementCount );
95118 }
96119
97120 public final <T , U > void setAs (SetPointerBuilder <T , U > factory , U reader ) {
98- factory .setPointerBuilder (this .segment , this .pointer , reader );
121+ factory .setPointerBuilder (this .segment , this .capTable , this . pointer , reader );
99122 }
100123
101124 public final Reader asReader () {
102- return new Reader (segment , pointer , java .lang .Integer .MAX_VALUE );
125+ return new Reader (segment , this . capTable , pointer , java .lang .Integer .MAX_VALUE );
103126 }
104127
105128 public final void clear () {
106- WireHelpers .zeroObject (this .segment , this .pointer );
129+ WireHelpers .zeroObject (this .segment , this .capTable , this . pointer );
107130 this .segment .buffer .putLong (this .pointer * 8 , 0L );
108131 }
109132 }
110-
111133}
0 commit comments