mojo.v23proxy: Replace RawBytesTarget hacks with vdl.Targeter
The previous RawBytesTarget{Func,Hack} hacks were meant to
support making and filling a vdl.Target from vom.RawBytes
directly.
This CL makes this mechanism more general-purpose and slightly
less hacky. We introduce a new vdl.Targeter interface with
{Make,Fill}VDLTarget methods, which make and fill a vdl.Target
respectively. These methods are implemented by vom.RawBytes, and
in the future will be implemented by user-defined types via vdl
code generation.
The HackGetRv() method hasn't been removed yet; that will be
removed in a subsequent change.
MultiPart: 2/2
Change-Id: I03294499f67268a05d4a178b4849d6d4e9145279
diff --git a/go/src/v.io/x/mojo/proxy/util/util.go b/go/src/v.io/x/mojo/proxy/util/util.go
index 3b2727b..9ce3bef 100644
--- a/go/src/v.io/x/mojo/proxy/util/util.go
+++ b/go/src/v.io/x/mojo/proxy/util/util.go
@@ -12,7 +12,7 @@
)
type structSplitTarget struct {
- tt *vdl.Type
+ tt *vdl.Type
fields []*vom.RawBytes
vdl.Target
}
@@ -37,8 +37,9 @@
func (ft *structSplitFieldsTarget) StartField(name string) (key, field vdl.Target, _ error) {
_, index := ft.targ.tt.FieldByName(name)
- ft.targ.fields[index] = &vom.RawBytes{}
- return nil, vom.RawBytesTarget(ft.targ.fields[index]), nil
+ rb := new(vom.RawBytes)
+ ft.targ.fields[index] = rb
+ return nil, rb.MakeVDLTarget(), nil
}
func (ft *structSplitFieldsTarget) FinishField(key, field vdl.Target) error {
@@ -63,7 +64,7 @@
if err != nil {
return err
}
- if err := fields[i].ToTarget(t); err != nil {
+ if err := fields[i].FillVDLTarget(t); err != nil {
return err
}
if err := st.FinishField(k, t); err != nil {
@@ -71,4 +72,4 @@
}
}
return targ.FinishFields(st)
-}
\ No newline at end of file
+}