diff --git a/engine.go b/engine.go index 2656640..cb895a6 100644 --- a/engine.go +++ b/engine.go @@ -61,6 +61,8 @@ func (o *Engine) StartTorrent(idx int64) error { o.torrCfg = torrent.NewDefaultClientConfig() o.torrCfg.ListenPort = o.settings.ListenPort o.torrCfg.DataDir = o.settings.DownloadPath + o.torrCfg.Seed = o.settings.Seed + o.torrCfg.AcceptPeerConnections = o.settings.AcceptPeerConnections o.torrCfg.DefaultStorage = storage.NewFileWithCompletion(o.settings.DownloadPath, storage.NewMapPieceCompletion()) if o.settings.Proxy != "" { diff --git a/py/gorrent/Makefile b/py/gorrent/Makefile deleted file mode 100644 index 4d31bca..0000000 --- a/py/gorrent/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# Makefile for python interface for package gorrent. -# File is generated by gopy. Do not edit. -# gopy gen --output=py/gorrent gorrent - -GOCMD=go -GOBUILD=$(GOCMD) build -mod=mod -GOIMPORTS=goimports -PYTHON=env python3 -LIBEXT=.so - -# get the CC and flags used to build python: -GCC = $(shell $(GOCMD) env CC) -CFLAGS = $(shell python3-config --includes) -LDFLAGS = -L/usr/lib64 $(BOOST_ROOT)/stage/lib/libboost_python*.a -lpthread -ldl -lutil -lm -lm - -all: build - -build: - # build target builds the generated files -- this is what gopy build does.. - # this will otherwise be built during go build and may be out of date - - rm -f gorrent.c - # goimports is needed to ensure that the imports list is valid - $(GOIMPORTS) -w gorrent.go - # generate gorrent_go$(LIBEXT) from gorrent.go -- the cgo wrappers to go functions - $(GOBUILD) -buildmode=c-archive -o gorrent_go.a gorrent.go - # use pybindgen to build the gorrent.c file which are the CPython wrappers to cgo wrappers.. - # note: pip install pybindgen to get pybindgen if this fails - $(PYTHON) build.py - # build the _gorrent$(LIBEXT) library that contains the cgo and CPython wrappers - # generated gorrent.py python wrapper imports this c-code package - - $(GCC) gorrent.c gorrent_go.a -o _gorrent$(LIBEXT) $(CFLAGS) $(LDFLAGS) -fPIC --shared -w - diff --git a/py/gorrent/__init__.py b/py/gorrent/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/py/gorrent/build.py b/py/gorrent/build.py deleted file mode 100644 index 233133a..0000000 --- a/py/gorrent/build.py +++ /dev/null @@ -1,216 +0,0 @@ -# python build stubs for package gorrent -# File is generated by gopy. Do not edit. -# gopy gen --output=py/gorrent gorrent - -from pybindgen import retval, param, Function, Module -import sys - -class CheckedFunction(Function): - def __init__(self, *a, **kw): - super(CheckedFunction, self).__init__(*a, **kw) - self._failure_expression = kw.get('failure_expression', '') - self._failure_cleanup = kw.get('failure_cleanup', '') - - def set_failure_expression(self, expr): - self._failure_expression = expr - - def set_failure_cleanup(self, expr): - self._failure_cleanup = expr - - def generate_call(self): - super(CheckedFunction, self).generate_call() - check = "PyErr_Occurred()" - if self._failure_expression: - check = "{} && {}".format(self._failure_expression, check) - failure_cleanup = self._failure_cleanup or None - self.before_call.write_error_check(check, failure_cleanup) - -def add_checked_function(mod, name, retval, params, failure_expression='', *a, **kw): - fn = CheckedFunction(name, retval, params, *a, **kw) - fn.set_failure_expression(failure_expression) - mod._add_function_obj(fn) - return fn - -def add_checked_string_function(mod, name, retval, params, failure_expression='', *a, **kw): - fn = CheckedFunction(name, retval, params, *a, **kw) - fn.set_failure_cleanup('if (retval != NULL) free(retval);') - fn.after_call.add_cleanup_code('free(retval);') - fn.set_failure_expression(failure_expression) - mod._add_function_obj(fn) - return fn - -mod = Module('_gorrent') -mod.add_include('"gorrent_go.h"') -mod.add_function('GoPyInit', None, []) -mod.add_function('DecRef', None, [param('int64_t', 'handle')]) -mod.add_function('IncRef', None, [param('int64_t', 'handle')]) -mod.add_function('NumHandles', retval('int'), []) -mod.add_function('Slice_bool_CTor', retval('int64_t'), []) -mod.add_function('Slice_bool_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_bool_elem', retval('bool'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_bool_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_bool_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('bool', 'value')]) -mod.add_function('Slice_bool_append', None, [param('int64_t', 'handle'), param('bool', 'value')]) -mod.add_function('Slice_byte_CTor', retval('int64_t'), []) -mod.add_function('Slice_byte_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_byte_elem', retval('uint8_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_byte_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_byte_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint8_t', 'value')]) -mod.add_function('Slice_byte_append', None, [param('int64_t', 'handle'), param('uint8_t', 'value')]) -mod.add_function('Slice_float32_CTor', retval('int64_t'), []) -mod.add_function('Slice_float32_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_float32_elem', retval('float'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_float32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_float32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('float', 'value')]) -mod.add_function('Slice_float32_append', None, [param('int64_t', 'handle'), param('float', 'value')]) -mod.add_function('Slice_float64_CTor', retval('int64_t'), []) -mod.add_function('Slice_float64_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_float64_elem', retval('double'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_float64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_float64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('double', 'value')]) -mod.add_function('Slice_float64_append', None, [param('int64_t', 'handle'), param('double', 'value')]) -mod.add_function('Slice_int_CTor', retval('int64_t'), []) -mod.add_function('Slice_int_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_int_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_int_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_int_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')]) -mod.add_function('Slice_int_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')]) -mod.add_function('Slice_int16_CTor', retval('int64_t'), []) -mod.add_function('Slice_int16_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_int16_elem', retval('int16_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_int16_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_int16_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int16_t', 'value')]) -mod.add_function('Slice_int16_append', None, [param('int64_t', 'handle'), param('int16_t', 'value')]) -mod.add_function('Slice_int32_CTor', retval('int64_t'), []) -mod.add_function('Slice_int32_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_int32_elem', retval('int32_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_int32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_int32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int32_t', 'value')]) -mod.add_function('Slice_int32_append', None, [param('int64_t', 'handle'), param('int32_t', 'value')]) -mod.add_function('Slice_int64_CTor', retval('int64_t'), []) -mod.add_function('Slice_int64_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_int64_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_int64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_int64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')]) -mod.add_function('Slice_int64_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')]) -mod.add_function('Slice_int8_CTor', retval('int64_t'), []) -mod.add_function('Slice_int8_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_int8_elem', retval('int8_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_int8_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_int8_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int8_t', 'value')]) -mod.add_function('Slice_int8_append', None, [param('int64_t', 'handle'), param('int8_t', 'value')]) -mod.add_function('Slice_rune_CTor', retval('int64_t'), []) -mod.add_function('Slice_rune_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_rune_elem', retval('int32_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_rune_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_rune_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int32_t', 'value')]) -mod.add_function('Slice_rune_append', None, [param('int64_t', 'handle'), param('int32_t', 'value')]) -mod.add_function('Slice_string_CTor', retval('int64_t'), []) -mod.add_function('Slice_string_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_string_elem', retval('char*'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_string_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_string_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('char*', 'value')]) -mod.add_function('Slice_string_append', None, [param('int64_t', 'handle'), param('char*', 'value')]) -mod.add_function('Slice_uint_CTor', retval('int64_t'), []) -mod.add_function('Slice_uint_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_uint_elem', retval('uint64_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_uint_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_uint_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint64_t', 'value')]) -mod.add_function('Slice_uint_append', None, [param('int64_t', 'handle'), param('uint64_t', 'value')]) -mod.add_function('Slice_uint16_CTor', retval('int64_t'), []) -mod.add_function('Slice_uint16_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_uint16_elem', retval('uint16_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_uint16_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_uint16_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint16_t', 'value')]) -mod.add_function('Slice_uint16_append', None, [param('int64_t', 'handle'), param('uint16_t', 'value')]) -mod.add_function('Slice_uint32_CTor', retval('int64_t'), []) -mod.add_function('Slice_uint32_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_uint32_elem', retval('uint32_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_uint32_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_uint32_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint32_t', 'value')]) -mod.add_function('Slice_uint32_append', None, [param('int64_t', 'handle'), param('uint32_t', 'value')]) -mod.add_function('Slice_uint64_CTor', retval('int64_t'), []) -mod.add_function('Slice_uint64_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_uint64_elem', retval('uint64_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_uint64_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_uint64_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint64_t', 'value')]) -mod.add_function('Slice_uint64_append', None, [param('int64_t', 'handle'), param('uint64_t', 'value')]) -mod.add_function('Slice_uint8_CTor', retval('int64_t'), []) -mod.add_function('Slice_uint8_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_uint8_elem', retval('uint8_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_uint8_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_uint8_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('uint8_t', 'value')]) -mod.add_function('Slice_uint8_append', None, [param('int64_t', 'handle'), param('uint8_t', 'value')]) -mod.add_function('Slice_Ptr_gorrent_FileInfo_CTor', retval('int64_t'), []) -mod.add_function('Slice_Ptr_gorrent_FileInfo_len', retval('int'), [param('int64_t', 'handle')]) -mod.add_function('Slice_Ptr_gorrent_FileInfo_elem', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'idx')]) -mod.add_function('Slice_Ptr_gorrent_FileInfo_subslice', retval('int64_t'), [param('int64_t', 'handle'), param('int', 'st'), param('int', 'ed')]) -mod.add_function('Slice_Ptr_gorrent_FileInfo_set', None, [param('int64_t', 'handle'), param('int', 'idx'), param('int64_t', 'value')]) -mod.add_function('Slice_Ptr_gorrent_FileInfo_append', None, [param('int64_t', 'handle'), param('int64_t', 'value')]) -mod.add_function('gorrent_Settings_CTor', retval('int64_t'), []) -mod.add_function('gorrent_Settings_DownloadPath_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_DownloadPath_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Settings_HttpBindHost_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_HttpBindHost_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Settings_HttpBindPort_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_HttpBindPort_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Settings_ListenPort_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_ListenPort_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Settings_MaxConnections_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_MaxConnections_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Settings_TorrentPath_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_TorrentPath_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Settings_Proxy_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_Proxy_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Settings_KeepFiles_Get', retval('bool'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_KeepFiles_Set', None, [param('int64_t', 'handle'), param('bool', 'val')]) -mod.add_function('gorrent_Settings_Debug_Get', retval('bool'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Settings_Debug_Set', None, [param('int64_t', 'handle'), param('bool', 'val')]) -mod.add_function('gorrent_TorrentStatus_CTor', retval('int64_t'), []) -mod.add_function('gorrent_TorrentStatus_DownloadRate_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_TorrentStatus_DownloadRate_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_TorrentStatus_UploadRate_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_TorrentStatus_UploadRate_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_TorrentStatus_Seeds_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_TorrentStatus_Seeds_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Engine_CTor', retval('int64_t'), []) -add_checked_function(mod, 'gorrent_Engine_IsAlive', retval('bool'), [param('int64_t', '_handle')]) -add_checked_function(mod, 'gorrent_Engine_StartTorrent', retval('char*'), [param('int64_t', '_handle'), param('int64_t', 'idx')]) -add_checked_function(mod, 'gorrent_Engine_Status', retval('int64_t'), [param('int64_t', '_handle')]) -add_checked_function(mod, 'gorrent_Engine_FileStatus', retval('int64_t'), [param('int64_t', '_handle'), param('int64_t', 'i')]) -add_checked_function(mod, 'gorrent_Engine_Stop', None, [param('int64_t', '_handle'), param('bool', 'goRun')]) -add_checked_string_function(mod, 'gorrent_Engine_GetMsg', retval('char*'), [param('int64_t', '_handle')]) -add_checked_function(mod, 'gorrent_Engine_Clean', None, [param('int64_t', '_handle'), param('bool', 'goRun')]) -mod.add_function('gorrent_FileInfo_CTor', retval('int64_t'), []) -mod.add_function('gorrent_FileInfo_Length_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileInfo_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_FileInfo_Path_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileInfo_Path_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_FileInfo_PathUTF8_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileInfo_PathUTF8_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_FileStatus_CTor', retval('int64_t'), []) -mod.add_function('gorrent_FileStatus_Name_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileStatus_Name_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_FileStatus_Url_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileStatus_Url_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_FileStatus_Progress_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileStatus_Progress_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_FileStatus_Length_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_FileStatus_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Info_CTor', retval('int64_t'), []) -mod.add_function('gorrent_Info_Name_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Info_Name_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Info_Length_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Info_Length_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -mod.add_function('gorrent_Info_Source_Get', retval('char*'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Info_Source_Set', None, [param('int64_t', 'handle'), param('char*', 'val')]) -mod.add_function('gorrent_Info_Files_Get', retval('int64_t'), [param('int64_t', 'handle')]) -mod.add_function('gorrent_Info_Files_Set', None, [param('int64_t', 'handle'), param('int64_t', 'val')]) -add_checked_function(mod, 'gorrent_Info_LoadFile', retval('char*'), [param('int64_t', '_handle'), param('char*', 'path')]) -add_checked_function(mod, 'gorrent_NewSettings', retval('int64_t'), []) -add_checked_function(mod, 'gorrent_NewEngine', retval('int64_t'), [param('int64_t', 'settings')]) -add_checked_function(mod, 'gorrent_GetMetaFromFile', retval('int64_t'), [param('char*', 'path')]) -add_checked_string_function(mod, 'gorrent_Version', retval('char*'), []) - -mod.generate(open('gorrent.c', 'w')) - diff --git a/py/gorrent/go.py b/py/gorrent/go.py deleted file mode 100644 index 908083d..0000000 --- a/py/gorrent/go.py +++ /dev/null @@ -1,1387 +0,0 @@ - -# python wrapper for package go within overall package gorrent -# This is what you import to use the package. -# File is generated by gopy. Do not edit. -# gopy gen --output=py/gorrent gorrent - -# the following is required to enable dlopen to open the _go.so file -import os,sys,inspect,collections -try: - import collections.abc as _collections_abc -except ImportError: - _collections_abc = collections - -cwd = os.getcwd() -currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) -os.chdir(currentdir) -from . import _gorrent - -os.chdir(cwd) - -# to use this code in your end-user python file, import it as follows: -# from gorrent import go -# and then refer to everything using go. prefix -# packages imported by this package listed below: - - -import collections -try: - import collections.abc as _collections_abc -except ImportError: - _collections_abc = collections - -class GoClass(object): - """GoClass is the base class for all GoPy wrapper classes""" - def __init__(self): - self.handle = 0 - -# use go.nil for nil pointers -nil = GoClass() - -# need to explicitly initialize it -def main(): - global nil - nil = GoClass() - -main() - -def Init(): - """calls the GoPyInit function, which runs the 'main' code string that was passed using -main arg to gopy""" - _gorrent.GoPyInit() - - - - -# ---- Types --- - -# Python type for slice []bool -class Slice_bool(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_bool_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_bool.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_bool len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_bool([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_bool_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_bool_len(self.handle) - return Slice_bool(handle=_gorrent.Slice_bool_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_bool_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_bool_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_bool.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_bool_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_bool_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []byte -class Slice_byte(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_byte_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_byte.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_byte len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_byte([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_byte_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_byte_len(self.handle) - return Slice_byte(handle=_gorrent.Slice_byte_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_byte_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_byte_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_byte.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_byte_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_byte_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []float32 -class Slice_float32(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_float32_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_float32.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_float32 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_float32([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_float32_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_float32_len(self.handle) - return Slice_float32(handle=_gorrent.Slice_float32_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_float32_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_float32_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_float32.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_float32_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_float32_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []float64 -class Slice_float64(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_float64_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_float64.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_float64 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_float64([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_float64_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_float64_len(self.handle) - return Slice_float64(handle=_gorrent.Slice_float64_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_float64_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_float64_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_float64.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_float64_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_float64_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []int -class Slice_int(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_int_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_int.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_int len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_int([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_int_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_int_len(self.handle) - return Slice_int(handle=_gorrent.Slice_int_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_int_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_int_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_int.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_int_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_int_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []int16 -class Slice_int16(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_int16_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_int16.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_int16 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_int16([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_int16_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_int16_len(self.handle) - return Slice_int16(handle=_gorrent.Slice_int16_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_int16_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_int16_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_int16.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_int16_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_int16_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []int32 -class Slice_int32(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_int32_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_int32.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_int32 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_int32([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_int32_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_int32_len(self.handle) - return Slice_int32(handle=_gorrent.Slice_int32_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_int32_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_int32_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_int32.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_int32_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_int32_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []int64 -class Slice_int64(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_int64_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_int64.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_int64 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_int64([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_int64_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_int64_len(self.handle) - return Slice_int64(handle=_gorrent.Slice_int64_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_int64_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_int64_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_int64.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_int64_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_int64_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []int8 -class Slice_int8(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_int8_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_int8.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_int8 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_int8([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_int8_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_int8_len(self.handle) - return Slice_int8(handle=_gorrent.Slice_int8_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_int8_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_int8_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_int8.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_int8_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_int8_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []rune -class Slice_rune(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_rune_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_rune.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_rune len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_rune([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_rune_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_rune_len(self.handle) - return Slice_rune(handle=_gorrent.Slice_rune_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_rune_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_rune_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_rune.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_rune_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_rune_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []string -class Slice_string(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_string_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_string.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_string len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_string([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_string_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_string_len(self.handle) - return Slice_string(handle=_gorrent.Slice_string_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_string_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_string_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_string.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_string_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_string_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []uint -class Slice_uint(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_uint_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_uint.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_uint len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_uint([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_uint_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_uint_len(self.handle) - return Slice_uint(handle=_gorrent.Slice_uint_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_uint_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_uint_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_uint.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_uint_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_uint_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []uint16 -class Slice_uint16(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_uint16_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_uint16.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_uint16 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_uint16([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_uint16_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_uint16_len(self.handle) - return Slice_uint16(handle=_gorrent.Slice_uint16_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_uint16_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_uint16_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_uint16.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_uint16_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_uint16_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []uint32 -class Slice_uint32(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_uint32_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_uint32.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_uint32 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_uint32([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_uint32_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_uint32_len(self.handle) - return Slice_uint32(handle=_gorrent.Slice_uint32_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_uint32_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_uint32_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_uint32.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_uint32_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_uint32_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []uint64 -class Slice_uint64(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_uint64_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_uint64.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_uint64 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_uint64([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_uint64_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_uint64_len(self.handle) - return Slice_uint64(handle=_gorrent.Slice_uint64_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_uint64_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_uint64_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_uint64.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_uint64_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_uint64_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# Python type for slice []uint8 -class Slice_uint8(GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_uint8_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_uint8.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'go.Slice_uint8 len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'go.Slice_uint8([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_uint8_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_uint8_len(self.handle) - return Slice_uint8(handle=_gorrent.Slice_uint8_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return _gorrent.Slice_uint8_elem(self.handle, key) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_uint8_set(self.handle, idx, value) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_uint8.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_uint8_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_uint8_append(self.handle, value) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - -# ---- External Types Outside of Targeted Packages --- - - diff --git a/py/gorrent/gorrent.go b/py/gorrent/gorrent.go deleted file mode 100644 index 5341a2a..0000000 --- a/py/gorrent/gorrent.go +++ /dev/null @@ -1,1710 +0,0 @@ -/* -cgo stubs for package gorrent. -File is generated by gopy. Do not edit. -gopy gen --output=py/gorrent gorrent -*/ - -package main - -/* - -#cgo CFLAGS: -I/usr/include/python3.9 -Wno-error -Wno-implicit-function-declaration -Wno-int-conversion -#cgo LDFLAGS: -L/usr/lib64 -lpython3.9 -lpthread -ldl -lutil -lm -lm - -// #define Py_LIMITED_API // need full API for PyRun* -#include -typedef uint8_t bool; -// static inline is trick for avoiding need for extra .c file -// the following are used for build value -- switch on reflect.Kind -// or the types equivalent -static inline PyObject* gopy_build_bool(uint8_t val) { - return Py_BuildValue("b", val); -} -static inline PyObject* gopy_build_int64(int64_t val) { - return Py_BuildValue("k", val); -} -static inline PyObject* gopy_build_uint64(uint64_t val) { - return Py_BuildValue("K", val); -} -static inline PyObject* gopy_build_float64(double val) { - return Py_BuildValue("d", val); -} -static inline PyObject* gopy_build_string(const char* val) { - return Py_BuildValue("s", val); -} -static inline void gopy_decref(PyObject* obj) { // macro - Py_XDECREF(obj); -} -static inline void gopy_incref(PyObject* obj) { // macro - Py_XINCREF(obj); -} -static inline int gopy_method_check(PyObject* obj) { // macro - return PyMethod_Check(obj); -} -static inline void gopy_err_handle() { - if(PyErr_Occurred() != NULL) { - PyErr_Print(); - } -} - -*/ -import "C" -import ( - "github.com/go-python/gopy/gopyh" // handler - - "gorrent" -) - -// main doesn't do anything in lib / pkg mode, but is essential for exe mode -func main() { - -} - -// initialization functions -- can be called from python after library is loaded -// GoPyInitRunFile runs a separate python file -- call in GoPyInit if it -// steals the main thread e.g., for GUI event loop, as in GoGi startup. - -//export GoPyInit -func GoPyInit() { - -} - -// type for the handle -- int64 for speed (can switch to string) -type GoHandle int64 -type CGoHandle C.longlong - -// DecRef decrements the reference count for the specified handle -// and deletes it it goes to zero. -//export DecRef -func DecRef(handle CGoHandle) { - gopyh.DecRef(gopyh.CGoHandle(handle)) -} - -// IncRef increments the reference count for the specified handle. -//export IncRef -func IncRef(handle CGoHandle) { - gopyh.IncRef(gopyh.CGoHandle(handle)) -} - -// NumHandles returns the number of handles currently in use. -//export NumHandles -func NumHandles() int { - return gopyh.NumHandles() -} - -// boolGoToPy converts a Go bool to python-compatible C.char -func boolGoToPy(b bool) C.char { - if b { - return 1 - } - return 0 -} - -// boolPyToGo converts a python-compatible C.Char to Go bool -func boolPyToGo(b C.char) bool { - if b != 0 { - return true - } - return false -} - -func complex64GoToPy(c complex64) *C.PyObject { - return C.PyComplex_FromDoubles(C.double(real(c)), C.double(imag(c))) -} - -func complex64PyToGo(o *C.PyObject) complex64 { - v := C.PyComplex_AsCComplex(o) - return complex(float32(v.real), float32(v.imag)) -} - -func complex128GoToPy(c complex128) *C.PyObject { - return C.PyComplex_FromDoubles(C.double(real(c)), C.double(imag(c))) -} - -func complex128PyToGo(o *C.PyObject) complex128 { - v := C.PyComplex_AsCComplex(o) - return complex(float64(v.real), float64(v.imag)) -} - - - -// --- generated code for package: gorrent below: --- - - -// ---- External Types Outside of Targeted Packages --- - -// ---- Package: go --- - -// ---- Types --- - -// Converters for implicit pointer handles for type: []bool -func ptrFromHandle_Slice_bool(h CGoHandle) *[]bool { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]bool") - if p == nil { - return nil - } - return p.(*[]bool) -} -func deptrFromHandle_Slice_bool(h CGoHandle) []bool { - p := ptrFromHandle_Slice_bool(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_bool(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]bool", p)) -} - -// --- wrapping slice: []bool --- -//export Slice_bool_CTor -func Slice_bool_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_bool(&[]bool{})) -} - -//export Slice_bool_len -func Slice_bool_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_bool(handle)) -} - -//export Slice_bool_elem -func Slice_bool_elem(handle CGoHandle, _idx int) C.char { - s := deptrFromHandle_Slice_bool(handle) - return boolGoToPy(s[_idx]) -} - -//export Slice_bool_subslice -func Slice_bool_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_bool(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_bool(&ss)) -} - -//export Slice_bool_set -func Slice_bool_set(handle CGoHandle, _idx int, _vl C.char) { - s := deptrFromHandle_Slice_bool(handle) - s[_idx] = boolPyToGo(_vl) -} - -//export Slice_bool_append -func Slice_bool_append(handle CGoHandle, _vl C.char) { - s := ptrFromHandle_Slice_bool(handle) - *s = append(*s, boolPyToGo(_vl)) -} - - -// Converters for implicit pointer handles for type: []byte -func ptrFromHandle_Slice_byte(h CGoHandle) *[]byte { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]byte") - if p == nil { - return nil - } - return p.(*[]byte) -} -func deptrFromHandle_Slice_byte(h CGoHandle) []byte { - p := ptrFromHandle_Slice_byte(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_byte(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]byte", p)) -} - -// --- wrapping slice: []byte --- -//export Slice_byte_CTor -func Slice_byte_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_byte(&[]byte{})) -} - -//export Slice_byte_len -func Slice_byte_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_byte(handle)) -} - -//export Slice_byte_elem -func Slice_byte_elem(handle CGoHandle, _idx int) C.char { - s := deptrFromHandle_Slice_byte(handle) - return C.char(s[_idx]) -} - -//export Slice_byte_subslice -func Slice_byte_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_byte(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_byte(&ss)) -} - -//export Slice_byte_set -func Slice_byte_set(handle CGoHandle, _idx int, _vl C.char) { - s := deptrFromHandle_Slice_byte(handle) - s[_idx] = byte(_vl) -} - -//export Slice_byte_append -func Slice_byte_append(handle CGoHandle, _vl C.char) { - s := ptrFromHandle_Slice_byte(handle) - *s = append(*s, byte(_vl)) -} - - -// Converters for implicit pointer handles for type: []float32 -func ptrFromHandle_Slice_float32(h CGoHandle) *[]float32 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]float32") - if p == nil { - return nil - } - return p.(*[]float32) -} -func deptrFromHandle_Slice_float32(h CGoHandle) []float32 { - p := ptrFromHandle_Slice_float32(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_float32(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]float32", p)) -} - -// --- wrapping slice: []float32 --- -//export Slice_float32_CTor -func Slice_float32_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_float32(&[]float32{})) -} - -//export Slice_float32_len -func Slice_float32_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_float32(handle)) -} - -//export Slice_float32_elem -func Slice_float32_elem(handle CGoHandle, _idx int) C.float { - s := deptrFromHandle_Slice_float32(handle) - return C.float(s[_idx]) -} - -//export Slice_float32_subslice -func Slice_float32_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_float32(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_float32(&ss)) -} - -//export Slice_float32_set -func Slice_float32_set(handle CGoHandle, _idx int, _vl C.float) { - s := deptrFromHandle_Slice_float32(handle) - s[_idx] = float32(_vl) -} - -//export Slice_float32_append -func Slice_float32_append(handle CGoHandle, _vl C.float) { - s := ptrFromHandle_Slice_float32(handle) - *s = append(*s, float32(_vl)) -} - - -// Converters for implicit pointer handles for type: []float64 -func ptrFromHandle_Slice_float64(h CGoHandle) *[]float64 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]float64") - if p == nil { - return nil - } - return p.(*[]float64) -} -func deptrFromHandle_Slice_float64(h CGoHandle) []float64 { - p := ptrFromHandle_Slice_float64(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_float64(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]float64", p)) -} - -// --- wrapping slice: []float64 --- -//export Slice_float64_CTor -func Slice_float64_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_float64(&[]float64{})) -} - -//export Slice_float64_len -func Slice_float64_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_float64(handle)) -} - -//export Slice_float64_elem -func Slice_float64_elem(handle CGoHandle, _idx int) C.double { - s := deptrFromHandle_Slice_float64(handle) - return C.double(s[_idx]) -} - -//export Slice_float64_subslice -func Slice_float64_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_float64(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_float64(&ss)) -} - -//export Slice_float64_set -func Slice_float64_set(handle CGoHandle, _idx int, _vl C.double) { - s := deptrFromHandle_Slice_float64(handle) - s[_idx] = float64(_vl) -} - -//export Slice_float64_append -func Slice_float64_append(handle CGoHandle, _vl C.double) { - s := ptrFromHandle_Slice_float64(handle) - *s = append(*s, float64(_vl)) -} - - -// Converters for implicit pointer handles for type: []int -func ptrFromHandle_Slice_int(h CGoHandle) *[]int { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int") - if p == nil { - return nil - } - return p.(*[]int) -} -func deptrFromHandle_Slice_int(h CGoHandle) []int { - p := ptrFromHandle_Slice_int(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_int(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]int", p)) -} - -// --- wrapping slice: []int --- -//export Slice_int_CTor -func Slice_int_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_int(&[]int{})) -} - -//export Slice_int_len -func Slice_int_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_int(handle)) -} - -//export Slice_int_elem -func Slice_int_elem(handle CGoHandle, _idx int) C.longlong { - s := deptrFromHandle_Slice_int(handle) - return C.longlong(s[_idx]) -} - -//export Slice_int_subslice -func Slice_int_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_int(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_int(&ss)) -} - -//export Slice_int_set -func Slice_int_set(handle CGoHandle, _idx int, _vl C.longlong) { - s := deptrFromHandle_Slice_int(handle) - s[_idx] = int(_vl) -} - -//export Slice_int_append -func Slice_int_append(handle CGoHandle, _vl C.longlong) { - s := ptrFromHandle_Slice_int(handle) - *s = append(*s, int(_vl)) -} - - -// Converters for implicit pointer handles for type: []int16 -func ptrFromHandle_Slice_int16(h CGoHandle) *[]int16 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int16") - if p == nil { - return nil - } - return p.(*[]int16) -} -func deptrFromHandle_Slice_int16(h CGoHandle) []int16 { - p := ptrFromHandle_Slice_int16(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_int16(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]int16", p)) -} - -// --- wrapping slice: []int16 --- -//export Slice_int16_CTor -func Slice_int16_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_int16(&[]int16{})) -} - -//export Slice_int16_len -func Slice_int16_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_int16(handle)) -} - -//export Slice_int16_elem -func Slice_int16_elem(handle CGoHandle, _idx int) C.short { - s := deptrFromHandle_Slice_int16(handle) - return C.short(s[_idx]) -} - -//export Slice_int16_subslice -func Slice_int16_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_int16(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_int16(&ss)) -} - -//export Slice_int16_set -func Slice_int16_set(handle CGoHandle, _idx int, _vl C.short) { - s := deptrFromHandle_Slice_int16(handle) - s[_idx] = int16(_vl) -} - -//export Slice_int16_append -func Slice_int16_append(handle CGoHandle, _vl C.short) { - s := ptrFromHandle_Slice_int16(handle) - *s = append(*s, int16(_vl)) -} - - -// Converters for implicit pointer handles for type: []int32 -func ptrFromHandle_Slice_int32(h CGoHandle) *[]int32 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int32") - if p == nil { - return nil - } - return p.(*[]int32) -} -func deptrFromHandle_Slice_int32(h CGoHandle) []int32 { - p := ptrFromHandle_Slice_int32(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_int32(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]int32", p)) -} - -// --- wrapping slice: []int32 --- -//export Slice_int32_CTor -func Slice_int32_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_int32(&[]int32{})) -} - -//export Slice_int32_len -func Slice_int32_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_int32(handle)) -} - -//export Slice_int32_elem -func Slice_int32_elem(handle CGoHandle, _idx int) C.long { - s := deptrFromHandle_Slice_int32(handle) - return C.long(s[_idx]) -} - -//export Slice_int32_subslice -func Slice_int32_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_int32(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_int32(&ss)) -} - -//export Slice_int32_set -func Slice_int32_set(handle CGoHandle, _idx int, _vl C.long) { - s := deptrFromHandle_Slice_int32(handle) - s[_idx] = int32(_vl) -} - -//export Slice_int32_append -func Slice_int32_append(handle CGoHandle, _vl C.long) { - s := ptrFromHandle_Slice_int32(handle) - *s = append(*s, int32(_vl)) -} - - -// Converters for implicit pointer handles for type: []int64 -func ptrFromHandle_Slice_int64(h CGoHandle) *[]int64 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int64") - if p == nil { - return nil - } - return p.(*[]int64) -} -func deptrFromHandle_Slice_int64(h CGoHandle) []int64 { - p := ptrFromHandle_Slice_int64(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_int64(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]int64", p)) -} - -// --- wrapping slice: []int64 --- -//export Slice_int64_CTor -func Slice_int64_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_int64(&[]int64{})) -} - -//export Slice_int64_len -func Slice_int64_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_int64(handle)) -} - -//export Slice_int64_elem -func Slice_int64_elem(handle CGoHandle, _idx int) C.longlong { - s := deptrFromHandle_Slice_int64(handle) - return C.longlong(s[_idx]) -} - -//export Slice_int64_subslice -func Slice_int64_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_int64(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_int64(&ss)) -} - -//export Slice_int64_set -func Slice_int64_set(handle CGoHandle, _idx int, _vl C.longlong) { - s := deptrFromHandle_Slice_int64(handle) - s[_idx] = int64(_vl) -} - -//export Slice_int64_append -func Slice_int64_append(handle CGoHandle, _vl C.longlong) { - s := ptrFromHandle_Slice_int64(handle) - *s = append(*s, int64(_vl)) -} - - -// Converters for implicit pointer handles for type: []int8 -func ptrFromHandle_Slice_int8(h CGoHandle) *[]int8 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]int8") - if p == nil { - return nil - } - return p.(*[]int8) -} -func deptrFromHandle_Slice_int8(h CGoHandle) []int8 { - p := ptrFromHandle_Slice_int8(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_int8(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]int8", p)) -} - -// --- wrapping slice: []int8 --- -//export Slice_int8_CTor -func Slice_int8_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_int8(&[]int8{})) -} - -//export Slice_int8_len -func Slice_int8_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_int8(handle)) -} - -//export Slice_int8_elem -func Slice_int8_elem(handle CGoHandle, _idx int) C.char { - s := deptrFromHandle_Slice_int8(handle) - return C.char(s[_idx]) -} - -//export Slice_int8_subslice -func Slice_int8_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_int8(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_int8(&ss)) -} - -//export Slice_int8_set -func Slice_int8_set(handle CGoHandle, _idx int, _vl C.char) { - s := deptrFromHandle_Slice_int8(handle) - s[_idx] = int8(_vl) -} - -//export Slice_int8_append -func Slice_int8_append(handle CGoHandle, _vl C.char) { - s := ptrFromHandle_Slice_int8(handle) - *s = append(*s, int8(_vl)) -} - - -// Converters for implicit pointer handles for type: []rune -func ptrFromHandle_Slice_rune(h CGoHandle) *[]rune { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]rune") - if p == nil { - return nil - } - return p.(*[]rune) -} -func deptrFromHandle_Slice_rune(h CGoHandle) []rune { - p := ptrFromHandle_Slice_rune(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_rune(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]rune", p)) -} - -// --- wrapping slice: []rune --- -//export Slice_rune_CTor -func Slice_rune_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_rune(&[]rune{})) -} - -//export Slice_rune_len -func Slice_rune_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_rune(handle)) -} - -//export Slice_rune_elem -func Slice_rune_elem(handle CGoHandle, _idx int) C.long { - s := deptrFromHandle_Slice_rune(handle) - return C.long(s[_idx]) -} - -//export Slice_rune_subslice -func Slice_rune_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_rune(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_rune(&ss)) -} - -//export Slice_rune_set -func Slice_rune_set(handle CGoHandle, _idx int, _vl C.long) { - s := deptrFromHandle_Slice_rune(handle) - s[_idx] = rune(_vl) -} - -//export Slice_rune_append -func Slice_rune_append(handle CGoHandle, _vl C.long) { - s := ptrFromHandle_Slice_rune(handle) - *s = append(*s, rune(_vl)) -} - - -// Converters for implicit pointer handles for type: []string -func ptrFromHandle_Slice_string(h CGoHandle) *[]string { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]string") - if p == nil { - return nil - } - return p.(*[]string) -} -func deptrFromHandle_Slice_string(h CGoHandle) []string { - p := ptrFromHandle_Slice_string(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_string(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]string", p)) -} - -// --- wrapping slice: []string --- -//export Slice_string_CTor -func Slice_string_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_string(&[]string{})) -} - -//export Slice_string_len -func Slice_string_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_string(handle)) -} - -//export Slice_string_elem -func Slice_string_elem(handle CGoHandle, _idx int) *C.char { - s := deptrFromHandle_Slice_string(handle) - return C.CString(s[_idx]) -} - -//export Slice_string_subslice -func Slice_string_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_string(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_string(&ss)) -} - -//export Slice_string_set -func Slice_string_set(handle CGoHandle, _idx int, _vl *C.char) { - s := deptrFromHandle_Slice_string(handle) - s[_idx] = C.GoString(_vl) -} - -//export Slice_string_append -func Slice_string_append(handle CGoHandle, _vl *C.char) { - s := ptrFromHandle_Slice_string(handle) - *s = append(*s, C.GoString(_vl)) -} - - -// Converters for implicit pointer handles for type: []uint -func ptrFromHandle_Slice_uint(h CGoHandle) *[]uint { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]uint") - if p == nil { - return nil - } - return p.(*[]uint) -} -func deptrFromHandle_Slice_uint(h CGoHandle) []uint { - p := ptrFromHandle_Slice_uint(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_uint(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]uint", p)) -} - -// --- wrapping slice: []uint --- -//export Slice_uint_CTor -func Slice_uint_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_uint(&[]uint{})) -} - -//export Slice_uint_len -func Slice_uint_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_uint(handle)) -} - -//export Slice_uint_elem -func Slice_uint_elem(handle CGoHandle, _idx int) C.ulonglong { - s := deptrFromHandle_Slice_uint(handle) - return C.ulonglong(s[_idx]) -} - -//export Slice_uint_subslice -func Slice_uint_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_uint(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_uint(&ss)) -} - -//export Slice_uint_set -func Slice_uint_set(handle CGoHandle, _idx int, _vl C.ulonglong) { - s := deptrFromHandle_Slice_uint(handle) - s[_idx] = uint(_vl) -} - -//export Slice_uint_append -func Slice_uint_append(handle CGoHandle, _vl C.ulonglong) { - s := ptrFromHandle_Slice_uint(handle) - *s = append(*s, uint(_vl)) -} - - -// Converters for implicit pointer handles for type: []uint16 -func ptrFromHandle_Slice_uint16(h CGoHandle) *[]uint16 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]uint16") - if p == nil { - return nil - } - return p.(*[]uint16) -} -func deptrFromHandle_Slice_uint16(h CGoHandle) []uint16 { - p := ptrFromHandle_Slice_uint16(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_uint16(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]uint16", p)) -} - -// --- wrapping slice: []uint16 --- -//export Slice_uint16_CTor -func Slice_uint16_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_uint16(&[]uint16{})) -} - -//export Slice_uint16_len -func Slice_uint16_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_uint16(handle)) -} - -//export Slice_uint16_elem -func Slice_uint16_elem(handle CGoHandle, _idx int) C.ushort { - s := deptrFromHandle_Slice_uint16(handle) - return C.ushort(s[_idx]) -} - -//export Slice_uint16_subslice -func Slice_uint16_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_uint16(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_uint16(&ss)) -} - -//export Slice_uint16_set -func Slice_uint16_set(handle CGoHandle, _idx int, _vl C.ushort) { - s := deptrFromHandle_Slice_uint16(handle) - s[_idx] = uint16(_vl) -} - -//export Slice_uint16_append -func Slice_uint16_append(handle CGoHandle, _vl C.ushort) { - s := ptrFromHandle_Slice_uint16(handle) - *s = append(*s, uint16(_vl)) -} - - -// Converters for implicit pointer handles for type: []uint32 -func ptrFromHandle_Slice_uint32(h CGoHandle) *[]uint32 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]uint32") - if p == nil { - return nil - } - return p.(*[]uint32) -} -func deptrFromHandle_Slice_uint32(h CGoHandle) []uint32 { - p := ptrFromHandle_Slice_uint32(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_uint32(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]uint32", p)) -} - -// --- wrapping slice: []uint32 --- -//export Slice_uint32_CTor -func Slice_uint32_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_uint32(&[]uint32{})) -} - -//export Slice_uint32_len -func Slice_uint32_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_uint32(handle)) -} - -//export Slice_uint32_elem -func Slice_uint32_elem(handle CGoHandle, _idx int) C.ulong { - s := deptrFromHandle_Slice_uint32(handle) - return C.ulong(s[_idx]) -} - -//export Slice_uint32_subslice -func Slice_uint32_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_uint32(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_uint32(&ss)) -} - -//export Slice_uint32_set -func Slice_uint32_set(handle CGoHandle, _idx int, _vl C.ulong) { - s := deptrFromHandle_Slice_uint32(handle) - s[_idx] = uint32(_vl) -} - -//export Slice_uint32_append -func Slice_uint32_append(handle CGoHandle, _vl C.ulong) { - s := ptrFromHandle_Slice_uint32(handle) - *s = append(*s, uint32(_vl)) -} - - -// Converters for implicit pointer handles for type: []uint64 -func ptrFromHandle_Slice_uint64(h CGoHandle) *[]uint64 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]uint64") - if p == nil { - return nil - } - return p.(*[]uint64) -} -func deptrFromHandle_Slice_uint64(h CGoHandle) []uint64 { - p := ptrFromHandle_Slice_uint64(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_uint64(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]uint64", p)) -} - -// --- wrapping slice: []uint64 --- -//export Slice_uint64_CTor -func Slice_uint64_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_uint64(&[]uint64{})) -} - -//export Slice_uint64_len -func Slice_uint64_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_uint64(handle)) -} - -//export Slice_uint64_elem -func Slice_uint64_elem(handle CGoHandle, _idx int) C.ulonglong { - s := deptrFromHandle_Slice_uint64(handle) - return C.ulonglong(s[_idx]) -} - -//export Slice_uint64_subslice -func Slice_uint64_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_uint64(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_uint64(&ss)) -} - -//export Slice_uint64_set -func Slice_uint64_set(handle CGoHandle, _idx int, _vl C.ulonglong) { - s := deptrFromHandle_Slice_uint64(handle) - s[_idx] = uint64(_vl) -} - -//export Slice_uint64_append -func Slice_uint64_append(handle CGoHandle, _vl C.ulonglong) { - s := ptrFromHandle_Slice_uint64(handle) - *s = append(*s, uint64(_vl)) -} - - -// Converters for implicit pointer handles for type: []uint8 -func ptrFromHandle_Slice_uint8(h CGoHandle) *[]uint8 { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]uint8") - if p == nil { - return nil - } - return p.(*[]uint8) -} -func deptrFromHandle_Slice_uint8(h CGoHandle) []uint8 { - p := ptrFromHandle_Slice_uint8(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_uint8(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]uint8", p)) -} - -// --- wrapping slice: []uint8 --- -//export Slice_uint8_CTor -func Slice_uint8_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_uint8(&[]uint8{})) -} - -//export Slice_uint8_len -func Slice_uint8_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_uint8(handle)) -} - -//export Slice_uint8_elem -func Slice_uint8_elem(handle CGoHandle, _idx int) C.uchar { - s := deptrFromHandle_Slice_uint8(handle) - return C.uchar(s[_idx]) -} - -//export Slice_uint8_subslice -func Slice_uint8_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_uint8(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_uint8(&ss)) -} - -//export Slice_uint8_set -func Slice_uint8_set(handle CGoHandle, _idx int, _vl C.uchar) { - s := deptrFromHandle_Slice_uint8(handle) - s[_idx] = uint8(_vl) -} - -//export Slice_uint8_append -func Slice_uint8_append(handle CGoHandle, _vl C.uchar) { - s := ptrFromHandle_Slice_uint8(handle) - *s = append(*s, uint8(_vl)) -} - - -// ---- Package: gorrent --- - -// ---- Types --- - -// Converters for pointer handles for type: *gorrent.Engine -func ptrFromHandle_Ptr_gorrent_Engine(h CGoHandle) *gorrent.Engine { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.Engine") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine) -} -func handleFromPtr_Ptr_gorrent_Engine(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.Engine", p)) -} - -// Converters for pointer handles for type: *gorrent.FileInfo -func ptrFromHandle_Ptr_gorrent_FileInfo(h CGoHandle) *gorrent.FileInfo { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.FileInfo") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.FileInfo{})).(*gorrent.FileInfo) -} -func handleFromPtr_Ptr_gorrent_FileInfo(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.FileInfo", p)) -} - -// Converters for pointer handles for type: *gorrent.FileStatus -func ptrFromHandle_Ptr_gorrent_FileStatus(h CGoHandle) *gorrent.FileStatus { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.FileStatus") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.FileStatus{})).(*gorrent.FileStatus) -} -func handleFromPtr_Ptr_gorrent_FileStatus(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.FileStatus", p)) -} - -// Converters for pointer handles for type: *gorrent.Info -func ptrFromHandle_Ptr_gorrent_Info(h CGoHandle) *gorrent.Info { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.Info") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Info{})).(*gorrent.Info) -} -func handleFromPtr_Ptr_gorrent_Info(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.Info", p)) -} - -// Converters for pointer handles for type: *gorrent.Settings -func ptrFromHandle_Ptr_gorrent_Settings(h CGoHandle) *gorrent.Settings { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.Settings") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Settings{})).(*gorrent.Settings) -} -func handleFromPtr_Ptr_gorrent_Settings(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.Settings", p)) -} - -// Converters for pointer handles for type: *gorrent.TorrentStatus -func ptrFromHandle_Ptr_gorrent_TorrentStatus(h CGoHandle) *gorrent.TorrentStatus { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "*gorrent.TorrentStatus") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.TorrentStatus{})).(*gorrent.TorrentStatus) -} -func handleFromPtr_Ptr_gorrent_TorrentStatus(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("*gorrent.TorrentStatus", p)) -} - -// Converters for implicit pointer handles for type: []*gorrent.FileInfo -func ptrFromHandle_Slice_Ptr_gorrent_FileInfo(h CGoHandle) *[]*gorrent.FileInfo { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]*gorrent.FileInfo") - if p == nil { - return nil - } - return p.(*[]*gorrent.FileInfo) -} -func deptrFromHandle_Slice_Ptr_gorrent_FileInfo(h CGoHandle) []*gorrent.FileInfo { - p := ptrFromHandle_Slice_Ptr_gorrent_FileInfo(h) - if p == nil { - return nil - } - return *p -} -func handleFromPtr_Slice_Ptr_gorrent_FileInfo(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("[]*gorrent.FileInfo", p)) -} - -// --- wrapping slice: []*gorrent.FileInfo --- -//export Slice_Ptr_gorrent_FileInfo_CTor -func Slice_Ptr_gorrent_FileInfo_CTor() CGoHandle { - return CGoHandle(handleFromPtr_Slice_Ptr_gorrent_FileInfo(&[]*gorrent.FileInfo{})) -} - -//export Slice_Ptr_gorrent_FileInfo_len -func Slice_Ptr_gorrent_FileInfo_len(handle CGoHandle) int { - return len(deptrFromHandle_Slice_Ptr_gorrent_FileInfo(handle)) -} - -//export Slice_Ptr_gorrent_FileInfo_elem -func Slice_Ptr_gorrent_FileInfo_elem(handle CGoHandle, _idx int) CGoHandle { - s := deptrFromHandle_Slice_Ptr_gorrent_FileInfo(handle) - return handleFromPtr_Ptr_gorrent_FileInfo(s[_idx]) -} - -//export Slice_Ptr_gorrent_FileInfo_subslice -func Slice_Ptr_gorrent_FileInfo_subslice(handle CGoHandle, _st, _ed int) CGoHandle { - s := deptrFromHandle_Slice_Ptr_gorrent_FileInfo(handle) - ss := s[_st:_ed] - return CGoHandle(handleFromPtr_Slice_Ptr_gorrent_FileInfo(&ss)) -} - -//export Slice_Ptr_gorrent_FileInfo_set -func Slice_Ptr_gorrent_FileInfo_set(handle CGoHandle, _idx int, _vl CGoHandle) { - s := deptrFromHandle_Slice_Ptr_gorrent_FileInfo(handle) - s[_idx] = ptrFromHandle_Ptr_gorrent_FileInfo(_vl) -} - -//export Slice_Ptr_gorrent_FileInfo_append -func Slice_Ptr_gorrent_FileInfo_append(handle CGoHandle, _vl CGoHandle) { - s := ptrFromHandle_Slice_Ptr_gorrent_FileInfo(handle) - *s = append(*s, ptrFromHandle_Ptr_gorrent_FileInfo(_vl)) -} - - -// Converters for non-pointer handles for type: gorrent.Engine -func ptrFromHandle_gorrent_Engine(h CGoHandle) *gorrent.Engine { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.Engine") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine) -} -func handleFromPtr_gorrent_Engine(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.Engine", p)) -} - -// Converters for non-pointer handles for type: gorrent.FileInfo -func ptrFromHandle_gorrent_FileInfo(h CGoHandle) *gorrent.FileInfo { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.FileInfo") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.FileInfo{})).(*gorrent.FileInfo) -} -func handleFromPtr_gorrent_FileInfo(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.FileInfo", p)) -} - -// Converters for non-pointer handles for type: gorrent.FileStatus -func ptrFromHandle_gorrent_FileStatus(h CGoHandle) *gorrent.FileStatus { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.FileStatus") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.FileStatus{})).(*gorrent.FileStatus) -} -func handleFromPtr_gorrent_FileStatus(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.FileStatus", p)) -} - -// Converters for non-pointer handles for type: gorrent.Info -func ptrFromHandle_gorrent_Info(h CGoHandle) *gorrent.Info { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.Info") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Info{})).(*gorrent.Info) -} -func handleFromPtr_gorrent_Info(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.Info", p)) -} - -// Converters for non-pointer handles for type: gorrent.Settings -func ptrFromHandle_gorrent_Settings(h CGoHandle) *gorrent.Settings { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.Settings") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.Settings{})).(*gorrent.Settings) -} -func handleFromPtr_gorrent_Settings(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.Settings", p)) -} - -// Converters for non-pointer handles for type: gorrent.TorrentStatus -func ptrFromHandle_gorrent_TorrentStatus(h CGoHandle) *gorrent.TorrentStatus { - p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "gorrent.TorrentStatus") - if p == nil { - return nil - } - return gopyh.Embed(p, reflect.TypeOf(gorrent.TorrentStatus{})).(*gorrent.TorrentStatus) -} -func handleFromPtr_gorrent_TorrentStatus(p interface{}) CGoHandle { - return CGoHandle(gopyh.Register("gorrent.TorrentStatus", p)) -} - - -// ---- Global Variables: can only use functions to access --- - - -// ---- Interfaces --- - - -// ---- Structs --- - -// --- wrapping struct: gorrent.Settings --- -//export gorrent_Settings_CTor -func gorrent_Settings_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_Settings(&gorrent.Settings{})) -} -//export gorrent_Settings_DownloadPath_Get -func gorrent_Settings_DownloadPath_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return C.CString(op.DownloadPath) -} - -//export gorrent_Settings_DownloadPath_Set -func gorrent_Settings_DownloadPath_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.DownloadPath = C.GoString(val) -} - -//export gorrent_Settings_HttpBindHost_Get -func gorrent_Settings_HttpBindHost_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return C.CString(op.HttpBindHost) -} - -//export gorrent_Settings_HttpBindHost_Set -func gorrent_Settings_HttpBindHost_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.HttpBindHost = C.GoString(val) -} - -//export gorrent_Settings_HttpBindPort_Get -func gorrent_Settings_HttpBindPort_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_Settings(handle) - return C.longlong(op.HttpBindPort) -} - -//export gorrent_Settings_HttpBindPort_Set -func gorrent_Settings_HttpBindPort_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_Settings(handle) - op.HttpBindPort = int(val) -} - -//export gorrent_Settings_ListenPort_Get -func gorrent_Settings_ListenPort_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_Settings(handle) - return C.longlong(op.ListenPort) -} - -//export gorrent_Settings_ListenPort_Set -func gorrent_Settings_ListenPort_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_Settings(handle) - op.ListenPort = int(val) -} - -//export gorrent_Settings_MaxConnections_Get -func gorrent_Settings_MaxConnections_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_Settings(handle) - return C.longlong(op.MaxConnections) -} - -//export gorrent_Settings_MaxConnections_Set -func gorrent_Settings_MaxConnections_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_Settings(handle) - op.MaxConnections = int(val) -} - -//export gorrent_Settings_TorrentPath_Get -func gorrent_Settings_TorrentPath_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return C.CString(op.TorrentPath) -} - -//export gorrent_Settings_TorrentPath_Set -func gorrent_Settings_TorrentPath_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.TorrentPath = C.GoString(val) -} - -//export gorrent_Settings_Proxy_Get -func gorrent_Settings_Proxy_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return C.CString(op.Proxy) -} - -//export gorrent_Settings_Proxy_Set -func gorrent_Settings_Proxy_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.Proxy = C.GoString(val) -} - -//export gorrent_Settings_KeepFiles_Get -func gorrent_Settings_KeepFiles_Get(handle CGoHandle) C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return boolGoToPy(op.KeepFiles) -} - -//export gorrent_Settings_KeepFiles_Set -func gorrent_Settings_KeepFiles_Set(handle CGoHandle, val C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.KeepFiles = boolPyToGo(val) -} - -//export gorrent_Settings_Debug_Get -func gorrent_Settings_Debug_Get(handle CGoHandle) C.char { - op := ptrFromHandle_gorrent_Settings(handle) - return boolGoToPy(op.Debug) -} - -//export gorrent_Settings_Debug_Set -func gorrent_Settings_Debug_Set(handle CGoHandle, val C.char) { - op := ptrFromHandle_gorrent_Settings(handle) - op.Debug = boolPyToGo(val) -} - - -// --- wrapping struct: gorrent.TorrentStatus --- -//export gorrent_TorrentStatus_CTor -func gorrent_TorrentStatus_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_TorrentStatus(&gorrent.TorrentStatus{})) -} -//export gorrent_TorrentStatus_DownloadRate_Get -func gorrent_TorrentStatus_DownloadRate_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - return C.longlong(op.DownloadRate) -} - -//export gorrent_TorrentStatus_DownloadRate_Set -func gorrent_TorrentStatus_DownloadRate_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - op.DownloadRate = int64(val) -} - -//export gorrent_TorrentStatus_UploadRate_Get -func gorrent_TorrentStatus_UploadRate_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - return C.longlong(op.UploadRate) -} - -//export gorrent_TorrentStatus_UploadRate_Set -func gorrent_TorrentStatus_UploadRate_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - op.UploadRate = int64(val) -} - -//export gorrent_TorrentStatus_Seeds_Get -func gorrent_TorrentStatus_Seeds_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - return C.longlong(op.Seeds) -} - -//export gorrent_TorrentStatus_Seeds_Set -func gorrent_TorrentStatus_Seeds_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_TorrentStatus(handle) - op.Seeds = int64(val) -} - - -// --- wrapping struct: gorrent.Engine --- -//export gorrent_Engine_CTor -func gorrent_Engine_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_Engine(&gorrent.Engine{})) -} - -//export gorrent_Engine_IsAlive -func gorrent_Engine_IsAlive(_handle CGoHandle) C.char { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return boolGoToPy(false) - } - return boolGoToPy(gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).IsAlive()) - -} - -//export gorrent_Engine_StartTorrent -func gorrent_Engine_StartTorrent(_handle CGoHandle, idx C.longlong) *C.char { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return C.CString("") - } - __err = gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).StartTorrent(int64(idx)) - - if __err != nil { - estr := C.CString(__err.Error()) - C.PyErr_SetString(C.PyExc_RuntimeError, estr) - return estr - } - return C.CString("") -} - -//export gorrent_Engine_Status -func gorrent_Engine_Status(_handle CGoHandle) CGoHandle { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return handleFromPtr_gorrent_TorrentStatus(nil) - } - cret := gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).Status() - - return handleFromPtr_gorrent_TorrentStatus(&cret) -} - -//export gorrent_Engine_FileStatus -func gorrent_Engine_FileStatus(_handle CGoHandle, i C.longlong) CGoHandle { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return handleFromPtr_gorrent_FileStatus(nil) - } - cret, __err := gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).FileStatus(int(i)) - - if __err != nil { - estr := C.CString(__err.Error()) - C.PyErr_SetString(C.PyExc_RuntimeError, estr) - C.free(unsafe.Pointer(estr)) - return handleFromPtr_gorrent_FileStatus(nil) - } - return handleFromPtr_gorrent_FileStatus(&cret) -} - -//export gorrent_Engine_Stop -func gorrent_Engine_Stop(_handle CGoHandle, goRun C.char) { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return - } - if boolPyToGo(goRun) { - go gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).Stop() - } else { - gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).Stop() - } -} - -//export gorrent_Engine_GetMsg -func gorrent_Engine_GetMsg(_handle CGoHandle) *C.char { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return C.CString("") - } - return C.CString(gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).GetMsg()) - -} - -//export gorrent_Engine_Clean -func gorrent_Engine_Clean(_handle CGoHandle, goRun C.char) { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Engine") - if __err != nil { - return - } - if boolPyToGo(goRun) { - go gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).Clean() - } else { - gopyh.Embed(vifc, reflect.TypeOf(gorrent.Engine{})).(*gorrent.Engine).Clean() - } -} - -// --- wrapping struct: gorrent.FileInfo --- -//export gorrent_FileInfo_CTor -func gorrent_FileInfo_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_FileInfo(&gorrent.FileInfo{})) -} -//export gorrent_FileInfo_Length_Get -func gorrent_FileInfo_Length_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_FileInfo(handle) - return C.longlong(op.Length) -} - -//export gorrent_FileInfo_Length_Set -func gorrent_FileInfo_Length_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_FileInfo(handle) - op.Length = int64(val) -} - -//export gorrent_FileInfo_Path_Get -func gorrent_FileInfo_Path_Get(handle CGoHandle) CGoHandle { - op := ptrFromHandle_gorrent_FileInfo(handle) - return handleFromPtr_Slice_string(&op.Path) -} - -//export gorrent_FileInfo_Path_Set -func gorrent_FileInfo_Path_Set(handle CGoHandle, val CGoHandle) { - op := ptrFromHandle_gorrent_FileInfo(handle) - op.Path = deptrFromHandle_Slice_string(val) -} - -//export gorrent_FileInfo_PathUTF8_Get -func gorrent_FileInfo_PathUTF8_Get(handle CGoHandle) CGoHandle { - op := ptrFromHandle_gorrent_FileInfo(handle) - return handleFromPtr_Slice_string(&op.PathUTF8) -} - -//export gorrent_FileInfo_PathUTF8_Set -func gorrent_FileInfo_PathUTF8_Set(handle CGoHandle, val CGoHandle) { - op := ptrFromHandle_gorrent_FileInfo(handle) - op.PathUTF8 = deptrFromHandle_Slice_string(val) -} - - -// --- wrapping struct: gorrent.FileStatus --- -//export gorrent_FileStatus_CTor -func gorrent_FileStatus_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_FileStatus(&gorrent.FileStatus{})) -} -//export gorrent_FileStatus_Name_Get -func gorrent_FileStatus_Name_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_FileStatus(handle) - return C.CString(op.Name) -} - -//export gorrent_FileStatus_Name_Set -func gorrent_FileStatus_Name_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_FileStatus(handle) - op.Name = C.GoString(val) -} - -//export gorrent_FileStatus_Url_Get -func gorrent_FileStatus_Url_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_FileStatus(handle) - return C.CString(op.Url) -} - -//export gorrent_FileStatus_Url_Set -func gorrent_FileStatus_Url_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_FileStatus(handle) - op.Url = C.GoString(val) -} - -//export gorrent_FileStatus_Progress_Get -func gorrent_FileStatus_Progress_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_FileStatus(handle) - return C.longlong(op.Progress) -} - -//export gorrent_FileStatus_Progress_Set -func gorrent_FileStatus_Progress_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_FileStatus(handle) - op.Progress = int64(val) -} - -//export gorrent_FileStatus_Length_Get -func gorrent_FileStatus_Length_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_FileStatus(handle) - return C.longlong(op.Length) -} - -//export gorrent_FileStatus_Length_Set -func gorrent_FileStatus_Length_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_FileStatus(handle) - op.Length = int64(val) -} - - -// --- wrapping struct: gorrent.Info --- -//export gorrent_Info_CTor -func gorrent_Info_CTor() CGoHandle { - return CGoHandle(handleFromPtr_gorrent_Info(&gorrent.Info{})) -} -//export gorrent_Info_Name_Get -func gorrent_Info_Name_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Info(handle) - return C.CString(op.Name) -} - -//export gorrent_Info_Name_Set -func gorrent_Info_Name_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Info(handle) - op.Name = C.GoString(val) -} - -//export gorrent_Info_Length_Get -func gorrent_Info_Length_Get(handle CGoHandle) C.longlong { - op := ptrFromHandle_gorrent_Info(handle) - return C.longlong(op.Length) -} - -//export gorrent_Info_Length_Set -func gorrent_Info_Length_Set(handle CGoHandle, val C.longlong) { - op := ptrFromHandle_gorrent_Info(handle) - op.Length = int64(val) -} - -//export gorrent_Info_Source_Get -func gorrent_Info_Source_Get(handle CGoHandle) *C.char { - op := ptrFromHandle_gorrent_Info(handle) - return C.CString(op.Source) -} - -//export gorrent_Info_Source_Set -func gorrent_Info_Source_Set(handle CGoHandle, val *C.char) { - op := ptrFromHandle_gorrent_Info(handle) - op.Source = C.GoString(val) -} - -//export gorrent_Info_Files_Get -func gorrent_Info_Files_Get(handle CGoHandle) CGoHandle { - op := ptrFromHandle_gorrent_Info(handle) - return handleFromPtr_Slice_Ptr_gorrent_FileInfo(&op.Files) -} - -//export gorrent_Info_Files_Set -func gorrent_Info_Files_Set(handle CGoHandle, val CGoHandle) { - op := ptrFromHandle_gorrent_Info(handle) - op.Files = deptrFromHandle_Slice_Ptr_gorrent_FileInfo(val) -} - - -//export gorrent_Info_LoadFile -func gorrent_Info_LoadFile(_handle CGoHandle, path *C.char) *C.char { - vifc, __err := gopyh.VarFromHandleTry((gopyh.CGoHandle)(_handle), "*gorrent.Info") - if __err != nil { - return C.CString("") - } - __err = gopyh.Embed(vifc, reflect.TypeOf(gorrent.Info{})).(*gorrent.Info).LoadFile(C.GoString(path)) - - if __err != nil { - estr := C.CString(__err.Error()) - C.PyErr_SetString(C.PyExc_RuntimeError, estr) - return estr - } - return C.CString("") -} - - -// ---- Slices --- - - -// ---- Maps --- - - -// ---- Constructors --- - -//export gorrent_NewSettings -func gorrent_NewSettings() CGoHandle { - return handleFromPtr_Ptr_gorrent_Settings(gorrent.NewSettings()) - -} - -//export gorrent_NewEngine -func gorrent_NewEngine(settings CGoHandle) CGoHandle { - return handleFromPtr_Ptr_gorrent_Engine(gorrent.NewEngine(ptrFromHandle_Ptr_gorrent_Settings(settings))) - -} - -//export gorrent_GetMetaFromFile -func gorrent_GetMetaFromFile(path *C.char) CGoHandle { - cret, __err := gorrent.GetMetaFromFile(C.GoString(path)) - - if __err != nil { - estr := C.CString(__err.Error()) - C.PyErr_SetString(C.PyExc_RuntimeError, estr) - C.free(unsafe.Pointer(estr)) - return handleFromPtr_Ptr_gorrent_Info(nil) - } - return handleFromPtr_Ptr_gorrent_Info(cret) -} - - -// ---- Functions --- - -//export gorrent_Version -func gorrent_Version() *C.char { - return C.CString(gorrent.Version()) - -} - - diff --git a/py/gorrent/gorrent.py b/py/gorrent/gorrent.py deleted file mode 100644 index 292a14f..0000000 --- a/py/gorrent/gorrent.py +++ /dev/null @@ -1,723 +0,0 @@ - -# python wrapper for package gorrent within overall package gorrent -# This is what you import to use the package. -# File is generated by gopy. Do not edit. -# gopy gen --output=py/gorrent gorrent - -# the following is required to enable dlopen to open the _go.so file -import os,sys,inspect,collections -try: - import collections.abc as _collections_abc -except ImportError: - _collections_abc = collections - -cwd = os.getcwd() -currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) -os.chdir(currentdir) -from . import _gorrent -from . import go - -os.chdir(cwd) - -# to use this code in your end-user python file, import it as follows: -# from gorrent import gorrent -# and then refer to everything using gorrent. prefix -# packages imported by this package listed below: - - - - -# ---- Types --- - -# Python type for slice []*gorrent.FileInfo -class Slice_Ptr_gorrent_FileInfo(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameter is a python list that we copy from - """ - self.index = 0 - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.Slice_Ptr_gorrent_FileInfo_CTor() - _gorrent.IncRef(self.handle) - if len(args) > 0: - if not isinstance(args[0], _collections_abc.Iterable): - raise TypeError('Slice_Ptr_gorrent_FileInfo.__init__ takes a sequence as argument') - for elt in args[0]: - self.append(elt) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - s = 'gorrent.Slice_Ptr_gorrent_FileInfo len: ' + str(len(self)) + ' handle: ' + str(self.handle) + ' [' - if len(self) < 120: - s += ', '.join(map(str, self)) + ']' - return s - def __repr__(self): - return 'gorrent.Slice_Ptr_gorrent_FileInfo([' + ', '.join(map(str, self)) + '])' - def __len__(self): - return _gorrent.Slice_Ptr_gorrent_FileInfo_len(self.handle) - def __getitem__(self, key): - if isinstance(key, slice): - if key.step == None or key.step == 1: - st = key.start - ed = key.stop - if st == None: - st = 0 - if ed == None: - ed = _gorrent.Slice_Ptr_gorrent_FileInfo_len(self.handle) - return Slice_Ptr_gorrent_FileInfo(handle=_gorrent.Slice_Ptr_gorrent_FileInfo_subslice(self.handle, st, ed)) - return [self[ii] for ii in range(*key.indices(len(self)))] - elif isinstance(key, int): - if key < 0: - key += len(self) - if key < 0 or key >= len(self): - raise IndexError('slice index out of range') - return FileInfo(handle=_gorrent.Slice_Ptr_gorrent_FileInfo_elem(self.handle, key)) - else: - raise TypeError('slice index invalid type') - def __setitem__(self, idx, value): - if idx < 0: - idx += len(self) - if idx < len(self): - _gorrent.Slice_Ptr_gorrent_FileInfo_set(self.handle, idx, value.handle) - return - raise IndexError('slice index out of range') - def __iadd__(self, value): - if not isinstance(value, _collections_abc.Iterable): - raise TypeError('Slice_Ptr_gorrent_FileInfo.__iadd__ takes a sequence as argument') - for elt in value: - self.append(elt) - return self - def __iter__(self): - self.index = 0 - return self - def __next__(self): - if self.index < len(self): - rv = _gorrent.Slice_Ptr_gorrent_FileInfo_elem(self.handle, self.index) - self.index = self.index + 1 - return rv - raise StopIteration - def append(self, value): - _gorrent.Slice_Ptr_gorrent_FileInfo_append(self.handle, value.handle) - def copy(self, src): - """ copy emulates the go copy function, copying elements into this list from source list, up to min of size of each list """ - mx = min(len(self), len(src)) - for i in range(mx): - self[i] = src[i] - - -#---- Enums from Go (collections of consts with same type) --- - - -#---- Constants from Go: Python can only ask that you please don't change these! --- - - -# ---- Global Variables: can only use functions to access --- - - -# ---- Interfaces --- - - -# ---- Structs --- - -# Python type for struct gorrent.Settings -class Settings(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_Settings_CTor() - _gorrent.IncRef(self.handle) - if 0 < len(args): - self.DownloadPath = args[0] - if "DownloadPath" in kwargs: - self.DownloadPath = kwargs["DownloadPath"] - if 1 < len(args): - self.HttpBindHost = args[1] - if "HttpBindHost" in kwargs: - self.HttpBindHost = kwargs["HttpBindHost"] - if 2 < len(args): - self.HttpBindPort = args[2] - if "HttpBindPort" in kwargs: - self.HttpBindPort = kwargs["HttpBindPort"] - if 3 < len(args): - self.ListenPort = args[3] - if "ListenPort" in kwargs: - self.ListenPort = kwargs["ListenPort"] - if 4 < len(args): - self.MaxConnections = args[4] - if "MaxConnections" in kwargs: - self.MaxConnections = kwargs["MaxConnections"] - if 5 < len(args): - self.TorrentPath = args[5] - if "TorrentPath" in kwargs: - self.TorrentPath = kwargs["TorrentPath"] - if 6 < len(args): - self.Proxy = args[6] - if "Proxy" in kwargs: - self.Proxy = kwargs["Proxy"] - if 7 < len(args): - self.KeepFiles = args[7] - if "KeepFiles" in kwargs: - self.KeepFiles = kwargs["KeepFiles"] - if 8 < len(args): - self.Debug = args[8] - if "Debug" in kwargs: - self.Debug = kwargs["Debug"] - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Settings{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Settings ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - @property - def DownloadPath(self): - return _gorrent.gorrent_Settings_DownloadPath_Get(self.handle) - @DownloadPath.setter - def DownloadPath(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_DownloadPath_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_DownloadPath_Set(self.handle, value) - @property - def HttpBindHost(self): - return _gorrent.gorrent_Settings_HttpBindHost_Get(self.handle) - @HttpBindHost.setter - def HttpBindHost(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_HttpBindHost_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_HttpBindHost_Set(self.handle, value) - @property - def HttpBindPort(self): - return _gorrent.gorrent_Settings_HttpBindPort_Get(self.handle) - @HttpBindPort.setter - def HttpBindPort(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_HttpBindPort_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_HttpBindPort_Set(self.handle, value) - @property - def ListenPort(self): - return _gorrent.gorrent_Settings_ListenPort_Get(self.handle) - @ListenPort.setter - def ListenPort(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_ListenPort_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_ListenPort_Set(self.handle, value) - @property - def MaxConnections(self): - return _gorrent.gorrent_Settings_MaxConnections_Get(self.handle) - @MaxConnections.setter - def MaxConnections(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_MaxConnections_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_MaxConnections_Set(self.handle, value) - @property - def TorrentPath(self): - return _gorrent.gorrent_Settings_TorrentPath_Get(self.handle) - @TorrentPath.setter - def TorrentPath(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_TorrentPath_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_TorrentPath_Set(self.handle, value) - @property - def Proxy(self): - return _gorrent.gorrent_Settings_Proxy_Get(self.handle) - @Proxy.setter - def Proxy(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_Proxy_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_Proxy_Set(self.handle, value) - @property - def KeepFiles(self): - return _gorrent.gorrent_Settings_KeepFiles_Get(self.handle) - @KeepFiles.setter - def KeepFiles(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_KeepFiles_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_KeepFiles_Set(self.handle, value) - @property - def Debug(self): - return _gorrent.gorrent_Settings_Debug_Get(self.handle) - @Debug.setter - def Debug(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Settings_Debug_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Settings_Debug_Set(self.handle, value) - -# Python type for struct gorrent.TorrentStatus -class TorrentStatus(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_TorrentStatus_CTor() - _gorrent.IncRef(self.handle) - if 0 < len(args): - self.DownloadRate = args[0] - if "DownloadRate" in kwargs: - self.DownloadRate = kwargs["DownloadRate"] - if 1 < len(args): - self.UploadRate = args[1] - if "UploadRate" in kwargs: - self.UploadRate = kwargs["UploadRate"] - if 2 < len(args): - self.Seeds = args[2] - if "Seeds" in kwargs: - self.Seeds = kwargs["Seeds"] - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.TorrentStatus{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.TorrentStatus ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - @property - def DownloadRate(self): - return _gorrent.gorrent_TorrentStatus_DownloadRate_Get(self.handle) - @DownloadRate.setter - def DownloadRate(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_TorrentStatus_DownloadRate_Set(self.handle, value.handle) - else: - _gorrent.gorrent_TorrentStatus_DownloadRate_Set(self.handle, value) - @property - def UploadRate(self): - return _gorrent.gorrent_TorrentStatus_UploadRate_Get(self.handle) - @UploadRate.setter - def UploadRate(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_TorrentStatus_UploadRate_Set(self.handle, value.handle) - else: - _gorrent.gorrent_TorrentStatus_UploadRate_Set(self.handle, value) - @property - def Seeds(self): - return _gorrent.gorrent_TorrentStatus_Seeds_Get(self.handle) - @Seeds.setter - def Seeds(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_TorrentStatus_Seeds_Set(self.handle, value.handle) - else: - _gorrent.gorrent_TorrentStatus_Seeds_Set(self.handle, value) - -# Python type for struct gorrent.Engine -class Engine(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_Engine_CTor() - _gorrent.IncRef(self.handle) - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Engine{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Engine ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - def IsAlive(self): - """IsAlive() bool""" - return _gorrent.gorrent_Engine_IsAlive(self.handle) - def StartTorrent(self, idx): - """StartTorrent(long idx) str""" - return _gorrent.gorrent_Engine_StartTorrent(self.handle, idx) - def Status(self): - """Status() object""" - return TorrentStatus(handle=_gorrent.gorrent_Engine_Status(self.handle)) - def FileStatus(self, i): - """FileStatus(int i) object, str""" - return FileStatus(handle=_gorrent.gorrent_Engine_FileStatus(self.handle, i)) - def Stop(self, goRun=False): - """Stop() """ - _gorrent.gorrent_Engine_Stop(self.handle, goRun) - def GetMsg(self): - """GetMsg() str""" - return _gorrent.gorrent_Engine_GetMsg(self.handle) - def Clean(self, goRun=False): - """Clean() """ - _gorrent.gorrent_Engine_Clean(self.handle, goRun) - -# Python type for struct gorrent.FileInfo -class FileInfo(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_FileInfo_CTor() - _gorrent.IncRef(self.handle) - if 0 < len(args): - self.Length = args[0] - if "Length" in kwargs: - self.Length = kwargs["Length"] - if 1 < len(args): - self.Path = args[1] - if "Path" in kwargs: - self.Path = kwargs["Path"] - if 2 < len(args): - self.PathUTF8 = args[2] - if "PathUTF8" in kwargs: - self.PathUTF8 = kwargs["PathUTF8"] - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.FileInfo{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.FileInfo ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - @property - def Length(self): - return _gorrent.gorrent_FileInfo_Length_Get(self.handle) - @Length.setter - def Length(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileInfo_Length_Set(self.handle, value.handle) - else: - _gorrent.gorrent_FileInfo_Length_Set(self.handle, value) - @property - def Path(self): - return go.Slice_string(handle=_gorrent.gorrent_FileInfo_Path_Get(self.handle)) - @Path.setter - def Path(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileInfo_Path_Set(self.handle, value.handle) - else: - raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value))) - @property - def PathUTF8(self): - return go.Slice_string(handle=_gorrent.gorrent_FileInfo_PathUTF8_Get(self.handle)) - @PathUTF8.setter - def PathUTF8(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileInfo_PathUTF8_Set(self.handle, value.handle) - else: - raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value))) - -# Python type for struct gorrent.FileStatus -class FileStatus(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_FileStatus_CTor() - _gorrent.IncRef(self.handle) - if 0 < len(args): - self.Name = args[0] - if "Name" in kwargs: - self.Name = kwargs["Name"] - if 1 < len(args): - self.Url = args[1] - if "Url" in kwargs: - self.Url = kwargs["Url"] - if 2 < len(args): - self.Progress = args[2] - if "Progress" in kwargs: - self.Progress = kwargs["Progress"] - if 3 < len(args): - self.Length = args[3] - if "Length" in kwargs: - self.Length = kwargs["Length"] - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.FileStatus{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.FileStatus ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - @property - def Name(self): - return _gorrent.gorrent_FileStatus_Name_Get(self.handle) - @Name.setter - def Name(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileStatus_Name_Set(self.handle, value.handle) - else: - _gorrent.gorrent_FileStatus_Name_Set(self.handle, value) - @property - def Url(self): - return _gorrent.gorrent_FileStatus_Url_Get(self.handle) - @Url.setter - def Url(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileStatus_Url_Set(self.handle, value.handle) - else: - _gorrent.gorrent_FileStatus_Url_Set(self.handle, value) - @property - def Progress(self): - return _gorrent.gorrent_FileStatus_Progress_Get(self.handle) - @Progress.setter - def Progress(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileStatus_Progress_Set(self.handle, value.handle) - else: - _gorrent.gorrent_FileStatus_Progress_Set(self.handle, value) - @property - def Length(self): - return _gorrent.gorrent_FileStatus_Length_Get(self.handle) - @Length.setter - def Length(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_FileStatus_Length_Set(self.handle, value.handle) - else: - _gorrent.gorrent_FileStatus_Length_Set(self.handle, value) - -# Python type for struct gorrent.Info -class Info(go.GoClass): - """""" - def __init__(self, *args, **kwargs): - """ - handle=A Go-side object is always initialized with an explicit handle=arg - otherwise parameters can be unnamed in order of field names or named fields - in which case a new Go object is constructed first - """ - if len(kwargs) == 1 and 'handle' in kwargs: - self.handle = kwargs['handle'] - _gorrent.IncRef(self.handle) - elif len(args) == 1 and isinstance(args[0], go.GoClass): - self.handle = args[0].handle - _gorrent.IncRef(self.handle) - else: - self.handle = _gorrent.gorrent_Info_CTor() - _gorrent.IncRef(self.handle) - if 0 < len(args): - self.Name = args[0] - if "Name" in kwargs: - self.Name = kwargs["Name"] - if 1 < len(args): - self.Length = args[1] - if "Length" in kwargs: - self.Length = kwargs["Length"] - if 2 < len(args): - self.Source = args[2] - if "Source" in kwargs: - self.Source = kwargs["Source"] - if 3 < len(args): - self.Files = args[3] - if "Files" in kwargs: - self.Files = kwargs["Files"] - def __del__(self): - _gorrent.DecRef(self.handle) - def __str__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Info{' - first = True - for v in pr: - if callable(v[1]): - continue - if first: - first = False - else: - sv += ', ' - sv += v[0] + '=' + str(v[1]) - return sv + '}' - def __repr__(self): - pr = [(p, getattr(self, p)) for p in dir(self) if not p.startswith('__')] - sv = 'gorrent.Info ( ' - for v in pr: - if not callable(v[1]): - sv += v[0] + '=' + str(v[1]) + ', ' - return sv + ')' - @property - def Name(self): - return _gorrent.gorrent_Info_Name_Get(self.handle) - @Name.setter - def Name(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Info_Name_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Info_Name_Set(self.handle, value) - @property - def Length(self): - return _gorrent.gorrent_Info_Length_Get(self.handle) - @Length.setter - def Length(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Info_Length_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Info_Length_Set(self.handle, value) - @property - def Source(self): - return _gorrent.gorrent_Info_Source_Get(self.handle) - @Source.setter - def Source(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Info_Source_Set(self.handle, value.handle) - else: - _gorrent.gorrent_Info_Source_Set(self.handle, value) - @property - def Files(self): - return Slice_Ptr_gorrent_FileInfo(handle=_gorrent.gorrent_Info_Files_Get(self.handle)) - @Files.setter - def Files(self, value): - if isinstance(value, go.GoClass): - _gorrent.gorrent_Info_Files_Set(self.handle, value.handle) - else: - raise TypeError("supplied argument type {t} is not a go.GoClass".format(t=type(value))) - def LoadFile(self, path): - """LoadFile(str path) str""" - return _gorrent.gorrent_Info_LoadFile(self.handle, path) - - -# ---- Slices --- - - -# ---- Maps --- - - -# ---- Constructors --- -def NewSettings(): - """NewSettings() object""" - return Settings(handle=_gorrent.gorrent_NewSettings()) -def NewEngine(settings): - """NewEngine(object settings) object""" - return Engine(handle=_gorrent.gorrent_NewEngine(settings.handle)) -def GetMetaFromFile(path): - """GetMetaFromFile(str path) object, str""" - return Info(handle=_gorrent.gorrent_GetMetaFromFile(path)) - - -# ---- Functions --- -def Version(): - """Version() str""" - return _gorrent.gorrent_Version() - - diff --git a/settings.go b/settings.go index 2efa07a..78711fd 100644 --- a/settings.go +++ b/settings.go @@ -1,15 +1,17 @@ package gorrent type Settings struct { - DownloadPath string - HttpBindHost string - HttpBindPort int - ListenPort int - MaxConnections int - TorrentPath string - Proxy string - KeepFiles bool - Debug bool + DownloadPath string + HttpBindHost string + HttpBindPort int + ListenPort int + MaxConnections int + TorrentPath string + Proxy string + KeepFiles bool + Seed bool + AcceptPeerConnections bool + Debug bool } func NewSettings() *Settings {