@@ -133,6 +133,8 @@ type conversionFuncMap map[conversionPair]*types.Type
133133
134134// Returns all manually-defined conversion functions in the package.
135135func getManualConversionFunctions (context * generator.Context , pkg * types.Package , manualMap conversionFuncMap ) {
136+ glog .V (5 ).Infof ("Scanning for conversion functions in %v" , pkg .Name )
137+
136138 scopeName := types .Ref (conversionPackagePath , "Scope" ).Name
137139 errorName := types .Ref ("" , "error" ).Name
138140 buffer := & bytes.Buffer {}
@@ -147,35 +149,43 @@ func getManualConversionFunctions(context *generator.Context, pkg *types.Package
147149 glog .Errorf ("Function without signature: %#v" , f )
148150 continue
149151 }
152+ glog .V (8 ).Infof ("Considering function %s" , f .Name )
150153 signature := f .Underlying .Signature
151154 // Check whether the function is conversion function.
152155 // Note that all of them have signature:
153156 // func Convert_inType_To_outType(inType, outType, conversion.Scope) error
154157 if signature .Receiver != nil {
158+ glog .V (8 ).Infof ("%s has a receiver" , f .Name )
155159 continue
156160 }
157161 if len (signature .Parameters ) != 3 || signature .Parameters [2 ].Name != scopeName {
162+ glog .V (8 ).Infof ("%s has wrong parameters" , f .Name )
158163 continue
159164 }
160165 if len (signature .Results ) != 1 || signature .Results [0 ].Name != errorName {
166+ glog .V (8 ).Infof ("%s has wrong results" , f .Name )
161167 continue
162168 }
163169 inType := signature .Parameters [0 ]
164170 outType := signature .Parameters [1 ]
165171 if inType .Kind != types .Pointer || outType .Kind != types .Pointer {
172+ glog .V (8 ).Infof ("%s has wrong parameter types" , f .Name )
166173 continue
167174 }
168175 // Now check if the name satisfies the convention.
169176 // TODO: This should call the Namer directly.
170177 args := argsFromType (inType .Elem , outType .Elem )
171178 sw .Do ("Convert_$.inType|public$_To_$.outType|public$" , args )
172179 if f .Name .Name == buffer .String () {
180+ glog .V (4 ).Infof ("Found conversion function %s" , f .Name )
173181 key := conversionPair {inType .Elem , outType .Elem }
174182 // We might scan the same package twice, and that's OK.
175183 if v , ok := manualMap [key ]; ok && v != nil && v .Name .Package != pkg .Path {
176184 panic (fmt .Sprintf ("duplicate static conversion defined: %s -> %s" , key .inType , key .outType ))
177185 }
178186 manualMap [key ] = f
187+ } else {
188+ glog .V (8 ).Infof ("%s has wrong name" , f .Name )
179189 }
180190 buffer .Reset ()
181191 }
0 commit comments