cmd/protoc-gen-go: generate XXX_OneofWrappers instead of XXX_OneofFuncs

The marshaler, unmarshaler, and sizer functions are unused ever since
the underlying implementation was switched to be table-driven.
Change the function to only return the wrapper structs.

This change:
* enables generated protos to drop dependencies on certain proto types
* reduces the size of generated protos
* simplifies the implementation of oneofs in protoc-gen-go

Updates #708

Change-Id: I845c9009bc0236d1b51d34b014dc3e184303c0f2
Reviewed-on: https://go-review.googlesource.com/c/151357
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/internal/impl/message.go b/internal/impl/message.go
index 4d96719..c0b1029 100644
--- a/internal/impl/message.go
+++ b/internal/impl/message.go
@@ -103,18 +103,21 @@
 			continue fieldLoop
 		}
 	}
+	var oneofWrappers []interface{}
 	if fn, ok := reflect.PtrTo(t).MethodByName("XXX_OneofFuncs"); ok {
-		vs := fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[3]
-	oneofLoop:
-		for _, v := range vs.Interface().([]interface{}) {
-			tf := reflect.TypeOf(v).Elem()
-			f := tf.Field(0)
-			for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
-				if len(s) > 0 && strings.Trim(s, "0123456789") == "" {
-					n, _ := strconv.ParseUint(s, 10, 64)
-					oneofFields[pref.FieldNumber(n)] = tf
-					continue oneofLoop
-				}
+		oneofWrappers = fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[3].Interface().([]interface{})
+	}
+	if fn, ok := reflect.PtrTo(t).MethodByName("XXX_OneofWrappers"); ok {
+		oneofWrappers = fn.Func.Call([]reflect.Value{reflect.Zero(fn.Type.In(0))})[0].Interface().([]interface{})
+	}
+	for _, v := range oneofWrappers {
+		tf := reflect.TypeOf(v).Elem()
+		f := tf.Field(0)
+		for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
+			if len(s) > 0 && strings.Trim(s, "0123456789") == "" {
+				n, _ := strconv.ParseUint(s, 10, 64)
+				oneofFields[pref.FieldNumber(n)] = tf
+				break
 			}
 		}
 	}