diff options
author | Antonio Jesus Navarro Perez <antonio@sourced.tech> | 2017-02-21 14:42:47 +0100 |
---|---|---|
committer | Antonio Jesus Navarro Perez <antonio@sourced.tech> | 2017-02-21 14:44:45 +0100 |
commit | 47666e18adfa70201efc951432ab3c204c1d2ed8 (patch) | |
tree | e223b2d3e3cf7637e3371586e4cf56a674b5ee6d /cshared/std_cshared.go | |
parent | 0b8b8da617d5a077f282e57d0300dc106a604236 (diff) | |
download | go-git-47666e18adfa70201efc951432ab3c204c1d2ed8.tar.gz |
cshared: remove directory (Fix #236)
If some day this code is needed, we can go back into the commit history and get it.
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)) - } -} |