@@ -93,7 +93,12 @@ func NewConverter(nameFn NameFunc) *Converter {
93
93
inputFieldMappingFuncs : make (map [reflect.Type ]FieldMappingFunc ),
94
94
inputDefaultFlags : make (map [reflect.Type ]FieldMatchingFlags ),
95
95
}
96
- c .RegisterConversionFunc (Convert_Slice_byte_To_Slice_byte )
96
+ c .RegisterUntypedConversionFunc (
97
+ (* []byte )(nil ), (* []byte )(nil ),
98
+ func (a , b interface {}, s Scope ) error {
99
+ return Convert_Slice_byte_To_Slice_byte (a .(* []byte ), b .(* []byte ), s )
100
+ },
101
+ )
97
102
return c
98
103
}
99
104
@@ -159,25 +164,11 @@ func NewConversionFuncs() ConversionFuncs {
159
164
}
160
165
161
166
type ConversionFuncs struct {
167
+ // FIXME: Remove.
162
168
fns map [typePair ]reflect.Value
163
169
untyped map [typePair ]ConversionFunc
164
170
}
165
171
166
- // Add adds the provided conversion functions to the lookup table - they must have the signature
167
- // `func(type1, type2, Scope) error`. Functions are added in the order passed and will override
168
- // previously registered pairs.
169
- func (c ConversionFuncs ) Add (fns ... interface {}) error {
170
- for _ , fn := range fns {
171
- fv := reflect .ValueOf (fn )
172
- ft := fv .Type ()
173
- if err := verifyConversionFunctionSignature (ft ); err != nil {
174
- return err
175
- }
176
- c .fns [typePair {ft .In (0 ).Elem (), ft .In (1 ).Elem ()}] = fv
177
- }
178
- return nil
179
- }
180
-
181
172
// AddUntyped adds the provided conversion function to the lookup table for the types that are
182
173
// supplied as a and b. a and b must be pointers or an error is returned. This method overwrites
183
174
// previously defined functions.
@@ -360,29 +351,6 @@ func verifyConversionFunctionSignature(ft reflect.Type) error {
360
351
return nil
361
352
}
362
353
363
- // RegisterConversionFunc registers a conversion func with the
364
- // Converter. conversionFunc must take three parameters: a pointer to the input
365
- // type, a pointer to the output type, and a conversion.Scope (which should be
366
- // used if recursive conversion calls are desired). It must return an error.
367
- //
368
- // Example:
369
- // c.RegisterConversionFunc(
370
- // func(in *Pod, out *v1.Pod, s Scope) error {
371
- // // conversion logic...
372
- // return nil
373
- // })
374
- // DEPRECATED: Will be removed in favor of RegisterUntypedConversionFunc
375
- func (c * Converter ) RegisterConversionFunc (conversionFunc interface {}) error {
376
- return c .conversionFuncs .Add (conversionFunc )
377
- }
378
-
379
- // Similar to RegisterConversionFunc, but registers conversion function that were
380
- // automatically generated.
381
- // DEPRECATED: Will be removed in favor of RegisterGeneratedUntypedConversionFunc
382
- func (c * Converter ) RegisterGeneratedConversionFunc (conversionFunc interface {}) error {
383
- return c .generatedConversionFuncs .Add (conversionFunc )
384
- }
385
-
386
354
// RegisterUntypedConversionFunc registers a function that converts between a and b by passing objects of those
387
355
// types to the provided function. The function *must* accept objects of a and b - this machinery will not enforce
388
356
// any other guarantee.
0 commit comments