profile
viewpoint

progressnerd/dbg-pencilcode-site 1

An online IDE for kids: pencilcode.net.

esrauch/pencilcode-site-gdrive 0

An online IDE for kids: pencilcode.net.

progressnerd/friendlypix-ios 0

Friendly Pix iOS is a sample app demonstrating how to build an iOS app with the Firebase Platform.

progressnerd/ideviceinstaller 0

Manage apps of iOS devices

progressnerd/libimobiledevice 0

A cross-platform protocol library to communicate with iOS devices

progressnerd/libplist 0

A library to handle Apple Property List format in binary or XML

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentopenconfig/ygot

Add Documentation on New Go Unions

 container foo { 	container bar { 		leaf union-leaf { 			type union {-				type string; 				type int8;+				type enumeration {+					enum ONE;+					enum TWO;+				} 			} 		} 	} } ``` -the `bar` container is mapped to:+The `bar` container can be mapped to one of the following generated Go code

"one of the code" sounds a little off grammatically. I'd say "The bar container can be translated to Go code according to one of the following strategies."

wenovus

comment created time in 4 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentopenconfig/ygot

Add New Go Union Generation under -generate_simple_unions

 type goStructField struct { // goUnionInterface contains a definition of an interface that should // be generated for a multi-type union in YANG. type goUnionInterface struct {-	Name           string            // Name is the name of the interface-	Types          map[string]string // Types is a map keyed by the camelcase type name, with values of the Go types in the union.-	LeafPath       string            // LeafPath stores the path for the leaf for which the multi-type union is being generated.-	ParentReceiver string            // ParentReceiver is the name of the struct that is a parent of this union field. It is used to allow methods to be created which simplify handling the union in the calling code.-	TypeNames      []string          // TypeNames is an list of Go type names within the union.+	Name                 string                 // Name is the name of the interface+	Types                map[string]string      // Types is a map keyed by the camelcase type name, with values of the Go types in the union.+	LeafPath             string                 // LeafPath stores the path for the leaf for which the multi-type union is being generated.+	ParentReceiver       string                 // ParentReceiver is the name of the struct that is a parent of this union field. It is used to allow methods to be created which simplify handling the union in the calling code.+	TypeNames            []string               // TypeNames is an list of Go type names within the union.

a list

wenovus

comment created time in 8 days

Pull request review commentopenconfig/ygot

Add New Go Union Generation under -generate_simple_unions

 type goStructField struct { // goUnionInterface contains a definition of an interface that should // be generated for a multi-type union in YANG. type goUnionInterface struct {-	Name           string            // Name is the name of the interface-	Types          map[string]string // Types is a map keyed by the camelcase type name, with values of the Go types in the union.-	LeafPath       string            // LeafPath stores the path for the leaf for which the multi-type union is being generated.-	ParentReceiver string            // ParentReceiver is the name of the struct that is a parent of this union field. It is used to allow methods to be created which simplify handling the union in the calling code.-	TypeNames      []string          // TypeNames is an list of Go type names within the union.+	Name                 string                 // Name is the name of the interface+	Types                map[string]string      // Types is a map keyed by the camelcase type name, with values of the Go types in the union.+	LeafPath             string                 // LeafPath stores the path for the leaf for which the multi-type union is being generated.

path of the leaf

wenovus

comment created time in 8 days

Pull request review commentopenconfig/ygot

Add New Go Union Generation under -generate_simple_unions

 const ( 	goEnumPrefix string = "E_" ) +// unionConversionSpec stores snippets that converts primitive Go types to

converts->convert

wenovus

comment created time in 8 days

PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentopenconfig/ygot

Add support for new Go unions for ytypes' Validate functions

 func validateLeaf(inSchema *yang.Entry, value interface{}) util.Errors { 			return util.NewErrs(fmt.Errorf("bad leaf type: expect Bool for empty type for schema %s, have type %v", schema.Name, ykind)) 		} 		rv = value+	case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Float64, reflect.String:+		if ykind != yang.Yunion {+			return util.NewErrs(fmt.Errorf("bad leaf type: expect %v for union type for schema %s, have type %v", rkind, schema.Name, ykind))+		}

why do the integer cases (both Int64 above and these cases) not assign "rv = value"?

wenovus

comment created time in 8 days

Pull request review commentopenconfig/ygot

Add support for new Go unions for ytypes' Validate functions

+// Copyright 2020 Google Inc.+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+//      http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package testutil++// Binary is a type that is used for fields that have a YANG type of+// binary. It is used such that binary fields can be distinguished from+// leaf-lists of uint8s (which are mapped to []uint8, equivalent to+// []byte in reflection).+type Binary []byte++// YANGEmpty is a type that is used for fields that have a YANG type of+// empty. It is used such that empty fields can be distinguished from boolean fields+// in the generated code.+type YANGEmpty bool++// Int8 is an int8 type assignable to unions of which it is a subtype.+type Int8 int8++// Int16 is an int16 type assignable to unions of which it is a subtype.+type Int16 int16++// Int32 is an int32 type assignable to unions of which it is a subtype.+type Int32 int32++// Int64 is an int64 type assignable to unions of which it is a subtype.+type Int64 int64++// Uint8 is a uint8 type assignable to unions of which it is a subtype.+type Uint8 uint8++// Uint16 is a uint16 type assignable to unions of which it is a subtype.+type Uint16 uint16++// Uint32 is a uint32 type assignable to unions of which it is a subtype.+type Uint32 uint32++// Uint64 is a uint64 type assignable to unions of which it is a subtype.+type Uint64 uint64++// Float64 is a float64 type assignable to unions of which it is a subtype.+type Float64 float64++// String is a string type assignable to unions of which it is a subtype.+type String string++// Bool is a bool type assignable to unions of which it is a subtype.+type Bool bool++// Unsupported is an interface{} wrapper type for unsupported types. It is+// assignable to unions of which it is a subtype.+type Unsupported struct {+	Value interface{}+}++type Union1 interface {+	IsUnion1()+}++func (String) IsUnion1()  {}+func (Int16) IsUnion1()   {}+func (Int64) IsUnion1()   {}+func (*Binary) IsUnion1() {}++func (String) IsUnion()  {}+func (Int64) IsUnion()   {}

what is there no IsUnion() method on Int16?

wenovus

comment created time in 8 days

Pull request review commentopenconfig/ygot

Add support for new Go unions for ytypes' Validate functions

+// Copyright 2020 Google Inc.+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+//      http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package testutil++// Binary is a type that is used for fields that have a YANG type of+// binary. It is used such that binary fields can be distinguished from+// leaf-lists of uint8s (which are mapped to []uint8, equivalent to+// []byte in reflection).+type Binary []byte++// YANGEmpty is a type that is used for fields that have a YANG type of+// empty. It is used such that empty fields can be distinguished from boolean fields+// in the generated code.+type YANGEmpty bool++// Int8 is an int8 type assignable to unions of which it is a subtype.+type Int8 int8++// Int16 is an int16 type assignable to unions of which it is a subtype.+type Int16 int16++// Int32 is an int32 type assignable to unions of which it is a subtype.+type Int32 int32++// Int64 is an int64 type assignable to unions of which it is a subtype.+type Int64 int64++// Uint8 is a uint8 type assignable to unions of which it is a subtype.+type Uint8 uint8++// Uint16 is a uint16 type assignable to unions of which it is a subtype.+type Uint16 uint16++// Uint32 is a uint32 type assignable to unions of which it is a subtype.+type Uint32 uint32++// Uint64 is a uint64 type assignable to unions of which it is a subtype.+type Uint64 uint64++// Float64 is a float64 type assignable to unions of which it is a subtype.+type Float64 float64++// String is a string type assignable to unions of which it is a subtype.+type String string++// Bool is a bool type assignable to unions of which it is a subtype.+type Bool bool++// Unsupported is an interface{} wrapper type for unsupported types. It is+// assignable to unions of which it is a subtype.+type Unsupported struct {+	Value interface{}+}++type Union1 interface {

Add godoc comment above exported type?

wenovus

comment created time in 8 days

PullRequestReviewEvent
PullRequestReviewEvent
PullRequestReviewEvent

Pull request review commentopenconfig/ygot

Allow keys fields that are themselves leafrefs to be unmarshalled.

 func TestStringToType(t *testing.T) { }  type allKeysListStruct struct {-	StringKey        *string  `path:"stringKey"`-	Int8Key          *int8    `path:"int8Key"`-	Int16Key         *int16   `path:"int16Key"`-	Int32Key         *int32   `path:"int32Key"`-	Int64Key         *int64   `path:"int64Key"`-	Uint8Key         *uint8   `path:"uint8Key"`-	Uint16Key        *uint16  `path:"uint16Key"`-	Uint32Key        *uint32  `path:"uint32Key"`-	Uint64Key        *uint64  `path:"uint64Key"`-	Decimal64Key     *float64 `path:"decimal64Key"`-	BoolKey          *bool    `path:"boolKey"`-	BinaryKey        Binary   `path:"binaryKey"`-	EnumKey          EnumType `path:"key3"`-	UnionKey         Union1   `path:"unionKey"`-	UnionLoneTypeKey *uint32  `path:"unionLoneTypeKey"`+	StringKey           *string  `path:"stringKey"`+	Int8Key             *int8    `path:"int8Key"`+	Int16Key            *int16   `path:"int16Key"`+	Int32Key            *int32   `path:"int32Key"`+	Int64Key            *int64   `path:"int64Key"`+	Uint8Key            *uint8   `path:"uint8Key"`+	Uint16Key           *uint16  `path:"uint16Key"`+	Uint32Key           *uint32  `path:"uint32Key"`+	Uint64Key           *uint64  `path:"uint64Key"`+	Decimal64Key        *float64 `path:"decimal64Key"`+	BoolKey             *bool    `path:"boolKey"`+	BinaryKey           Binary   `path:"binaryKey"`+	EnumKey             EnumType `path:"enumKey"`

They "key3" to "enumKey" change was intentional right?

wenovus

comment created time in a month

CommitCommentEvent

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 type NodePath struct { 	p             PathStruct } -// ResolvePath is a helper which returns the root PathStruct and absolute path-// of a PathStruct node.-func ResolvePath(n PathStruct) (PathStruct, []*gpb.PathElem, []error) {+// fakeRootPathStruct is an interface that is implemented by the fake root path+// struct type.+type fakeRootPathStruct interface {+	PathStruct+	Id() string+	CustomData() map[string]interface{}+}++func NewDeviceRootBase(id string) *DeviceRootBase {+	return &DeviceRootBase{NodePath: &NodePath{}, id: id, customData: map[string]interface{}{}}+}++// DeviceRootBase represents the fakeroot for all YANG schema elements.+type DeviceRootBase struct {+	*NodePath+	id string+	// customData is meant to store root-specific information that may be+	// useful to know when processing the resolved path. It is meant to be+	// accessible through a user-defined accessor.+	customData map[string]interface{}+}++// Id returns the device ID of the DeviceRootBase struct.+func (d *DeviceRootBase) Id() string {+	return d.id+}++// CustomData returns the customData field of the DeviceRootBase struct.+func (d *DeviceRootBase) CustomData() map[string]interface{} {+	return d.customData+}++// SetCustomDataKey modifies an entry in the customData field of the DeviceRootBase struct.+func (d *DeviceRootBase) SetCustomDataKey(key string, val interface{}) {

This function isn't strictly necessary because anyone could do CustomData()[key] = val. I could see the case for syntactic sugar, though.

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 type NodePath struct { 	p             PathStruct } -// ResolvePath is a helper which returns the root PathStruct and absolute path-// of a PathStruct node.-func ResolvePath(n PathStruct) (PathStruct, []*gpb.PathElem, []error) {+// fakeRootPathStruct is an interface that is implemented by the fake root path+// struct type.+type fakeRootPathStruct interface {+	PathStruct+	Id() string+	CustomData() map[string]interface{}+}++func NewDeviceRootBase(id string) *DeviceRootBase {+	return &DeviceRootBase{NodePath: &NodePath{}, id: id, customData: map[string]interface{}{}}+}++// DeviceRootBase represents the fakeroot for all YANG schema elements.+type DeviceRootBase struct {+	*NodePath+	id string+	// customData is meant to store root-specific information that may be+	// useful to know when processing the resolved path. It is meant to be+	// accessible through a user-defined accessor.+	customData map[string]interface{}+}++// Id returns the device ID of the DeviceRootBase struct.+func (d *DeviceRootBase) Id() string {+	return d.id+}++// CustomData returns the customData field of the DeviceRootBase struct.+func (d *DeviceRootBase) CustomData() map[string]interface{} {+	return d.customData+}++// SetCustomDataKey modifies an entry in the customData field of the DeviceRootBase struct.+func (d *DeviceRootBase) SetCustomDataKey(key string, val interface{}) {

Maybe it's not standard in ygot, but I'm used to seeing the verb "put" for maps. And then maybe you no longer need the "key" part, i.e. just "PutCustomData"

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 type NodePath struct { 	p             PathStruct } -// ResolvePath is a helper which returns the root PathStruct and absolute path-// of a PathStruct node.-func ResolvePath(n PathStruct) (PathStruct, []*gpb.PathElem, []error) {+// FakeRootPathStruct is an interface that is implemented by the fake root path+// struct type.+type FakeRootPathStruct interface {+	PathStruct+	GetId() string

If you don't need to export CustomData, could change the method names to the cleaner "Id()" and "CustomData()." The "Get" prefixed is sometimes frowned on as a "stop word" in Go.

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 type NodePath struct { 	p             PathStruct } -// ResolvePath is a helper which returns the root PathStruct and absolute path-// of a PathStruct node.-func ResolvePath(n PathStruct) (PathStruct, []*gpb.PathElem, []error) {+// FakeRootPathStruct is an interface that is implemented by the fake root path+// struct type.+type FakeRootPathStruct interface {+	PathStruct+	GetId() string+	GetCustomData() map[string]interface{}+}++func NewDeviceRootBase(id string) *DeviceRootBase {+	return &DeviceRootBase{NodePath: &NodePath{}, id: id, CustomData: map[string]interface{}{}}+}++// DeviceRootBase represents the fakeroot for all YANG schema elements.+type DeviceRootBase struct {+	*NodePath+	id         string+	CustomData map[string]interface{}

if GetCustomData is exported, does CustomData need to be exported, too?

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 import ( 	"google.golang.org/protobuf/proto" ) +type deviceRoot struct {

why is this type necessary? Why can't you just use Device directly?

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 type NodePath struct { 	p             PathStruct } -// ResolvePath is a helper which returns the root PathStruct and absolute path-// of a PathStruct node.-func ResolvePath(n PathStruct) (PathStruct, []*gpb.PathElem, []error) {+// FakeRootPathStruct is an interface that is implemented by the fake root path+// struct type.+type FakeRootPathStruct interface {

does FakeRootPathStruct itself need to be exported?

wenovus

comment created time in 3 months

Pull request review commentopenconfig/ygot

Remove Resolve function from generated code

 Imported modules were sourced from: package ocpathstructs  import (-	"fmt"--	gpb "github.com/openconfig/gnmi/proto/gnmi" 	oc "github.com/openconfig/ygot/ypathgen/testdata/exampleoc" 	"github.com/openconfig/ygot/ygot" ) -// Resolve is a helper which returns the resolved *gpb.Path of a PathStruct node.-func Resolve(n ygot.PathStruct) (*gpb.Path, map[string]interface{}, []error) {-	n, p, errs := ygot.ResolvePath(n)-	root, ok := n.(*Device)-	if !ok {-		errs = append(errs, fmt.Errorf("Resolve(n ygot.PathStruct): got unexpected root of (type, value) (%T, %v)", n, n))-	}--	if errs != nil {-		return nil, nil, errs-	}-	return &gpb.Path{Target: root.id, Elem: p}, root.customData, nil-}- // Device represents the /device YANG schema element. type Device struct {-	*ygot.NodePath-	id string-	customData map[string]interface{}+	*ygot.DeviceRootBase } +// DeviceRoot returns a new path object from which YANG paths can be constructed. func DeviceRoot(id string) *Device {-	return &Device{NodePath: &ygot.NodePath{}, id: id, customData: map[string]interface{}{}}+	return &Device{DeviceRootBase: ygot.NewDeviceRootBase(id)}

Up to your personal style, but for structs with a single field, particularly a single embedded field, reads OK just just to drop the field name, e.g. &Device{ygot.NewDeviceRootBase(id)}.

wenovus

comment created time in 3 months

more