diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-02-21 16:08:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 16:08:38 +0100 |
commit | 73855d0a5f617bcda1f33e730f3bc7cf8afbef6c (patch) | |
tree | 1616abfd6c9449e08d55563875f8c15546020a52 /cshared/std_cshared.go | |
parent | 867b10692e5f8a34a82cc0a783bdb63e2b5ff398 (diff) | |
parent | 47666e18adfa70201efc951432ab3c204c1d2ed8 (diff) | |
download | go-git-73855d0a5f617bcda1f33e730f3bc7cf8afbef6c.tar.gz |
Merge pull request #277 from ajnavarro/remove-cshared
cshared: remove directory (Fix #236)
Diffstat (limited to 'cshared/std_cshared.go')
-rw-r--r-- | cshared/std_cshared.go | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/cshared/std_cshared.go b/cshared/std_cshared.go deleted file mode 100644 index 90514b8..0000000 --- a/cshared/std_cshared.go +++ /dev/null @@ -1,143 +0,0 @@ -// +build ignore -package main - -import ( - "C" - "reflect" - "strings" -) - -//export c_std_map_get_str_str -func c_std_map_get_str_str(m uint64, key string) *C.char { - obj, ok := GetObject(Handle(m)) - if !ok { - return nil - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } - if mapval.Kind() != reflect.Map { - return nil - } - val := mapval.MapIndex(reflect.ValueOf(key)) - if !val.IsValid() || SafeIsNil(val) { - return nil - } - if (val.Kind() == reflect.Slice || val.Kind() == reflect.Array) && - val.Type().Elem().Kind() == reflect.Uint8 { - arr := make([]byte, val.Len(), val.Len()) - reflect.Copy(reflect.ValueOf(arr), val) - return CBytes(arr) - } - return C.CString(val.String()) -} - -//export c_std_map_get_str_obj -func c_std_map_get_str_obj(m uint64, key string) uint64 { - obj, ok := GetObject(Handle(m)) - if !ok { - return IH - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } - if mapval.Kind() != reflect.Map { - return IH - } - val := mapval.MapIndex(reflect.ValueOf(key)) - if !val.IsValid() || SafeIsNil(val) { - return IH - } - val_handle := RegisterObject(val.Interface()) - return uint64(val_handle) -} - -//export c_std_map_get_obj_obj -func c_std_map_get_obj_obj(m uint64, key uint64) uint64 { - obj, ok := GetObject(Handle(m)) - if !ok { - return IH - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } - if mapval.Kind() != reflect.Map { - return IH - } - obj, ok = GetObject(Handle(key)) - if !ok { - return IH - } - val := mapval.MapIndex(reflect.ValueOf(obj)) - if !val.IsValid() || SafeIsNil(val) { - return IH - } - val_handle := RegisterObject(val.Interface()) - return uint64(val_handle) -} - -//export c_std_map_keys_str -func c_std_map_keys_str(m uint64) *C.char { - obj, ok := GetObject(Handle(m)) - if !ok { - return nil - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } - if mapval.Kind() != reflect.Map { - return nil - } - keys := mapval.MapKeys() - keys_str := make([]string, 0, len(keys)) - for _, k := range keys { - keys_str = append(keys_str, k.String()) - } - return C.CString(strings.Join(keys_str, "\xff")) -} - -//export c_std_map_len -func c_std_map_len(m uint64) int { - obj, ok := GetObject(Handle(m)) - if !ok { - return -1 - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } - if mapval.Kind() != reflect.Map { - return -1 - } - return mapval.Len() -} - -//export c_std_map_set_str -func c_std_map_set_str(m uint64, key string, val uint64) { - obj, ok := GetObject(Handle(m)) - if !ok { - return - } - mapval := reflect.ValueOf(obj) - if mapval.Kind() == reflect.Ptr { - mapval = mapval.Elem() - } else { - return - } - if mapval.Kind() != reflect.Map { - return - } - if val == IH { - mapval.SetMapIndex(reflect.ValueOf(key), reflect.Value{}) - } else { - obj, ok := GetObject(Handle(val)) - if !ok { - return - } - mapval.SetMapIndex(reflect.ValueOf(key), reflect.ValueOf(obj)) - } -} |