Rename DCPS->DCP (name had confused a plural 's' into the acronym).

This commit is contained in:
John Beisley 2014-06-07 20:34:27 +01:00
parent 24f693965e
commit eadcb12812

View File

@ -38,7 +38,7 @@ var (
// -s, --spec_filename=<upnpresources.zip> // -s, --spec_filename=<upnpresources.zip>
// Path to the specification file, available from http://upnp.org/resources/upnpresources.zip // Path to the specification file, available from http://upnp.org/resources/upnpresources.zip
// -o, --out_dir=<output directory> // -o, --out_dir=<output directory>
// Path to the output directory. This is is where the dcps source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps // Path to the output directory. This is is where the DCP source files will be placed. Should normally correspond to the directory for github.com/huin/goupnp/dcps
// --nogofmt // --nogofmt
// Disable passing the output through gofmt. Do this if debugging code output problems and needing to see the generated code prior to being passed through gofmt. // Disable passing the output through gofmt. Do this if debugging code output problems and needing to see the generated code prior to being passed through gofmt.
func TaskSpecgen(t *tasking.T) { func TaskSpecgen(t *tasking.T) {
@ -64,7 +64,7 @@ func TaskSpecgen(t *tasking.T) {
} }
defer specArchive.Close() defer specArchive.Close()
dcpsCol := newDcpsCollection(map[string]DCPSMetadata{ dcpCol := newDcpsCollection(map[string]DCPMetadata{
"Internet Gateway_1": {"internetgateway1"}, "Internet Gateway_1": {"internetgateway1"},
"Internet Gateway_2": {"internetgateway2"}, "Internet Gateway_2": {"internetgateway2"},
}) })
@ -78,7 +78,7 @@ func TaskSpecgen(t *tasking.T) {
} }
dirName = dirName[:slashIndex] dirName = dirName[:slashIndex]
dcp := dcpsCol.dcpsForDir(dirName) dcp := dcpCol.dcpForDir(dirName)
if dcp == nil { if dcp == nil {
t.Logf("No alias defined for directory %q: skipping %s\n", dirName, f.Name) t.Logf("No alias defined for directory %q: skipping %s\n", dirName, f.Name)
continue continue
@ -89,50 +89,50 @@ func TaskSpecgen(t *tasking.T) {
dcp.processZipFile(f) dcp.processZipFile(f)
} }
for _, dcp := range dcpsCol.dcpsByAlias { for _, dcp := range dcpCol.dcpByAlias {
if err := dcp.writePackage(outDir, useGofmt); err != nil { if err := dcp.writePackage(outDir, useGofmt); err != nil {
log.Printf("Error writing package %q: %v", dcp.Metadata.Name, err) log.Printf("Error writing package %q: %v", dcp.Metadata.Name, err)
} }
} }
} }
type DCPSMetadata struct { type DCPMetadata struct {
Name string Name string
} }
type dcpsCollection struct { type dcpCollection struct {
dcpsMetadataByDir map[string]DCPSMetadata dcpMetadataByDir map[string]DCPMetadata
dcpsByAlias map[string]*DCP dcpByAlias map[string]*DCP
} }
func newDcpsCollection(dcpsMetadataByDir map[string]DCPSMetadata) *dcpsCollection { func newDcpsCollection(dcpMetadataByDir map[string]DCPMetadata) *dcpCollection {
c := &dcpsCollection{ c := &dcpCollection{
dcpsMetadataByDir: dcpsMetadataByDir, dcpMetadataByDir: dcpMetadataByDir,
dcpsByAlias: make(map[string]*DCP), dcpByAlias: make(map[string]*DCP),
} }
for _, metadata := range dcpsMetadataByDir { for _, metadata := range dcpMetadataByDir {
c.dcpsByAlias[metadata.Name] = newDCP(metadata) c.dcpByAlias[metadata.Name] = newDCP(metadata)
} }
return c return c
} }
func (c *dcpsCollection) dcpsForDir(dirName string) *DCP { func (c *dcpCollection) dcpForDir(dirName string) *DCP {
metadata, ok := c.dcpsMetadataByDir[dirName] metadata, ok := c.dcpMetadataByDir[dirName]
if !ok { if !ok {
return nil return nil
} }
return c.dcpsByAlias[metadata.Name] return c.dcpByAlias[metadata.Name]
} }
// DCP collects together information about a UPnP Device Control Protocol. // DCP collects together information about a UPnP Device Control Protocol.
type DCP struct { type DCP struct {
Metadata DCPSMetadata Metadata DCPMetadata
DeviceTypes map[string]*URNParts DeviceTypes map[string]*URNParts
ServiceTypes map[string]*URNParts ServiceTypes map[string]*URNParts
Services []SCPDWithURN Services []SCPDWithURN
} }
func newDCP(metadata DCPSMetadata) *DCP { func newDCP(metadata DCPMetadata) *DCP {
return &DCP{ return &DCP{
Metadata: metadata, Metadata: metadata,
DeviceTypes: make(map[string]*URNParts), DeviceTypes: make(map[string]*URNParts),