NO-JIRA: Eliminate PN_INVALID as global constant variable taking space in
program data segment.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/587f3cd8
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/587f3cd8
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/587f3cd8

Branch: refs/heads/go1
Commit: 587f3cd8ff2ac626d02fdb509b9b2540e6f2ab89
Parents: 37be776
Author: Andrew Stitcher <[email protected]>
Authored: Tue Nov 24 10:22:01 2015 -0500
Committer: Andrew Stitcher <[email protected]>
Committed: Tue Nov 24 14:08:08 2015 -0500

----------------------------------------------------------------------
 proton-c/bindings/go/src/qpid.apache.org/amqp/types.go   |  8 +++-----
 .../bindings/go/src/qpid.apache.org/amqp/unmarshal.go    |  6 +++---
 proton-c/include/proton/codec.h                          | 11 +++++++----
 proton-c/src/codec/codec.c                               |  2 --
 4 files changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/587f3cd8/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go 
b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
index abcff25..697d896 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/types.go
@@ -30,13 +30,11 @@ import (
        "unsafe"
 )
 
-type Type C.pn_type_t
-
 // Older proton versions don't define C.PN_INVALID, so define it here.
 // In C it is pn_type_t(-1), in Go use the bitwise NOT operator to get the 
same value.
-const pnInvalid = ^C.pn_type_t(0)
+const pnInvalid = C.pn_type_t(^0)
 
-func (t Type) String() string {
+func (t C.pn_type_t) String() string {
        switch C.pn_type_t(t) {
        case C.PN_NULL:
                return "null"
@@ -89,7 +87,7 @@ func (t Type) String() string {
        case C.PN_MAP:
                return "map"
        default:
-               if uint32(t) == uint32(pnInvalid) {
+               if t == pnInvalid {
                        return "no-data"
                }
                return fmt.Sprintf("unknown-type(%d)", t)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/587f3cd8/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go 
b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
index 25bb519..05ecb8d 100644
--- a/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
+++ b/proton-c/bindings/go/src/qpid.apache.org/amqp/unmarshal.go
@@ -41,7 +41,7 @@ type UnmarshalError struct {
 }
 
 func newUnmarshalError(pnType C.pn_type_t, v interface{}) *UnmarshalError {
-       return &UnmarshalError{Type(pnType).String(), reflect.TypeOf(v)}
+       return &UnmarshalError{C.pn_type_t(pnType).String(), reflect.TypeOf(v)}
 }
 
 func (e UnmarshalError) Error() string {
@@ -451,7 +451,7 @@ func rewindUnmarshal(v interface{}, data *C.pn_data_t) {
 func getInterface(data *C.pn_data_t, v *interface{}) {
        pnType := C.pn_data_type(data)
        switch pnType {
-       case C.PN_NULL, C.pn_type_t(pnInvalid): // No data.
+       case C.PN_NULL, pnInvalid: // No data.
                *v = nil
        case C.PN_BOOL:
                *v = bool(C.pn_data_get_bool(data))
@@ -517,7 +517,7 @@ func getMap(data *C.pn_data_t, v interface{}) {
                                }
                        }
                }
-       case C.pn_type_t(pnInvalid): // Leave the map empty
+       case pnInvalid: // Leave the map empty
        default:
                panic(newUnmarshalError(pnType, v))
        }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/587f3cd8/proton-c/include/proton/codec.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/codec.h b/proton-c/include/proton/codec.h
index 3f6a6dc..3f7e5ac 100644
--- a/proton-c/include/proton/codec.h
+++ b/proton-c/include/proton/codec.h
@@ -174,11 +174,14 @@ typedef enum {
    * An AMQP map. A polymorphic container of other AMQP values formed
    * into key/value pairs.
    */
-  PN_MAP = 25
-} pn_type_t;
+  PN_MAP = 25,
 
-/** A special invalid type value that is returned when no valid type is 
available. */
-PN_EXTERN extern const pn_type_t PN_INVALID;
+  /**
+   * A special invalid type value that is returned when no valid type
+   * is available.
+   */
+  PN_INVALID = -1
+} pn_type_t;
 
 /**
  * Return a string name for an AMQP type.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/587f3cd8/proton-c/src/codec/codec.c
----------------------------------------------------------------------
diff --git a/proton-c/src/codec/codec.c b/proton-c/src/codec/codec.c
index 45026ee..1cc1ee7 100644
--- a/proton-c/src/codec/codec.c
+++ b/proton-c/src/codec/codec.c
@@ -74,8 +74,6 @@ const char *pn_type_name(pn_type_t type)
   return "<UNKNOWN>";
 }
 
-const pn_type_t PN_INVALID = (pn_type_t) -1;
-
 static inline void pni_atom_init(pn_atom_t *atom, pn_type_t type)
 {
   memset(atom, 0, sizeof(pn_atom_t));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to