This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git
The following commit(s) were added to refs/heads/master by this push:
new 322ce76 newtmgr - rm platform-specific code from vendor dir
322ce76 is described below
commit 322ce7613e73c9298db78b0f7c880d842ca7b24e
Author: Christopher Collins <[email protected]>
AuthorDate: Fri Jun 30 18:11:01 2017 -0700
newtmgr - rm platform-specific code from vendor dir
---
newtmgr/Godeps/Godeps.json | 4 -
newtmgr/vendor/github.com/raff/goble/LICENSE | 20 --
newtmgr/vendor/github.com/raff/goble/xpc/xpc.go | 381 ---------------------
.../vendor/github.com/raff/goble/xpc/xpc_wrapper.c | 85 -----
.../vendor/github.com/raff/goble/xpc/xpc_wrapper.h | 33 --
5 files changed, 523 deletions(-)
diff --git a/newtmgr/Godeps/Godeps.json b/newtmgr/Godeps/Godeps.json
index 51f155d..8cc8b2a 100644
--- a/newtmgr/Godeps/Godeps.json
+++ b/newtmgr/Godeps/Godeps.json
@@ -107,10 +107,6 @@
"Rev": "c605e284fe17294bda444b34710735b29d1a9d90"
},
{
- "ImportPath": "github.com/raff/goble/xpc",
- "Rev": "f6ecf99ef03749e4914b6f23547fbd7e4d363858"
- },
- {
"ImportPath": "github.com/runtimeco/go-coap",
"Rev": "69c7d16d97310edddc3bde6da452b684051549a7"
},
diff --git a/newtmgr/vendor/github.com/raff/goble/LICENSE
b/newtmgr/vendor/github.com/raff/goble/LICENSE
deleted file mode 100644
index a4f7f21..0000000
--- a/newtmgr/vendor/github.com/raff/goble/LICENSE
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2014 Raffaele Sena
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/newtmgr/vendor/github.com/raff/goble/xpc/xpc.go
b/newtmgr/vendor/github.com/raff/goble/xpc/xpc.go
deleted file mode 100644
index fd210ac..0000000
--- a/newtmgr/vendor/github.com/raff/goble/xpc/xpc.go
+++ /dev/null
@@ -1,381 +0,0 @@
-package xpc
-
-/*
-#include "xpc_wrapper.h"
-*/
-import "C"
-
-import (
- "errors"
- "fmt"
- "log"
- r "reflect"
- "strings"
- "unsafe"
-)
-
-type XPC struct {
- conn C.xpc_connection_t
-}
-
-func (x *XPC) Send(msg interface{}, verbose bool) {
- // verbose == true converts the type from bool to C._Bool
- C.XpcSendMessage(x.conn, goToXpc(msg), true, verbose == true)
-}
-
-//
-// minimal XPC support required for BLE
-//
-
-// a dictionary of things
-type Dict map[string]interface{}
-
-func (d Dict) Contains(k string) bool {
- _, ok := d[k]
- return ok
-}
-
-func (d Dict) MustGetDict(k string) Dict {
- return d[k].(Dict)
-}
-
-func (d Dict) MustGetArray(k string) Array {
- return d[k].(Array)
-}
-
-func (d Dict) MustGetBytes(k string) []byte {
- return d[k].([]byte)
-}
-
-func (d Dict) MustGetHexBytes(k string) string {
- return fmt.Sprintf("%x", d[k].([]byte))
-}
-
-func (d Dict) MustGetInt(k string) int {
- return int(d[k].(int64))
-}
-
-func (d Dict) MustGetUUID(k string) UUID {
- return d[k].(UUID)
-}
-
-func (d Dict) GetString(k, defv string) string {
- if v := d[k]; v != nil {
- //log.Printf("GetString %s %#v\n", k, v)
- return v.(string)
- } else {
- //log.Printf("GetString %s default %#v\n", k, defv)
- return defv
- }
-}
-
-func (d Dict) GetBytes(k string, defv []byte) []byte {
- if v := d[k]; v != nil {
- //log.Printf("GetBytes %s %#v\n", k, v)
- return v.([]byte)
- } else {
- //log.Printf("GetBytes %s default %#v\n", k, defv)
- return defv
- }
-}
-
-func (d Dict) GetInt(k string, defv int) int {
- if v := d[k]; v != nil {
- //log.Printf("GetString %s %#v\n", k, v)
- return int(v.(int64))
- } else {
- //log.Printf("GetString %s default %#v\n", k, defv)
- return defv
- }
-}
-
-func (d Dict) GetUUID(k string) UUID {
- return GetUUID(d[k])
-}
-
-// an Array of things
-type Array []interface{}
-
-func (a Array) GetUUID(k int) UUID {
- return GetUUID(a[k])
-}
-
-// a UUID
-type UUID [16]byte
-
-func MakeUUID(s string) UUID {
- var sl []byte
-
- s = strings.Replace(s, "-", "", -1)
- fmt.Sscanf(s, "%32x", &sl)
-
- var uuid [16]byte
- copy(uuid[:], sl)
- return UUID(uuid)
-}
-
-func MustUUID(s string) UUID {
- var sl []byte
-
- s = strings.Replace(s, "-", "", -1)
- if len(s) != 32 {
- log.Fatal("invalid UUID")
- }
- if n, err := fmt.Sscanf(s, "%32x", &sl); err != nil || n != 1 {
- log.Fatal("invalid UUID ", s, " len ", n, " error ", err)
- }
-
- var uuid [16]byte
- copy(uuid[:], sl)
- return UUID(uuid)
-}
-
-func (uuid UUID) String() string {
- return fmt.Sprintf("%x", [16]byte(uuid))
-}
-
-func GetUUID(v interface{}) UUID {
- if v == nil {
- return UUID{}
- }
-
- if uuid, ok := v.(UUID); ok {
- return uuid
- }
-
- if bytes, ok := v.([]byte); ok {
- uuid := UUID{}
-
- for i, b := range bytes {
- uuid[i] = b
- }
-
- return uuid
- }
-
- if bytes, ok := v.([]uint8); ok {
- uuid := UUID{}
-
- for i, b := range bytes {
- uuid[i] = b
- }
-
- return uuid
- }
-
- log.Fatalf("invalid type for UUID: %#v", v)
- return UUID{}
-}
-
-var (
- CONNECTION_INVALID = errors.New("connection invalid")
- CONNECTION_INTERRUPTED = errors.New("connection interrupted")
- CONNECTION_TERMINATED = errors.New("connection terminated")
-
- TYPE_OF_UUID = r.TypeOf(UUID{})
- TYPE_OF_BYTES = r.TypeOf([]byte{})
-
- handlers = map[uintptr]XpcEventHandler{}
-)
-
-type XpcEventHandler interface {
- HandleXpcEvent(event Dict, err error)
-}
-
-func XpcConnect(service string, eh XpcEventHandler) XPC {
- // func XpcConnect(service string, eh XpcEventHandler)
C.xpc_connection_t {
- ctx := uintptr(unsafe.Pointer(&eh))
- handlers[ctx] = eh
-
- cservice := C.CString(service)
- defer C.free(unsafe.Pointer(cservice))
- // return C.XpcConnect(cservice, C.uintptr_t(ctx))
- return XPC{conn: C.XpcConnect(cservice, C.uintptr_t(ctx))}
-}
-
-//export handleXpcEvent
-func handleXpcEvent(event C.xpc_object_t, p C.ulong) {
- //log.Printf("handleXpcEvent %#v %#v\n", event, p)
-
- t := C.xpc_get_type(event)
-
- eh := handlers[uintptr(p)]
- if eh == nil {
- //log.Println("no handler for", p)
- return
- }
-
- if t == C.TYPE_ERROR {
- if event == C.ERROR_CONNECTION_INVALID {
- // The client process on the other end of the
connection has either
- // crashed or cancelled the connection. After receiving
this error,
- // the connection is in an invalid state, and you do
not need to
- // call xpc_connection_cancel(). Just tear down any
associated state
- // here.
- //log.Println("connection invalid")
- eh.HandleXpcEvent(nil, CONNECTION_INVALID)
- } else if event == C.ERROR_CONNECTION_INTERRUPTED {
- //log.Println("connection interrupted")
- eh.HandleXpcEvent(nil, CONNECTION_INTERRUPTED)
- } else if event == C.ERROR_CONNECTION_TERMINATED {
- // Handle per-connection termination cleanup.
- //log.Println("connection terminated")
- eh.HandleXpcEvent(nil, CONNECTION_TERMINATED)
- } else {
- //log.Println("got some error", event)
- eh.HandleXpcEvent(nil, fmt.Errorf("%v", event))
- }
- } else {
- eh.HandleXpcEvent(xpcToGo(event).(Dict), nil)
- }
-}
-
-// goToXpc converts a go object to an xpc object
-func goToXpc(o interface{}) C.xpc_object_t {
- return valueToXpc(r.ValueOf(o))
-}
-
-// valueToXpc converts a go Value to an xpc object
-//
-// note that not all the types are supported, but only the subset required for
Blued
-func valueToXpc(val r.Value) C.xpc_object_t {
- if !val.IsValid() {
- return nil
- }
-
- var xv C.xpc_object_t
-
- switch val.Kind() {
- case r.Int, r.Int8, r.Int16, r.Int32, r.Int64:
- xv = C.xpc_int64_create(C.int64_t(val.Int()))
-
- case r.Uint, r.Uint8, r.Uint16, r.Uint32:
- xv = C.xpc_int64_create(C.int64_t(val.Uint()))
-
- case r.String:
- xv = C.xpc_string_create(C.CString(val.String()))
-
- case r.Map:
- xv = C.xpc_dictionary_create(nil, nil, 0)
- for _, k := range val.MapKeys() {
- v := valueToXpc(val.MapIndex(k))
- C.xpc_dictionary_set_value(xv, C.CString(k.String()), v)
- if v != nil {
- C.xpc_release(v)
- }
- }
-
- case r.Array, r.Slice:
- if val.Type() == TYPE_OF_UUID {
- // Array of bytes
- var uuid [16]byte
- r.Copy(r.ValueOf(uuid[:]), val)
- xv =
C.xpc_uuid_create(C.ptr_to_uuid(unsafe.Pointer(&uuid[0])))
- } else if val.Type() == TYPE_OF_BYTES {
- // slice of bytes
- xv = C.xpc_data_create(unsafe.Pointer(val.Pointer()),
C.size_t(val.Len()))
- } else {
- xv = C.xpc_array_create(nil, 0)
- l := val.Len()
-
- for i := 0; i < l; i++ {
- v := valueToXpc(val.Index(i))
- C.xpc_array_append_value(xv, v)
- if v != nil {
- C.xpc_release(v)
- }
- }
- }
-
- case r.Interface, r.Ptr:
- xv = valueToXpc(val.Elem())
-
- default:
- log.Fatalf("unsupported %#v", val.String())
- }
-
- return xv
-}
-
-//export arraySet
-func arraySet(u C.uintptr_t, i C.int, v C.xpc_object_t) {
- a := *(*Array)(unsafe.Pointer(uintptr(u)))
- a[i] = xpcToGo(v)
-}
-
-//export dictSet
-func dictSet(u C.uintptr_t, k *C.char, v C.xpc_object_t) {
- d := *(*Dict)(unsafe.Pointer(uintptr(u)))
- d[C.GoString(k)] = xpcToGo(v)
-}
-
-// xpcToGo converts an xpc object to a go object
-//
-// note that not all the types are supported, but only the subset required for
Blued
-func xpcToGo(v C.xpc_object_t) interface{} {
- t := C.xpc_get_type(v)
-
- switch t {
- case C.TYPE_ARRAY:
- a := make(Array, C.int(C.xpc_array_get_count(v)))
- p := uintptr(unsafe.Pointer(&a))
- C.XpcArrayApply(C.uintptr_t(p), v)
- return a
-
- case C.TYPE_DATA:
- return C.GoBytes(C.xpc_data_get_bytes_ptr(v),
C.int(C.xpc_data_get_length(v)))
-
- case C.TYPE_DICT:
- d := make(Dict)
- p := uintptr(unsafe.Pointer(&d))
- C.XpcDictApply(C.uintptr_t(p), v)
- return d
-
- case C.TYPE_INT64:
- return int64(C.xpc_int64_get_value(v))
-
- case C.TYPE_STRING:
- return C.GoString(C.xpc_string_get_string_ptr(v))
-
- case C.TYPE_UUID:
- a := [16]byte{}
- C.XpcUUIDGetBytes(unsafe.Pointer(&a), v)
- return UUID(a)
-
- default:
- log.Fatalf("unexpected type %#v, value %#v", t, v)
- }
-
- return nil
-}
-
-// xpc_release is needed by tests, since they can't use CGO
-func xpc_release(xv C.xpc_object_t) {
- C.xpc_release(xv)
-}
-
-// this is used to check the OS version
-
-type Utsname struct {
- Sysname string
- Nodename string
- Release string
- Version string
- Machine string
-}
-
-func Uname(utsname *Utsname) error {
- var cstruct C.struct_utsname
- if err := C.uname(&cstruct); err != 0 {
- return errors.New("utsname error")
- }
-
- // XXX: this may crash if any value is exactly 256 characters (no 0
terminator)
- utsname.Sysname = C.GoString(&cstruct.sysname[0])
- utsname.Nodename = C.GoString(&cstruct.nodename[0])
- utsname.Release = C.GoString(&cstruct.release[0])
- utsname.Version = C.GoString(&cstruct.version[0])
- utsname.Machine = C.GoString(&cstruct.machine[0])
-
- return nil
-}
diff --git a/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.c
b/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.c
deleted file mode 100644
index 130b237..0000000
--- a/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <dispatch/dispatch.h>
-#include <xpc/xpc.h>
-#include <xpc/connection.h>
-#include <Block.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "_cgo_export.h"
-
-//
-// types and errors are implemented as macros
-// create some real objects to make them accessible to Go
-//
-xpc_type_t TYPE_ERROR = XPC_TYPE_ERROR;
-
-xpc_type_t TYPE_ARRAY = XPC_TYPE_ARRAY;
-xpc_type_t TYPE_DATA = XPC_TYPE_DATA;
-xpc_type_t TYPE_DICT = XPC_TYPE_DICTIONARY;
-xpc_type_t TYPE_INT64 = XPC_TYPE_INT64;
-xpc_type_t TYPE_STRING = XPC_TYPE_STRING;
-xpc_type_t TYPE_UUID = XPC_TYPE_UUID;
-
-xpc_object_t ERROR_CONNECTION_INVALID = (xpc_object_t)
XPC_ERROR_CONNECTION_INVALID;
-xpc_object_t ERROR_CONNECTION_INTERRUPTED = (xpc_object_t)
XPC_ERROR_CONNECTION_INTERRUPTED;
-xpc_object_t ERROR_CONNECTION_TERMINATED = (xpc_object_t)
XPC_ERROR_TERMINATION_IMMINENT;
-
-const ptr_to_uuid_t ptr_to_uuid(void *p) { return (ptr_to_uuid_t)p; }
-
-
-//
-// connect to XPC service
-//
-xpc_connection_t XpcConnect(char *service, uintptr_t ctx) {
- dispatch_queue_t queue = dispatch_queue_create(service, 0);
- xpc_connection_t conn = xpc_connection_create_mach_service(service, queue,
XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
-
- // making a local copy, that should be made "persistent" with the
following Block_copy
- //GoInterface ictx = *((GoInterface*)ctx);
-
- xpc_connection_set_event_handler(conn,
- Block_copy(^(xpc_object_t event) {
- handleXpcEvent(event, ctx); //(void *)&ictx);
- })
- );
-
- xpc_connection_resume(conn);
- return conn;
-}
-
-void XpcSendMessage(xpc_connection_t conn, xpc_object_t message, bool release,
bool reportDelivery) {
- xpc_connection_send_message(conn, message);
- xpc_connection_send_barrier(conn, ^{
- // Block is invoked on connection's target queue
- // when 'message' has been sent.
- if (reportDelivery) { // maybe this could be a callback
- puts("message delivered");
- }
- });
- if (release) {
- xpc_release(message);
- }
-}
-
-void XpcArrayApply(uintptr_t v, xpc_object_t arr) {
- xpc_array_apply(arr, ^bool(size_t index, xpc_object_t value) {
- arraySet(v, index, value);
- return true;
- });
-}
-
-void XpcDictApply(uintptr_t v, xpc_object_t dict) {
- xpc_dictionary_apply(dict, ^bool(const char *key, xpc_object_t value) {
- dictSet(v, (char *)key, value);
- return true;
- });
-}
-
-void XpcUUIDGetBytes(void *v, xpc_object_t uuid) {
- const uint8_t *src = xpc_uuid_get_bytes(uuid);
- uint8_t *dest = (uint8_t *)v;
-
- for (int i=0; i < sizeof(uuid_t); i++) {
- dest[i] = src[i];
- }
-}
diff --git a/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.h
b/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.h
deleted file mode 100644
index eb7528f..0000000
--- a/newtmgr/vendor/github.com/raff/goble/xpc/xpc_wrapper.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _XPC_WRAPPER_H_
-#define _XPC_WRAPPER_H_
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <xpc/xpc.h>
-#include <sys/utsname.h>
-
-extern xpc_type_t TYPE_ERROR;
-
-extern xpc_type_t TYPE_ARRAY;
-extern xpc_type_t TYPE_DATA;
-extern xpc_type_t TYPE_DICT;
-extern xpc_type_t TYPE_INT64;
-extern xpc_type_t TYPE_STRING;
-extern xpc_type_t TYPE_UUID;
-
-extern xpc_object_t ERROR_CONNECTION_INVALID;
-extern xpc_object_t ERROR_CONNECTION_INTERRUPTED;
-extern xpc_object_t ERROR_CONNECTION_TERMINATED;
-
-extern xpc_connection_t XpcConnect(char *, uintptr_t);
-extern void XpcSendMessage(xpc_connection_t, xpc_object_t, bool, bool);
-extern void XpcArrayApply(uintptr_t, xpc_object_t);
-extern void XpcDictApply(uintptr_t, xpc_object_t);
-extern void XpcUUIDGetBytes(void *, xpc_object_t);
-
-// the input type for xpc_uuid_create should be uuid_t but CGO instists on
unsigned char *
-// typedef uuid_t * ptr_to_uuid_t;
-typedef unsigned char * ptr_to_uuid_t;
-extern const ptr_to_uuid_t ptr_to_uuid(void *p);
-
-#endif
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].