diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c7dd2d15e..627e5becf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,22 +10,34 @@ on: jobs: build: - runs-on: ubuntu-latest - + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.11"] #, "3.12-dev"] + go-version: ["1.18", "1.19", "1.20"] steps: + - name: Checkout csgo library + uses: actions/checkout@v3 - name: Set up Go uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go-version }} + cache-dependency-path: awpy/parser/go.sum - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.11' - - name: Checkout csgo library - uses: actions/checkout@v3 + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + requirements.txt + tests/requirements.txt - name: Installation run: | python -m pip install --upgrade pip - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi + pip install -r requirements.txt + pip install -r tests/requirements.txt - name: Check formatting with black uses: psf/black@stable - name: Lint with ruff diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7f975e097..f37a27a3d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -22,6 +22,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: gh-pages + if: github.event_name != 'pull_request' - name: Trigger RTDs build uses: dfm/rtds-action@v1 with: diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 000000000..699060dcb --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,98 @@ +linters: + enable: + - asasalint + - asciicheck + - bidichk + - bodyclose + - containedctx + - contextcheck + # - cyclop + - decorder + - depguard + - dogsled + # - dupl # Probably useful in principle. But did not find an easy way. + - dupword + - durationcheck + - errcheck + - errchkjson + - errname + - errorlint + - execinquery + - exhaustive + # - exhaustruct # Should be useful in the future. No time now + - exportloopref + - forbidigo + - forcetypeassert + # - funlen # Should be usefull in the future. No time atm + # - gci # Broken for me + - ginkgolinter + - gocheckcompilerdirectives + - gochecknoglobals + - gochecknoinits + # - gocognit # Similar to cyclop. Could be usefull + - goconst + - gocritic + # - gocyclo + - godot + - godox + - goerr113 + # - gofmt + # - gofumpt + - goheader + # - goimports + # - gomnd + - gomoddirectives + - gomodguard + - goprintffuncname + - gosec + - gosimple + - govet + - grouper + - importas + - ineffassign + - interfacebloat + - ireturn + - lll + - loggercheck + - maintidx + - makezero + - misspell + - musttag + - nakedret + # - nestif + - nilerr + - nilnil + - nlreturn + - noctx + - nolintlint + - nonamedreturns + - nosprintfhostport + - paralleltest + - prealloc + - predeclared + - promlinter + - reassign + - revive + - staticcheck + - stylecheck + # - tagliatelle + - tenv + - testableexamples + - testpackage + - thelper + - tparallel + - typecheck + - unconvert + - unparam + - unused + - usestdlibvars + # - varnamelen # Usefull for the future + - whitespace + - wrapcheck + # - wsl +linters-settings: + maintidx: + # Show functions with maintainability index lower than N. + # A high index indicates better maintainability (it's kind of the opposite of complexity). + # Default: 20 + under: 10 diff --git a/awpy/parser/awpygo/__init__.py b/awpy/parser/awpygo/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/awpy/parser/awpygo/_awpygo.cp311-win_amd64.h b/awpy/parser/awpygo/_awpygo.cp311-win_amd64.h new file mode 100644 index 000000000..ed66e4d71 --- /dev/null +++ b/awpy/parser/awpygo/_awpygo.cp311-win_amd64.h @@ -0,0 +1,292 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/pnxenopoulos/awpygo/awpygo/awpygo */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 9 "awpygo.go" + + + + + +// #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(); + } +} + + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __declspec(dllexport) void GoPyInit(); + +// DecRef decrements the reference count for the specified handle +// and deletes it it goes to zero. +// +extern __declspec(dllexport) void DecRef(long long int handle); + +// IncRef increments the reference count for the specified handle. +// +extern __declspec(dllexport) void IncRef(long long int handle); + +// NumHandles returns the number of handles currently in use. +// +extern __declspec(dllexport) GoInt NumHandles(); + +// --- wrapping slice: []bool --- +// +extern __declspec(dllexport) long long int Slice_bool_CTor(); +extern __declspec(dllexport) GoInt Slice_bool_len(long long int handle); +extern __declspec(dllexport) char Slice_bool_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_bool_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_bool_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_bool_append(long long int handle, char _vl); + +// --- wrapping slice: []byte --- +// +extern __declspec(dllexport) long long int Slice_byte_CTor(); +extern __declspec(dllexport) GoInt Slice_byte_len(long long int handle); +extern __declspec(dllexport) char Slice_byte_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_byte_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_byte_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_byte_append(long long int handle, char _vl); + +// --- wrapping slice: []error --- +// +extern __declspec(dllexport) long long int Slice_error_CTor(); +extern __declspec(dllexport) GoInt Slice_error_len(long long int handle); +extern __declspec(dllexport) char* Slice_error_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_error_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_error_set(long long int handle, GoInt _idx, char* _vl); +extern __declspec(dllexport) void Slice_error_append(long long int handle, char* _vl); + +// --- wrapping slice: []float32 --- +// +extern __declspec(dllexport) long long int Slice_float32_CTor(); +extern __declspec(dllexport) GoInt Slice_float32_len(long long int handle); +extern __declspec(dllexport) float Slice_float32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_float32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_float32_set(long long int handle, GoInt _idx, float _vl); +extern __declspec(dllexport) void Slice_float32_append(long long int handle, float _vl); + +// --- wrapping slice: []float64 --- +// +extern __declspec(dllexport) long long int Slice_float64_CTor(); +extern __declspec(dllexport) GoInt Slice_float64_len(long long int handle); +extern __declspec(dllexport) double Slice_float64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_float64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_float64_set(long long int handle, GoInt _idx, double _vl); +extern __declspec(dllexport) void Slice_float64_append(long long int handle, double _vl); + +// --- wrapping slice: []int --- +// +extern __declspec(dllexport) long long int Slice_int_CTor(); +extern __declspec(dllexport) GoInt Slice_int_len(long long int handle); +extern __declspec(dllexport) long long int Slice_int_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int_set(long long int handle, GoInt _idx, long long int _vl); +extern __declspec(dllexport) void Slice_int_append(long long int handle, long long int _vl); + +// --- wrapping slice: []int16 --- +// +extern __declspec(dllexport) long long int Slice_int16_CTor(); +extern __declspec(dllexport) GoInt Slice_int16_len(long long int handle); +extern __declspec(dllexport) short int Slice_int16_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int16_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int16_set(long long int handle, GoInt _idx, short int _vl); +extern __declspec(dllexport) void Slice_int16_append(long long int handle, short int _vl); + +// --- wrapping slice: []int32 --- +// +extern __declspec(dllexport) long long int Slice_int32_CTor(); +extern __declspec(dllexport) GoInt Slice_int32_len(long long int handle); +extern __declspec(dllexport) long int Slice_int32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int32_set(long long int handle, GoInt _idx, long int _vl); +extern __declspec(dllexport) void Slice_int32_append(long long int handle, long int _vl); + +// --- wrapping slice: []int64 --- +// +extern __declspec(dllexport) long long int Slice_int64_CTor(); +extern __declspec(dllexport) GoInt Slice_int64_len(long long int handle); +extern __declspec(dllexport) long long int Slice_int64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int64_set(long long int handle, GoInt _idx, long long int _vl); +extern __declspec(dllexport) void Slice_int64_append(long long int handle, long long int _vl); + +// --- wrapping slice: []int8 --- +// +extern __declspec(dllexport) long long int Slice_int8_CTor(); +extern __declspec(dllexport) GoInt Slice_int8_len(long long int handle); +extern __declspec(dllexport) char Slice_int8_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int8_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int8_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_int8_append(long long int handle, char _vl); + +// --- wrapping slice: []rune --- +// +extern __declspec(dllexport) long long int Slice_rune_CTor(); +extern __declspec(dllexport) GoInt Slice_rune_len(long long int handle); +extern __declspec(dllexport) long int Slice_rune_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_rune_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_rune_set(long long int handle, GoInt _idx, long int _vl); +extern __declspec(dllexport) void Slice_rune_append(long long int handle, long int _vl); + +// --- wrapping slice: []string --- +// +extern __declspec(dllexport) long long int Slice_string_CTor(); +extern __declspec(dllexport) GoInt Slice_string_len(long long int handle); +extern __declspec(dllexport) char* Slice_string_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_string_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_string_set(long long int handle, GoInt _idx, char* _vl); +extern __declspec(dllexport) void Slice_string_append(long long int handle, char* _vl); + +// --- wrapping slice: []uint --- +// +extern __declspec(dllexport) long long int Slice_uint_CTor(); +extern __declspec(dllexport) GoInt Slice_uint_len(long long int handle); +extern __declspec(dllexport) long long unsigned int Slice_uint_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint_set(long long int handle, GoInt _idx, long long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint_append(long long int handle, long long unsigned int _vl); + +// --- wrapping slice: []uint16 --- +// +extern __declspec(dllexport) long long int Slice_uint16_CTor(); +extern __declspec(dllexport) GoInt Slice_uint16_len(long long int handle); +extern __declspec(dllexport) short unsigned int Slice_uint16_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint16_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint16_set(long long int handle, GoInt _idx, short unsigned int _vl); +extern __declspec(dllexport) void Slice_uint16_append(long long int handle, short unsigned int _vl); + +// --- wrapping slice: []uint32 --- +// +extern __declspec(dllexport) long long int Slice_uint32_CTor(); +extern __declspec(dllexport) GoInt Slice_uint32_len(long long int handle); +extern __declspec(dllexport) long unsigned int Slice_uint32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint32_set(long long int handle, GoInt _idx, long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint32_append(long long int handle, long unsigned int _vl); + +// --- wrapping slice: []uint64 --- +// +extern __declspec(dllexport) long long int Slice_uint64_CTor(); +extern __declspec(dllexport) GoInt Slice_uint64_len(long long int handle); +extern __declspec(dllexport) long long unsigned int Slice_uint64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint64_set(long long int handle, GoInt _idx, long long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint64_append(long long int handle, long long unsigned int _vl); + +// --- wrapping slice: []uint8 --- +// +extern __declspec(dllexport) long long int Slice_uint8_CTor(); +extern __declspec(dllexport) GoInt Slice_uint8_len(long long int handle); +extern __declspec(dllexport) unsigned char Slice_uint8_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint8_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint8_set(long long int handle, GoInt _idx, unsigned char _vl); +extern __declspec(dllexport) void Slice_uint8_append(long long int handle, unsigned char _vl); +extern __declspec(dllexport) void awpygo_ParseDemo(char* demPath, char* demoID, long long int parseRate, char parseFrames, char parseKillFrames, long long int tradeTime, char* roundBuyStyle, char damagesRolled, char jsonIndentation, char parseChat, char* outpath, char goRun); + +#ifdef __cplusplus +} +#endif diff --git a/awpy/parser/awpygo/_awpygo.cp311-win_amd64.pyd b/awpy/parser/awpygo/_awpygo.cp311-win_amd64.pyd new file mode 100644 index 000000000..27b7740f7 Binary files /dev/null and b/awpy/parser/awpygo/_awpygo.cp311-win_amd64.pyd differ diff --git a/awpy/parser/awpygo/awpygo.c b/awpy/parser/awpygo/awpygo.c new file mode 100644 index 000000000..8c5002653 --- /dev/null +++ b/awpy/parser/awpygo/awpygo.c @@ -0,0 +1,2197 @@ +/* This file was generated by PyBindGen 0.0.0.0 */ +#define PY_SSIZE_T_CLEAN +#include +#include + + +#if PY_VERSION_HEX >= 0x03000000 +#if PY_VERSION_HEX >= 0x03050000 +typedef PyAsyncMethods* cmpfunc; +#else +typedef void* cmpfunc; +#endif +#define PyCObject_FromVoidPtr(a, b) PyCapsule_New(a, NULL, b) +#define PyCObject_AsVoidPtr(a) PyCapsule_GetPointer(a, NULL) +#define PyString_FromString(a) PyBytes_FromString(a) +#define Py_TPFLAGS_CHECKTYPES 0 /* this flag doesn't exist in python 3 */ +#endif + + +#if __GNUC__ > 2 +# define PYBINDGEN_UNUSED(param) param __attribute__((__unused__)) +#elif __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4) +# define PYBINDGEN_UNUSED(param) __attribute__((__unused__)) param +#else +# define PYBINDGEN_UNUSED(param) param +#endif /* !__GNUC__ */ + +#ifndef _PyBindGenWrapperFlags_defined_ +#define _PyBindGenWrapperFlags_defined_ +typedef enum _PyBindGenWrapperFlags { + PYBINDGEN_WRAPPER_FLAG_NONE = 0, + PYBINDGEN_WRAPPER_FLAG_OBJECT_NOT_OWNED = (1<<0), +} PyBindGenWrapperFlags; +#endif + +#if PY_VERSION_HEX >= 0x03070000 && !defined(PyEval_ThreadsInitialized) +#define PyEval_ThreadsInitialized() 1 +#endif + + +#include "awpygo_go.h" +/* --- module functions --- */ + + +PyObject * +_wrap__awpygo_GoPyInit(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + + GoPyInit(); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_GoPyInit(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_DecRef(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + DecRef(handle); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_DecRef(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_IncRef(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + IncRef(handle); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_IncRef(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_NumHandles(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int retval; + + retval = NumHandles(); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_NumHandles(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_bool_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_bool_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_bool_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_bool_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_bool_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + bool retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_bool_elem(handle, idx); + py_retval = Py_BuildValue((char *) "N", PyBool_FromLong(retval)); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_bool_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_bool_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_bool_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + bool value; + PyObject *py_value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiO", (char **) keywords, &handle, &idx, &py_value)) { + return NULL; + } + value = (bool) PyObject_IsTrue(py_value); + Slice_bool_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_bool_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + bool value; + PyObject *py_value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LO", (char **) keywords, &handle, &py_value)) { + return NULL; + } + value = (bool) PyObject_IsTrue(py_value); + Slice_bool_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_bool_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_byte_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_byte_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_byte_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_byte_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_byte_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint8_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_byte_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", (int)retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_byte_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_byte_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_byte_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + if (value > 0xff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_byte_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_byte_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + if (value > 0xff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_byte_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_byte_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_error_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_error_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_error_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_error_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_error_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + char *retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_error_elem(handle, idx); + py_retval = Py_BuildValue((char *) "s", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_error_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_error_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_error_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + char *value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lis", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_error_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_error_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + char *value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Ls", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_error_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_error_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_float32_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_float32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_float32_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + float retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_float32_elem(handle, idx); + py_retval = Py_BuildValue((char *) "f", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_float32_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + float value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lif", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_float32_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + float value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lf", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_float32_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_float64_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_float64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_float64_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + double retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_float64_elem(handle, idx); + py_retval = Py_BuildValue((char *) "d", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_float64_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + double value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lid", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_float64_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_float64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + double value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Ld", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_float64_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_float64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_int_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_int_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_int_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_int_elem(handle, idx); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_int_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int64_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiL", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_int_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int64_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LL", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_int_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int16_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_int16_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_int16_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_int16_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int16_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int16_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_int16_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int16_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_int16_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int16_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + if (value > 0x7fff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_int16_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int16_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + if (value > 0x7fff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_int16_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int16_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_int32_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_int32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_int32_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int32_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_int32_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_int32_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int32_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_int32_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int32_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_int32_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_int64_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_int64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_int64_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_int64_elem(handle, idx); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_int64_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int64_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiL", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_int64_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int64_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LL", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_int64_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int8_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_int8_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_int8_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_int8_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int8_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int8_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_int8_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int8_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_int8_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int8_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + if (value > 0x7f) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_int8_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_int8_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + if (value > 0x7f) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_int8_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_int8_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_rune_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_rune_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_rune_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_rune_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_rune_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int32_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_rune_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_rune_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_rune_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_rune_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int32_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_rune_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_rune_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int32_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_rune_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_rune_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_string_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_string_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_string_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_string_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_string_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + char *retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_string_elem(handle, idx); + py_retval = Py_BuildValue((char *) "s", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_string_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_string_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_string_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + char *value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lis", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_string_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_string_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + char *value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Ls", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_string_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_string_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_uint_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_uint_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_uint_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint64_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_uint_elem(handle, idx); + py_retval = Py_BuildValue((char *) "K", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_uint_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + uint64_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiK", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_uint_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + uint64_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LK", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_uint_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint16_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_uint16_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_uint16_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_uint16_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint16_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint16_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_uint16_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint16_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_uint16_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint16_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + if (value > 0xffff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_uint16_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint16_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + if (value > 0xffff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_uint16_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint16_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_uint32_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_uint32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_uint32_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint32_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_uint32_elem(handle, idx); + py_retval = Py_BuildValue((char *) "N", PyLong_FromUnsignedLong(retval)); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_uint32_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + unsigned int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiI", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_uint32_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + unsigned int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LI", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_uint32_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint32_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_uint64_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_uint64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_uint64_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint64_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_uint64_elem(handle, idx); + py_retval = Py_BuildValue((char *) "K", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_uint64_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + uint64_t value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LiK", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + Slice_uint64_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + uint64_t value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "LK", (char **) keywords, &handle, &value)) { + return NULL; + } + Slice_uint64_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint64_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint8_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)) +{ + PyObject *py_retval; + int64_t retval; + + retval = Slice_uint8_CTor(); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_CTor(PyObject *PYBINDGEN_UNUSED(_args), PyObject *PYBINDGEN_UNUSED(_kwargs)); + + +PyObject * +_wrap__awpygo_Slice_uint8_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int retval; + int64_t handle; + const char *keywords[] = {"handle", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "L", (char **) keywords, &handle)) { + return NULL; + } + retval = Slice_uint8_len(handle); + py_retval = Py_BuildValue((char *) "i", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_len(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint8_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + uint8_t retval; + int64_t handle; + int idx; + const char *keywords[] = {"handle", "idx", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &idx)) { + return NULL; + } + retval = Slice_uint8_elem(handle, idx); + py_retval = Py_BuildValue((char *) "i", (int)retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_elem(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint8_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t retval; + int64_t handle; + int st; + int ed; + const char *keywords[] = {"handle", "st", "ed", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &st, &ed)) { + return NULL; + } + retval = Slice_uint8_subslice(handle, st, ed); + py_retval = Py_BuildValue((char *) "L", retval); + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_subslice(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint8_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int idx; + int value; + const char *keywords[] = {"handle", "idx", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Lii", (char **) keywords, &handle, &idx, &value)) { + return NULL; + } + if (value > 0xff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_uint8_set(handle, idx, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_set(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_Slice_uint8_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + int64_t handle; + int value; + const char *keywords[] = {"handle", "value", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "Li", (char **) keywords, &handle, &value)) { + return NULL; + } + if (value > 0xff) { + PyErr_SetString(PyExc_ValueError, "Out of range"); + return NULL; + } + Slice_uint8_append(handle, value); + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_Slice_uint8_append(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + + +PyObject * +_wrap__awpygo_awpygo_ParseDemo(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs) +{ + PyObject *py_retval; + char *demPath; + char *demoID; + int64_t parseRate; + bool parseFrames; + PyObject *py_parseFrames; + bool parseKillFrames; + PyObject *py_parseKillFrames; + int64_t tradeTime; + char *roundBuyStyle; + bool damagesRolled; + PyObject *py_damagesRolled; + bool jsonIndentation; + PyObject *py_jsonIndentation; + bool parseChat; + PyObject *py_parseChat; + char *outpath; + bool goRun; + PyObject *py_goRun; + const char *keywords[] = {"demPath", "demoID", "parseRate", "parseFrames", "parseKillFrames", "tradeTime", "roundBuyStyle", "damagesRolled", "jsonIndentation", "parseChat", "outpath", "goRun", NULL}; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ssLOOLsOOOsO", (char **) keywords, &demPath, &demoID, &parseRate, &py_parseFrames, &py_parseKillFrames, &tradeTime, &roundBuyStyle, &py_damagesRolled, &py_jsonIndentation, &py_parseChat, &outpath, &py_goRun)) { + return NULL; + } + parseFrames = (bool) PyObject_IsTrue(py_parseFrames); + parseKillFrames = (bool) PyObject_IsTrue(py_parseKillFrames); + damagesRolled = (bool) PyObject_IsTrue(py_damagesRolled); + jsonIndentation = (bool) PyObject_IsTrue(py_jsonIndentation); + parseChat = (bool) PyObject_IsTrue(py_parseChat); + goRun = (bool) PyObject_IsTrue(py_goRun); + awpygo_ParseDemo(demPath, demoID, parseRate, parseFrames, parseKillFrames, tradeTime, roundBuyStyle, damagesRolled, jsonIndentation, parseChat, outpath, goRun); + if (PyErr_Occurred()) { + return NULL; + } + Py_INCREF(Py_None); + py_retval = Py_None; + return py_retval; +} +PyObject * _wrap__awpygo_awpygo_ParseDemo(PyObject * PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs); + +static PyMethodDef _awpygo_functions[] = { + {(char *) "GoPyInit", (PyCFunction) _wrap__awpygo_GoPyInit, METH_NOARGS, "GoPyInit()\n\n" }, + {(char *) "DecRef", (PyCFunction) _wrap__awpygo_DecRef, METH_KEYWORDS|METH_VARARGS, "DecRef(handle)\n\ntype: handle: int64_t" }, + {(char *) "IncRef", (PyCFunction) _wrap__awpygo_IncRef, METH_KEYWORDS|METH_VARARGS, "IncRef(handle)\n\ntype: handle: int64_t" }, + {(char *) "NumHandles", (PyCFunction) _wrap__awpygo_NumHandles, METH_NOARGS, "NumHandles()\n\n" }, + {(char *) "Slice_bool_CTor", (PyCFunction) _wrap__awpygo_Slice_bool_CTor, METH_NOARGS, "Slice_bool_CTor()\n\n" }, + {(char *) "Slice_bool_len", (PyCFunction) _wrap__awpygo_Slice_bool_len, METH_KEYWORDS|METH_VARARGS, "Slice_bool_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_bool_elem", (PyCFunction) _wrap__awpygo_Slice_bool_elem, METH_KEYWORDS|METH_VARARGS, "Slice_bool_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_bool_subslice", (PyCFunction) _wrap__awpygo_Slice_bool_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_bool_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_bool_set", (PyCFunction) _wrap__awpygo_Slice_bool_set, METH_KEYWORDS|METH_VARARGS, "Slice_bool_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: bool" }, + {(char *) "Slice_bool_append", (PyCFunction) _wrap__awpygo_Slice_bool_append, METH_KEYWORDS|METH_VARARGS, "Slice_bool_append(handle, value)\n\ntype: handle: int64_t\ntype: value: bool" }, + {(char *) "Slice_byte_CTor", (PyCFunction) _wrap__awpygo_Slice_byte_CTor, METH_NOARGS, "Slice_byte_CTor()\n\n" }, + {(char *) "Slice_byte_len", (PyCFunction) _wrap__awpygo_Slice_byte_len, METH_KEYWORDS|METH_VARARGS, "Slice_byte_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_byte_elem", (PyCFunction) _wrap__awpygo_Slice_byte_elem, METH_KEYWORDS|METH_VARARGS, "Slice_byte_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_byte_subslice", (PyCFunction) _wrap__awpygo_Slice_byte_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_byte_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_byte_set", (PyCFunction) _wrap__awpygo_Slice_byte_set, METH_KEYWORDS|METH_VARARGS, "Slice_byte_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint8_t" }, + {(char *) "Slice_byte_append", (PyCFunction) _wrap__awpygo_Slice_byte_append, METH_KEYWORDS|METH_VARARGS, "Slice_byte_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint8_t" }, + {(char *) "Slice_error_CTor", (PyCFunction) _wrap__awpygo_Slice_error_CTor, METH_NOARGS, "Slice_error_CTor()\n\n" }, + {(char *) "Slice_error_len", (PyCFunction) _wrap__awpygo_Slice_error_len, METH_KEYWORDS|METH_VARARGS, "Slice_error_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_error_elem", (PyCFunction) _wrap__awpygo_Slice_error_elem, METH_KEYWORDS|METH_VARARGS, "Slice_error_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_error_subslice", (PyCFunction) _wrap__awpygo_Slice_error_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_error_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_error_set", (PyCFunction) _wrap__awpygo_Slice_error_set, METH_KEYWORDS|METH_VARARGS, "Slice_error_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: char *" }, + {(char *) "Slice_error_append", (PyCFunction) _wrap__awpygo_Slice_error_append, METH_KEYWORDS|METH_VARARGS, "Slice_error_append(handle, value)\n\ntype: handle: int64_t\ntype: value: char *" }, + {(char *) "Slice_float32_CTor", (PyCFunction) _wrap__awpygo_Slice_float32_CTor, METH_NOARGS, "Slice_float32_CTor()\n\n" }, + {(char *) "Slice_float32_len", (PyCFunction) _wrap__awpygo_Slice_float32_len, METH_KEYWORDS|METH_VARARGS, "Slice_float32_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_float32_elem", (PyCFunction) _wrap__awpygo_Slice_float32_elem, METH_KEYWORDS|METH_VARARGS, "Slice_float32_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_float32_subslice", (PyCFunction) _wrap__awpygo_Slice_float32_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_float32_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_float32_set", (PyCFunction) _wrap__awpygo_Slice_float32_set, METH_KEYWORDS|METH_VARARGS, "Slice_float32_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: float" }, + {(char *) "Slice_float32_append", (PyCFunction) _wrap__awpygo_Slice_float32_append, METH_KEYWORDS|METH_VARARGS, "Slice_float32_append(handle, value)\n\ntype: handle: int64_t\ntype: value: float" }, + {(char *) "Slice_float64_CTor", (PyCFunction) _wrap__awpygo_Slice_float64_CTor, METH_NOARGS, "Slice_float64_CTor()\n\n" }, + {(char *) "Slice_float64_len", (PyCFunction) _wrap__awpygo_Slice_float64_len, METH_KEYWORDS|METH_VARARGS, "Slice_float64_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_float64_elem", (PyCFunction) _wrap__awpygo_Slice_float64_elem, METH_KEYWORDS|METH_VARARGS, "Slice_float64_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_float64_subslice", (PyCFunction) _wrap__awpygo_Slice_float64_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_float64_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_float64_set", (PyCFunction) _wrap__awpygo_Slice_float64_set, METH_KEYWORDS|METH_VARARGS, "Slice_float64_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: double" }, + {(char *) "Slice_float64_append", (PyCFunction) _wrap__awpygo_Slice_float64_append, METH_KEYWORDS|METH_VARARGS, "Slice_float64_append(handle, value)\n\ntype: handle: int64_t\ntype: value: double" }, + {(char *) "Slice_int_CTor", (PyCFunction) _wrap__awpygo_Slice_int_CTor, METH_NOARGS, "Slice_int_CTor()\n\n" }, + {(char *) "Slice_int_len", (PyCFunction) _wrap__awpygo_Slice_int_len, METH_KEYWORDS|METH_VARARGS, "Slice_int_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_int_elem", (PyCFunction) _wrap__awpygo_Slice_int_elem, METH_KEYWORDS|METH_VARARGS, "Slice_int_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_int_subslice", (PyCFunction) _wrap__awpygo_Slice_int_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_int_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_int_set", (PyCFunction) _wrap__awpygo_Slice_int_set, METH_KEYWORDS|METH_VARARGS, "Slice_int_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int64_t" }, + {(char *) "Slice_int_append", (PyCFunction) _wrap__awpygo_Slice_int_append, METH_KEYWORDS|METH_VARARGS, "Slice_int_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int64_t" }, + {(char *) "Slice_int16_CTor", (PyCFunction) _wrap__awpygo_Slice_int16_CTor, METH_NOARGS, "Slice_int16_CTor()\n\n" }, + {(char *) "Slice_int16_len", (PyCFunction) _wrap__awpygo_Slice_int16_len, METH_KEYWORDS|METH_VARARGS, "Slice_int16_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_int16_elem", (PyCFunction) _wrap__awpygo_Slice_int16_elem, METH_KEYWORDS|METH_VARARGS, "Slice_int16_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_int16_subslice", (PyCFunction) _wrap__awpygo_Slice_int16_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_int16_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_int16_set", (PyCFunction) _wrap__awpygo_Slice_int16_set, METH_KEYWORDS|METH_VARARGS, "Slice_int16_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int16_t" }, + {(char *) "Slice_int16_append", (PyCFunction) _wrap__awpygo_Slice_int16_append, METH_KEYWORDS|METH_VARARGS, "Slice_int16_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int16_t" }, + {(char *) "Slice_int32_CTor", (PyCFunction) _wrap__awpygo_Slice_int32_CTor, METH_NOARGS, "Slice_int32_CTor()\n\n" }, + {(char *) "Slice_int32_len", (PyCFunction) _wrap__awpygo_Slice_int32_len, METH_KEYWORDS|METH_VARARGS, "Slice_int32_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_int32_elem", (PyCFunction) _wrap__awpygo_Slice_int32_elem, METH_KEYWORDS|METH_VARARGS, "Slice_int32_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_int32_subslice", (PyCFunction) _wrap__awpygo_Slice_int32_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_int32_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_int32_set", (PyCFunction) _wrap__awpygo_Slice_int32_set, METH_KEYWORDS|METH_VARARGS, "Slice_int32_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int32_t" }, + {(char *) "Slice_int32_append", (PyCFunction) _wrap__awpygo_Slice_int32_append, METH_KEYWORDS|METH_VARARGS, "Slice_int32_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int32_t" }, + {(char *) "Slice_int64_CTor", (PyCFunction) _wrap__awpygo_Slice_int64_CTor, METH_NOARGS, "Slice_int64_CTor()\n\n" }, + {(char *) "Slice_int64_len", (PyCFunction) _wrap__awpygo_Slice_int64_len, METH_KEYWORDS|METH_VARARGS, "Slice_int64_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_int64_elem", (PyCFunction) _wrap__awpygo_Slice_int64_elem, METH_KEYWORDS|METH_VARARGS, "Slice_int64_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_int64_subslice", (PyCFunction) _wrap__awpygo_Slice_int64_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_int64_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_int64_set", (PyCFunction) _wrap__awpygo_Slice_int64_set, METH_KEYWORDS|METH_VARARGS, "Slice_int64_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int64_t" }, + {(char *) "Slice_int64_append", (PyCFunction) _wrap__awpygo_Slice_int64_append, METH_KEYWORDS|METH_VARARGS, "Slice_int64_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int64_t" }, + {(char *) "Slice_int8_CTor", (PyCFunction) _wrap__awpygo_Slice_int8_CTor, METH_NOARGS, "Slice_int8_CTor()\n\n" }, + {(char *) "Slice_int8_len", (PyCFunction) _wrap__awpygo_Slice_int8_len, METH_KEYWORDS|METH_VARARGS, "Slice_int8_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_int8_elem", (PyCFunction) _wrap__awpygo_Slice_int8_elem, METH_KEYWORDS|METH_VARARGS, "Slice_int8_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_int8_subslice", (PyCFunction) _wrap__awpygo_Slice_int8_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_int8_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_int8_set", (PyCFunction) _wrap__awpygo_Slice_int8_set, METH_KEYWORDS|METH_VARARGS, "Slice_int8_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int8_t" }, + {(char *) "Slice_int8_append", (PyCFunction) _wrap__awpygo_Slice_int8_append, METH_KEYWORDS|METH_VARARGS, "Slice_int8_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int8_t" }, + {(char *) "Slice_rune_CTor", (PyCFunction) _wrap__awpygo_Slice_rune_CTor, METH_NOARGS, "Slice_rune_CTor()\n\n" }, + {(char *) "Slice_rune_len", (PyCFunction) _wrap__awpygo_Slice_rune_len, METH_KEYWORDS|METH_VARARGS, "Slice_rune_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_rune_elem", (PyCFunction) _wrap__awpygo_Slice_rune_elem, METH_KEYWORDS|METH_VARARGS, "Slice_rune_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_rune_subslice", (PyCFunction) _wrap__awpygo_Slice_rune_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_rune_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_rune_set", (PyCFunction) _wrap__awpygo_Slice_rune_set, METH_KEYWORDS|METH_VARARGS, "Slice_rune_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: int32_t" }, + {(char *) "Slice_rune_append", (PyCFunction) _wrap__awpygo_Slice_rune_append, METH_KEYWORDS|METH_VARARGS, "Slice_rune_append(handle, value)\n\ntype: handle: int64_t\ntype: value: int32_t" }, + {(char *) "Slice_string_CTor", (PyCFunction) _wrap__awpygo_Slice_string_CTor, METH_NOARGS, "Slice_string_CTor()\n\n" }, + {(char *) "Slice_string_len", (PyCFunction) _wrap__awpygo_Slice_string_len, METH_KEYWORDS|METH_VARARGS, "Slice_string_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_string_elem", (PyCFunction) _wrap__awpygo_Slice_string_elem, METH_KEYWORDS|METH_VARARGS, "Slice_string_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_string_subslice", (PyCFunction) _wrap__awpygo_Slice_string_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_string_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_string_set", (PyCFunction) _wrap__awpygo_Slice_string_set, METH_KEYWORDS|METH_VARARGS, "Slice_string_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: char *" }, + {(char *) "Slice_string_append", (PyCFunction) _wrap__awpygo_Slice_string_append, METH_KEYWORDS|METH_VARARGS, "Slice_string_append(handle, value)\n\ntype: handle: int64_t\ntype: value: char *" }, + {(char *) "Slice_uint_CTor", (PyCFunction) _wrap__awpygo_Slice_uint_CTor, METH_NOARGS, "Slice_uint_CTor()\n\n" }, + {(char *) "Slice_uint_len", (PyCFunction) _wrap__awpygo_Slice_uint_len, METH_KEYWORDS|METH_VARARGS, "Slice_uint_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_uint_elem", (PyCFunction) _wrap__awpygo_Slice_uint_elem, METH_KEYWORDS|METH_VARARGS, "Slice_uint_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_uint_subslice", (PyCFunction) _wrap__awpygo_Slice_uint_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_uint_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_uint_set", (PyCFunction) _wrap__awpygo_Slice_uint_set, METH_KEYWORDS|METH_VARARGS, "Slice_uint_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint64_t" }, + {(char *) "Slice_uint_append", (PyCFunction) _wrap__awpygo_Slice_uint_append, METH_KEYWORDS|METH_VARARGS, "Slice_uint_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint64_t" }, + {(char *) "Slice_uint16_CTor", (PyCFunction) _wrap__awpygo_Slice_uint16_CTor, METH_NOARGS, "Slice_uint16_CTor()\n\n" }, + {(char *) "Slice_uint16_len", (PyCFunction) _wrap__awpygo_Slice_uint16_len, METH_KEYWORDS|METH_VARARGS, "Slice_uint16_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_uint16_elem", (PyCFunction) _wrap__awpygo_Slice_uint16_elem, METH_KEYWORDS|METH_VARARGS, "Slice_uint16_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_uint16_subslice", (PyCFunction) _wrap__awpygo_Slice_uint16_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_uint16_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_uint16_set", (PyCFunction) _wrap__awpygo_Slice_uint16_set, METH_KEYWORDS|METH_VARARGS, "Slice_uint16_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint16_t" }, + {(char *) "Slice_uint16_append", (PyCFunction) _wrap__awpygo_Slice_uint16_append, METH_KEYWORDS|METH_VARARGS, "Slice_uint16_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint16_t" }, + {(char *) "Slice_uint32_CTor", (PyCFunction) _wrap__awpygo_Slice_uint32_CTor, METH_NOARGS, "Slice_uint32_CTor()\n\n" }, + {(char *) "Slice_uint32_len", (PyCFunction) _wrap__awpygo_Slice_uint32_len, METH_KEYWORDS|METH_VARARGS, "Slice_uint32_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_uint32_elem", (PyCFunction) _wrap__awpygo_Slice_uint32_elem, METH_KEYWORDS|METH_VARARGS, "Slice_uint32_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_uint32_subslice", (PyCFunction) _wrap__awpygo_Slice_uint32_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_uint32_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_uint32_set", (PyCFunction) _wrap__awpygo_Slice_uint32_set, METH_KEYWORDS|METH_VARARGS, "Slice_uint32_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint32_t" }, + {(char *) "Slice_uint32_append", (PyCFunction) _wrap__awpygo_Slice_uint32_append, METH_KEYWORDS|METH_VARARGS, "Slice_uint32_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint32_t" }, + {(char *) "Slice_uint64_CTor", (PyCFunction) _wrap__awpygo_Slice_uint64_CTor, METH_NOARGS, "Slice_uint64_CTor()\n\n" }, + {(char *) "Slice_uint64_len", (PyCFunction) _wrap__awpygo_Slice_uint64_len, METH_KEYWORDS|METH_VARARGS, "Slice_uint64_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_uint64_elem", (PyCFunction) _wrap__awpygo_Slice_uint64_elem, METH_KEYWORDS|METH_VARARGS, "Slice_uint64_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_uint64_subslice", (PyCFunction) _wrap__awpygo_Slice_uint64_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_uint64_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_uint64_set", (PyCFunction) _wrap__awpygo_Slice_uint64_set, METH_KEYWORDS|METH_VARARGS, "Slice_uint64_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint64_t" }, + {(char *) "Slice_uint64_append", (PyCFunction) _wrap__awpygo_Slice_uint64_append, METH_KEYWORDS|METH_VARARGS, "Slice_uint64_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint64_t" }, + {(char *) "Slice_uint8_CTor", (PyCFunction) _wrap__awpygo_Slice_uint8_CTor, METH_NOARGS, "Slice_uint8_CTor()\n\n" }, + {(char *) "Slice_uint8_len", (PyCFunction) _wrap__awpygo_Slice_uint8_len, METH_KEYWORDS|METH_VARARGS, "Slice_uint8_len(handle)\n\ntype: handle: int64_t" }, + {(char *) "Slice_uint8_elem", (PyCFunction) _wrap__awpygo_Slice_uint8_elem, METH_KEYWORDS|METH_VARARGS, "Slice_uint8_elem(handle, idx)\n\ntype: handle: int64_t\ntype: idx: int" }, + {(char *) "Slice_uint8_subslice", (PyCFunction) _wrap__awpygo_Slice_uint8_subslice, METH_KEYWORDS|METH_VARARGS, "Slice_uint8_subslice(handle, st, ed)\n\ntype: handle: int64_t\ntype: st: int\ntype: ed: int" }, + {(char *) "Slice_uint8_set", (PyCFunction) _wrap__awpygo_Slice_uint8_set, METH_KEYWORDS|METH_VARARGS, "Slice_uint8_set(handle, idx, value)\n\ntype: handle: int64_t\ntype: idx: int\ntype: value: uint8_t" }, + {(char *) "Slice_uint8_append", (PyCFunction) _wrap__awpygo_Slice_uint8_append, METH_KEYWORDS|METH_VARARGS, "Slice_uint8_append(handle, value)\n\ntype: handle: int64_t\ntype: value: uint8_t" }, + {(char *) "awpygo_ParseDemo", (PyCFunction) _wrap__awpygo_awpygo_ParseDemo, METH_KEYWORDS|METH_VARARGS, "awpygo_ParseDemo(demPath, demoID, parseRate, parseFrames, parseKillFrames, tradeTime, roundBuyStyle, damagesRolled, jsonIndentation, parseChat, outpath, goRun)\n\ntype: demPath: char *\ntype: demoID: char *\ntype: parseRate: int64_t\ntype: parseFrames: bool\ntype: parseKillFrames: bool\ntype: tradeTime: int64_t\ntype: roundBuyStyle: char *\ntype: damagesRolled: bool\ntype: jsonIndentation: bool\ntype: parseChat: bool\ntype: outpath: char *\ntype: goRun: bool" }, + {NULL, NULL, 0, NULL} +}; +#if PY_VERSION_HEX >= 0x03000000 +static struct PyModuleDef _awpygo_moduledef = { + PyModuleDef_HEAD_INIT, + "_awpygo", + NULL, + -1, + _awpygo_functions, +}; +#endif + + +#if PY_VERSION_HEX >= 0x03000000 + #define MOD_ERROR NULL + #define MOD_INIT(name) PyObject* __declspec(dllexport) PyInit_##name(void) + #define MOD_RETURN(val) val +#else + #define MOD_ERROR + #define MOD_INIT(name) void init##name(void) + #define MOD_RETURN(val) +#endif +#if defined(__cplusplus) +extern "C" +#endif +#if defined(__GNUC__) && __GNUC__ >= 4 +__attribute__ ((visibility("default"))) +#endif + + +MOD_INIT(_awpygo) +{ + PyObject *m; + #if PY_VERSION_HEX >= 0x03000000 + m = PyModule_Create(&_awpygo_moduledef); + #else + m = Py_InitModule3((char *) "_awpygo", _awpygo_functions, NULL); + #endif + if (m == NULL) { + return MOD_ERROR; + } + return MOD_RETURN(m); +} diff --git a/awpy/parser/awpygo/awpygo.go b/awpy/parser/awpygo/awpygo.go new file mode 100644 index 000000000..bcd7d1cef --- /dev/null +++ b/awpy/parser/awpygo/awpygo.go @@ -0,0 +1,1129 @@ +/* +cgo stubs for package awpygo. +File is generated by gopy. Do not edit. +gopy.exe pkg -output=awpygo -vm=python github.com/pnxenopoulos/awpygo +*/ + +package main + +/* + +#cgo CFLAGS: -IC:/Users/Jan-Eric/AppData/Local/Programs/Python/Python311/include -Wno-error -Wno-implicit-function-declaration -Wno-int-conversion +#cgo LDFLAGS: -LC:/Users/Jan-Eric/AppData/Local/Programs/Python/Python311/libs -lpython311 + +// #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 ( + "errors" + + "github.com/go-python/gopy/gopyh" // handler + + "github.com/pnxenopoulos/awpygo" +) + +// 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)) +} + +// errorGoToPy converts a Go error to python-compatible C.CString +func errorGoToPy(e error) *C.char { + if e != nil { + return C.CString(e.Error()) + } + return C.CString("") +} + +// --- generated code for package: awpygo 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: []error +func ptrFromHandle_Slice_error(h CGoHandle) *[]error { + p := gopyh.VarFromHandle((gopyh.CGoHandle)(h), "[]error") + if p == nil { + return nil + } + return p.(*[]error) +} +func deptrFromHandle_Slice_error(h CGoHandle) []error { + p := ptrFromHandle_Slice_error(h) + if p == nil { + return nil + } + return *p +} +func handleFromPtr_Slice_error(p interface{}) CGoHandle { + return CGoHandle(gopyh.Register("[]error", p)) +} + +// --- wrapping slice: []error --- +// +//export Slice_error_CTor +func Slice_error_CTor() CGoHandle { + return CGoHandle(handleFromPtr_Slice_error(&[]error{})) +} + +//export Slice_error_len +func Slice_error_len(handle CGoHandle) int { + return len(deptrFromHandle_Slice_error(handle)) +} + +//export Slice_error_elem +func Slice_error_elem(handle CGoHandle, _idx int) *C.char { + s := deptrFromHandle_Slice_error(handle) + return errorGoToPy(s[_idx]) +} + +//export Slice_error_subslice +func Slice_error_subslice(handle CGoHandle, _st, _ed int) CGoHandle { + s := deptrFromHandle_Slice_error(handle) + ss := s[_st:_ed] + return CGoHandle(handleFromPtr_Slice_error(&ss)) +} + +//export Slice_error_set +func Slice_error_set(handle CGoHandle, _idx int, _vl *C.char) { + s := deptrFromHandle_Slice_error(handle) + s[_idx] = errors.New(C.GoString(_vl)) +} + +//export Slice_error_append +func Slice_error_append(handle CGoHandle, _vl *C.char) { + s := ptrFromHandle_Slice_error(handle) + *s = append(*s, errors.New(C.GoString(_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: awpygo --- + +// ---- Types --- + +// ---- Global Variables: can only use functions to access --- + +// ---- Interfaces --- + +// ---- Structs --- + +// ---- Slices --- + +// ---- Maps --- + +// ---- Constructors --- + +// ---- Functions --- + +//export awpygo_ParseDemo +func awpygo_ParseDemo(demPath *C.char, demoID *C.char, parseRate C.longlong, parseFrames C.char, parseKillFrames C.char, tradeTime C.longlong, roundBuyStyle *C.char, damagesRolled C.char, jsonIndentation C.char, parseChat C.char, outpath *C.char, goRun C.char) { + _saved_thread := C.PyEval_SaveThread() + defer C.PyEval_RestoreThread(_saved_thread) + if boolPyToGo(goRun) { + go awpygo.ParseDemo(C.GoString(demPath), C.GoString(demoID), int(parseRate), boolPyToGo(parseFrames), boolPyToGo(parseKillFrames), int64(tradeTime), C.GoString(roundBuyStyle), boolPyToGo(damagesRolled), boolPyToGo(jsonIndentation), boolPyToGo(parseChat), C.GoString(outpath)) + } else { + awpygo.ParseDemo(C.GoString(demPath), C.GoString(demoID), int(parseRate), boolPyToGo(parseFrames), boolPyToGo(parseKillFrames), int64(tradeTime), C.GoString(roundBuyStyle), boolPyToGo(damagesRolled), boolPyToGo(jsonIndentation), boolPyToGo(parseChat), C.GoString(outpath)) + } +} diff --git a/awpy/parser/awpygo/awpygo.py b/awpy/parser/awpygo/awpygo.py new file mode 100644 index 000000000..0bce3bf4f --- /dev/null +++ b/awpy/parser/awpygo/awpygo.py @@ -0,0 +1,84 @@ +# python wrapper for package github.com/pnxenopoulos/awpygo within overall package awpygo +# This is what you import to use the package. +# File is generated by gopy. Do not edit. +# gopy.exe pkg -output=awpygo -vm=python github.com/pnxenopoulos/awpygo + +# the following is required to enable dlopen to open the _go.so file +import collections +import inspect +import os + +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 _awpygo + +os.chdir(cwd) + +# to use this code in your end-user python file, import it as follows: +# and then refer to everything using awpygo. prefix +# packages imported by this package listed below: + + +# ---- Types --- + + +# ---- 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 --- + + +# ---- Slices --- + + +# ---- Maps --- + + +# ---- Constructors --- + + +# ---- Functions --- +def ParseDemo( + demPath, + demoID, + parseRate, + parseFrames, + parseKillFrames, + tradeTime, + roundBuyStyle, + damagesRolled, + jsonIndentation, + parseChat, + outpath, + goRun=False, +): + """ParseDemo(str demPath, str demoID, int parseRate, bool parseFrames, bool parseKillFrames, long tradeTime, str roundBuyStyle, bool damagesRolled, bool jsonIndentation, bool parseChat, str outpath).""" + _awpygo.awpygo_ParseDemo( + demPath, + demoID, + parseRate, + parseFrames, + parseKillFrames, + tradeTime, + roundBuyStyle, + damagesRolled, + jsonIndentation, + parseChat, + outpath, + goRun, + ) diff --git a/awpy/parser/awpygo/awpygo_go.h b/awpy/parser/awpygo/awpygo_go.h new file mode 100644 index 000000000..ed66e4d71 --- /dev/null +++ b/awpy/parser/awpygo/awpygo_go.h @@ -0,0 +1,292 @@ +/* Code generated by cmd/cgo; DO NOT EDIT. */ + +/* package github.com/pnxenopoulos/awpygo/awpygo/awpygo */ + + +#line 1 "cgo-builtin-export-prolog" + +#include + +#ifndef GO_CGO_EXPORT_PROLOGUE_H +#define GO_CGO_EXPORT_PROLOGUE_H + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef struct { const char *p; ptrdiff_t n; } _GoString_; +#endif + +#endif + +/* Start of preamble from import "C" comments. */ + + +#line 9 "awpygo.go" + + + + + +// #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(); + } +} + + +#line 1 "cgo-generated-wrapper" + + +/* End of preamble from import "C" comments. */ + + +/* Start of boilerplate cgo prologue. */ +#line 1 "cgo-gcc-export-header-prolog" + +#ifndef GO_CGO_PROLOGUE_H +#define GO_CGO_PROLOGUE_H + +typedef signed char GoInt8; +typedef unsigned char GoUint8; +typedef short GoInt16; +typedef unsigned short GoUint16; +typedef int GoInt32; +typedef unsigned int GoUint32; +typedef long long GoInt64; +typedef unsigned long long GoUint64; +typedef GoInt64 GoInt; +typedef GoUint64 GoUint; +typedef size_t GoUintptr; +typedef float GoFloat32; +typedef double GoFloat64; +#ifdef _MSC_VER +#include +typedef _Fcomplex GoComplex64; +typedef _Dcomplex GoComplex128; +#else +typedef float _Complex GoComplex64; +typedef double _Complex GoComplex128; +#endif + +/* + static assertion to make sure the file is being used on architecture + at least with matching size of GoInt. +*/ +typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1]; + +#ifndef GO_CGO_GOSTRING_TYPEDEF +typedef _GoString_ GoString; +#endif +typedef void *GoMap; +typedef void *GoChan; +typedef struct { void *t; void *v; } GoInterface; +typedef struct { void *data; GoInt len; GoInt cap; } GoSlice; + +#endif + +/* End of boilerplate cgo prologue. */ + +#ifdef __cplusplus +extern "C" { +#endif + +extern __declspec(dllexport) void GoPyInit(); + +// DecRef decrements the reference count for the specified handle +// and deletes it it goes to zero. +// +extern __declspec(dllexport) void DecRef(long long int handle); + +// IncRef increments the reference count for the specified handle. +// +extern __declspec(dllexport) void IncRef(long long int handle); + +// NumHandles returns the number of handles currently in use. +// +extern __declspec(dllexport) GoInt NumHandles(); + +// --- wrapping slice: []bool --- +// +extern __declspec(dllexport) long long int Slice_bool_CTor(); +extern __declspec(dllexport) GoInt Slice_bool_len(long long int handle); +extern __declspec(dllexport) char Slice_bool_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_bool_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_bool_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_bool_append(long long int handle, char _vl); + +// --- wrapping slice: []byte --- +// +extern __declspec(dllexport) long long int Slice_byte_CTor(); +extern __declspec(dllexport) GoInt Slice_byte_len(long long int handle); +extern __declspec(dllexport) char Slice_byte_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_byte_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_byte_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_byte_append(long long int handle, char _vl); + +// --- wrapping slice: []error --- +// +extern __declspec(dllexport) long long int Slice_error_CTor(); +extern __declspec(dllexport) GoInt Slice_error_len(long long int handle); +extern __declspec(dllexport) char* Slice_error_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_error_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_error_set(long long int handle, GoInt _idx, char* _vl); +extern __declspec(dllexport) void Slice_error_append(long long int handle, char* _vl); + +// --- wrapping slice: []float32 --- +// +extern __declspec(dllexport) long long int Slice_float32_CTor(); +extern __declspec(dllexport) GoInt Slice_float32_len(long long int handle); +extern __declspec(dllexport) float Slice_float32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_float32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_float32_set(long long int handle, GoInt _idx, float _vl); +extern __declspec(dllexport) void Slice_float32_append(long long int handle, float _vl); + +// --- wrapping slice: []float64 --- +// +extern __declspec(dllexport) long long int Slice_float64_CTor(); +extern __declspec(dllexport) GoInt Slice_float64_len(long long int handle); +extern __declspec(dllexport) double Slice_float64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_float64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_float64_set(long long int handle, GoInt _idx, double _vl); +extern __declspec(dllexport) void Slice_float64_append(long long int handle, double _vl); + +// --- wrapping slice: []int --- +// +extern __declspec(dllexport) long long int Slice_int_CTor(); +extern __declspec(dllexport) GoInt Slice_int_len(long long int handle); +extern __declspec(dllexport) long long int Slice_int_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int_set(long long int handle, GoInt _idx, long long int _vl); +extern __declspec(dllexport) void Slice_int_append(long long int handle, long long int _vl); + +// --- wrapping slice: []int16 --- +// +extern __declspec(dllexport) long long int Slice_int16_CTor(); +extern __declspec(dllexport) GoInt Slice_int16_len(long long int handle); +extern __declspec(dllexport) short int Slice_int16_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int16_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int16_set(long long int handle, GoInt _idx, short int _vl); +extern __declspec(dllexport) void Slice_int16_append(long long int handle, short int _vl); + +// --- wrapping slice: []int32 --- +// +extern __declspec(dllexport) long long int Slice_int32_CTor(); +extern __declspec(dllexport) GoInt Slice_int32_len(long long int handle); +extern __declspec(dllexport) long int Slice_int32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int32_set(long long int handle, GoInt _idx, long int _vl); +extern __declspec(dllexport) void Slice_int32_append(long long int handle, long int _vl); + +// --- wrapping slice: []int64 --- +// +extern __declspec(dllexport) long long int Slice_int64_CTor(); +extern __declspec(dllexport) GoInt Slice_int64_len(long long int handle); +extern __declspec(dllexport) long long int Slice_int64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int64_set(long long int handle, GoInt _idx, long long int _vl); +extern __declspec(dllexport) void Slice_int64_append(long long int handle, long long int _vl); + +// --- wrapping slice: []int8 --- +// +extern __declspec(dllexport) long long int Slice_int8_CTor(); +extern __declspec(dllexport) GoInt Slice_int8_len(long long int handle); +extern __declspec(dllexport) char Slice_int8_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_int8_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_int8_set(long long int handle, GoInt _idx, char _vl); +extern __declspec(dllexport) void Slice_int8_append(long long int handle, char _vl); + +// --- wrapping slice: []rune --- +// +extern __declspec(dllexport) long long int Slice_rune_CTor(); +extern __declspec(dllexport) GoInt Slice_rune_len(long long int handle); +extern __declspec(dllexport) long int Slice_rune_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_rune_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_rune_set(long long int handle, GoInt _idx, long int _vl); +extern __declspec(dllexport) void Slice_rune_append(long long int handle, long int _vl); + +// --- wrapping slice: []string --- +// +extern __declspec(dllexport) long long int Slice_string_CTor(); +extern __declspec(dllexport) GoInt Slice_string_len(long long int handle); +extern __declspec(dllexport) char* Slice_string_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_string_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_string_set(long long int handle, GoInt _idx, char* _vl); +extern __declspec(dllexport) void Slice_string_append(long long int handle, char* _vl); + +// --- wrapping slice: []uint --- +// +extern __declspec(dllexport) long long int Slice_uint_CTor(); +extern __declspec(dllexport) GoInt Slice_uint_len(long long int handle); +extern __declspec(dllexport) long long unsigned int Slice_uint_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint_set(long long int handle, GoInt _idx, long long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint_append(long long int handle, long long unsigned int _vl); + +// --- wrapping slice: []uint16 --- +// +extern __declspec(dllexport) long long int Slice_uint16_CTor(); +extern __declspec(dllexport) GoInt Slice_uint16_len(long long int handle); +extern __declspec(dllexport) short unsigned int Slice_uint16_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint16_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint16_set(long long int handle, GoInt _idx, short unsigned int _vl); +extern __declspec(dllexport) void Slice_uint16_append(long long int handle, short unsigned int _vl); + +// --- wrapping slice: []uint32 --- +// +extern __declspec(dllexport) long long int Slice_uint32_CTor(); +extern __declspec(dllexport) GoInt Slice_uint32_len(long long int handle); +extern __declspec(dllexport) long unsigned int Slice_uint32_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint32_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint32_set(long long int handle, GoInt _idx, long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint32_append(long long int handle, long unsigned int _vl); + +// --- wrapping slice: []uint64 --- +// +extern __declspec(dllexport) long long int Slice_uint64_CTor(); +extern __declspec(dllexport) GoInt Slice_uint64_len(long long int handle); +extern __declspec(dllexport) long long unsigned int Slice_uint64_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint64_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint64_set(long long int handle, GoInt _idx, long long unsigned int _vl); +extern __declspec(dllexport) void Slice_uint64_append(long long int handle, long long unsigned int _vl); + +// --- wrapping slice: []uint8 --- +// +extern __declspec(dllexport) long long int Slice_uint8_CTor(); +extern __declspec(dllexport) GoInt Slice_uint8_len(long long int handle); +extern __declspec(dllexport) unsigned char Slice_uint8_elem(long long int handle, GoInt _idx); +extern __declspec(dllexport) long long int Slice_uint8_subslice(long long int handle, GoInt _st, GoInt _ed); +extern __declspec(dllexport) void Slice_uint8_set(long long int handle, GoInt _idx, unsigned char _vl); +extern __declspec(dllexport) void Slice_uint8_append(long long int handle, unsigned char _vl); +extern __declspec(dllexport) void awpygo_ParseDemo(char* demPath, char* demoID, long long int parseRate, char parseFrames, char parseKillFrames, long long int tradeTime, char* roundBuyStyle, char damagesRolled, char jsonIndentation, char parseChat, char* outpath, char goRun); + +#ifdef __cplusplus +} +#endif diff --git a/awpy/parser/awpygo/build.py b/awpy/parser/awpygo/build.py new file mode 100644 index 000000000..27fc63391 --- /dev/null +++ b/awpy/parser/awpygo/build.py @@ -0,0 +1,418 @@ +# python build stubs for package awpygo +# File is generated by gopy. Do not edit. +# gopy.exe pkg -output=awpygo -vm=python github.com/pnxenopoulos/awpygo + + +from pybindgen import Function, Module, param, retval + + +class CheckedFunction(Function): + def __init__(self, *a, **kw) -> None: + super().__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().generate_call() + check = "PyErr_Occurred()" + if self._failure_expression: + check = f"{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("_awpygo") +mod.add_include('"awpygo_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_error_CTor", retval("int64_t"), []) +mod.add_function("Slice_error_len", retval("int"), [param("int64_t", "handle")]) +mod.add_function( + "Slice_error_elem", + retval("char*"), + [param("int64_t", "handle"), param("int", "idx")], +) +mod.add_function( + "Slice_error_subslice", + retval("int64_t"), + [param("int64_t", "handle"), param("int", "st"), param("int", "ed")], +) +mod.add_function( + "Slice_error_set", + None, + [param("int64_t", "handle"), param("int", "idx"), param("char*", "value")], +) +mod.add_function( + "Slice_error_append", None, [param("int64_t", "handle"), param("char*", "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")] +) +add_checked_function( + mod, + "awpygo_ParseDemo", + None, + [ + param("char*", "demPath"), + param("char*", "demoID"), + param("int64_t", "parseRate"), + param("bool", "parseFrames"), + param("bool", "parseKillFrames"), + param("int64_t", "tradeTime"), + param("char*", "roundBuyStyle"), + param("bool", "damagesRolled"), + param("bool", "jsonIndentation"), + param("bool", "parseChat"), + param("char*", "outpath"), + param("bool", "goRun"), + ], +) + +mod.generate(open("awpygo.c", "w")) diff --git a/awpy/parser/go.mod b/awpy/parser/awpygo/go.mod similarity index 79% rename from awpy/parser/go.mod rename to awpy/parser/awpygo/go.mod index 270b52316..16bafae81 100644 --- a/awpy/parser/go.mod +++ b/awpy/parser/awpygo/go.mod @@ -1,8 +1,11 @@ -module github.com/pnxenopoulos/csgo +module github.com/pnxenopoulos/awpygo go 1.18 -require github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 +require ( + github.com/go-python/gopy v0.4.7 + github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 +) require ( github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect diff --git a/awpy/parser/awpygo/go.py b/awpy/parser/awpygo/go.py new file mode 100644 index 000000000..60ac9c4f0 --- /dev/null +++ b/awpy/parser/awpygo/go.py @@ -0,0 +1,1825 @@ +# python wrapper for package go within overall package awpygo +# This is what you import to use the package. +# File is generated by gopy. Do not edit. +# gopy.exe pkg -output=awpygo -vm=python github.com/pnxenopoulos/awpygo + +# the following is required to enable dlopen to open the _go.so file +import collections +import inspect +import os + +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 _awpygo + +os.chdir(cwd) + +# to use this code in your end-user python file, import it as follows: +# 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: + """GoClass is the base class for all GoPy wrapper classes.""" + + def __init__(self) -> None: + 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.""" + _awpygo.GoPyInit() + + +# ---- Types --- + + +# Python type for slice []bool +class Slice_bool(GoClass): + """""" + + def __init__(self, *args, **kwargs) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_bool_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_bool([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_bool_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_bool_len(self.handle) + return Slice_bool( + handle=_awpygo.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 _awpygo.Slice_bool_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_bool_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_byte_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_byte([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_byte_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_byte_len(self.handle) + return Slice_byte( + handle=_awpygo.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 _awpygo.Slice_byte_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_byte_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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 []error +class Slice_error(GoClass): + """""" + + def __init__(self, *args, **kwargs) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_error_CTor() + _awpygo.IncRef(self.handle) + if len(args) > 0: + if not isinstance(args[0], _collections_abc.Iterable): + raise TypeError("Slice_error.__init__ takes a sequence as argument") + for elt in args[0]: + self.append(elt) + + def __del__(self) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + s = ( + "go.Slice_error len: " + + str(len(self)) + + " handle: " + + str(self.handle) + + " [" + ) + if len(self) < 120: + s += ", ".join(map(str, self)) + "]" + return s + + def __repr__(self) -> str: + return "go.Slice_error([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_error_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_error_len(self.handle) + return Slice_error( + handle=_awpygo.Slice_error_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 _awpygo.Slice_error_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.Slice_error_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_error.__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 = _awpygo.Slice_error_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.Slice_error_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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_float32_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_float32([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_float32_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_float32_len(self.handle) + return Slice_float32( + handle=_awpygo.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 _awpygo.Slice_float32_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_float32_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_float64_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_float64([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_float64_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_float64_len(self.handle) + return Slice_float64( + handle=_awpygo.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 _awpygo.Slice_float64_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_float64_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_int_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_int([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_int_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_int_len(self.handle) + return Slice_int(handle=_awpygo.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 _awpygo.Slice_int_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_int_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_int16_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_int16([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_int16_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_int16_len(self.handle) + return Slice_int16( + handle=_awpygo.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 _awpygo.Slice_int16_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_int16_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_int32_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_int32([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_int32_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_int32_len(self.handle) + return Slice_int32( + handle=_awpygo.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 _awpygo.Slice_int32_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_int32_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_int64_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_int64([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_int64_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_int64_len(self.handle) + return Slice_int64( + handle=_awpygo.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 _awpygo.Slice_int64_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_int64_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_int8_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_int8([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_int8_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_int8_len(self.handle) + return Slice_int8( + handle=_awpygo.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 _awpygo.Slice_int8_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_int8_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_rune_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_rune([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_rune_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_rune_len(self.handle) + return Slice_rune( + handle=_awpygo.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 _awpygo.Slice_rune_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_rune_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_string_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_string([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_string_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_string_len(self.handle) + return Slice_string( + handle=_awpygo.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 _awpygo.Slice_string_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_string_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_uint_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_uint([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_uint_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_uint_len(self.handle) + return Slice_uint( + handle=_awpygo.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 _awpygo.Slice_uint_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_uint_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_uint16_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_uint16([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_uint16_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_uint16_len(self.handle) + return Slice_uint16( + handle=_awpygo.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 _awpygo.Slice_uint16_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_uint16_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_uint32_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_uint32([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_uint32_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_uint32_len(self.handle) + return Slice_uint32( + handle=_awpygo.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 _awpygo.Slice_uint32_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_uint32_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_uint64_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_uint64([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_uint64_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_uint64_len(self.handle) + return Slice_uint64( + handle=_awpygo.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 _awpygo.Slice_uint64_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_uint64_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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) -> None: + """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"] + _awpygo.IncRef(self.handle) + elif len(args) == 1 and isinstance(args[0], GoClass): + self.handle = args[0].handle + _awpygo.IncRef(self.handle) + else: + self.handle = _awpygo.Slice_uint8_CTor() + _awpygo.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) -> None: + _awpygo.DecRef(self.handle) + + def __str__(self) -> str: + 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) -> str: + return "go.Slice_uint8([" + ", ".join(map(str, self)) + "])" + + def __len__(self) -> int: + return _awpygo.Slice_uint8_len(self.handle) + + def __getitem__(self, key): + if isinstance(key, slice): + if key.step is None or key.step == 1: + st = key.start + ed = key.stop + if st is None: + st = 0 + if ed is None: + ed = _awpygo.Slice_uint8_len(self.handle) + return Slice_uint8( + handle=_awpygo.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 _awpygo.Slice_uint8_elem(self.handle, key) + else: + raise TypeError("slice index invalid type") + + def __setitem__(self, idx, value) -> None: + if idx < 0: + idx += len(self) + if idx < len(self): + _awpygo.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 = _awpygo.Slice_uint8_elem(self.handle, self.index) + self.index = self.index + 1 + return rv + raise StopIteration + + def append(self, value): + _awpygo.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/awpy/parser/go.sum b/awpy/parser/awpygo/go.sum similarity index 95% rename from awpy/parser/go.sum rename to awpy/parser/awpygo/go.sum index 1624196c1..a9dff89f3 100644 --- a/awpy/parser/go.sum +++ b/awpy/parser/awpygo/go.sum @@ -1,5 +1,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/go-python/gopy v0.4.7 h1:VkJmTmzioBIRWca7+3EBN9W8/yPQavC8VNg+CMINHHQ= +github.com/go-python/gopy v0.4.7/go.mod h1:SqsDVtw9SG+TJNwJOnnnU/myD76uOhO8w5jehFewoVc= github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60= github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo= github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= diff --git a/awpy/parser/parse_demo.go b/awpy/parser/awpygo/parse_demo.go similarity index 66% rename from awpy/parser/parse_demo.go rename to awpy/parser/awpygo/parse_demo.go index a831a2c7b..7587793f2 100644 --- a/awpy/parser/parse_demo.go +++ b/awpy/parser/awpygo/parse_demo.go @@ -1,8 +1,7 @@ -package main +package awpygo import ( "encoding/json" - "flag" "fmt" "math" "os" @@ -14,8 +13,15 @@ import ( events "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/events" ) -// Game is the overall struct that holds the parsed demo data -type Game struct { +const unknown = "Unknown" +const spectator = "Spectator" +const unassigned = "Unassigned" +const plant = "plant" +const unranked = "Unranked" +const zeroTime = "00:00" + +// game is the overall struct that holds the parsed demo data. +type game struct { MatchName string `json:"matchID"` ClientName string `json:"clientName"` Map string `json:"mapName"` @@ -23,17 +29,17 @@ type Game struct { PlaybackTicks int64 `json:"playbackTicks"` PlaybackFrames int64 `json:"playbackFramesCount"` ParsedToFrame int64 `json:"parsedToFrameIdx"` - ParsingOpts ParserOpts `json:"parserParameters"` - ServerVars ServerConVar `json:"serverVars"` - MatchPhases MatchPhases `json:"matchPhases"` - MMRanks []MMRank `json:"matchmakingRanks"` - Chat []Chat `json:"chatMessages"` - Connections []ConnectAction `json:"playerConnections"` - Rounds []GameRound `json:"gameRounds"` + ParsingOpts parserOpts `json:"parserParameters"` + ServerVars serverConVar `json:"serverVars"` + MatchPhases matchPhases `json:"matchPhases"` + MMRanks []mMRank `json:"matchmakingRanks"` + Chat []chat `json:"chatMessages"` + Connections []connectAction `json:"playerConnections"` + Rounds []gameRound `json:"gameRounds"` } -// ParserOpts holds the parameters passed to the parser -type ParserOpts struct { +// parserOpts holds the parameters passed to the parser. +type parserOpts struct { ParseRate int `json:"parseRate"` ParseFrames bool `json:"parseFrames"` ParseKillFrames bool `json:"parseKillFrames"` @@ -43,8 +49,8 @@ type ParserOpts struct { ParseChat bool `json:"parseChat"` } -// MatchPhases holds lists of when match events occurred -type MatchPhases struct { +// matchPhases holds lists of when match events occurred. +type matchPhases struct { AnnLastRoundHalf []int64 `json:"announcementLastRoundHalf"` AnnFinalRound []int64 `json:"announcementFinalRound"` AnnMatchStarted []int64 `json:"announcementMatchStarted"` @@ -59,8 +65,8 @@ type MatchPhases struct { TeamSwitch []int64 `json:"teamSwitch"` } -// ServerConVar holds server convars, like round timers and timeouts, etc. Not always accurate. -type ServerConVar struct { +// serverConVar holds server convars, like round timers and timeouts, etc. Not always accurate. +type serverConVar struct { CashBombDefused int64 `json:"cashBombDefused"` // cash_player_bomb_defused CashBombPlanted int64 `json:"cashBombPlanted"` // cash_player_bomb_planted CashWinBomb int64 `json:"cashTeamTWinBomb"` // cash_team_terrorist_win_bomb @@ -81,8 +87,8 @@ type ServerConVar struct { CoachingAllowed int64 `json:"coachingAllowed"` // sv_coaching_enabled } -// MMRank holds the matchmaking ranks. Only for MM demos. -type MMRank struct { +// mMRank holds the matchmaking ranks. Only for MM demos. +type mMRank struct { SteamID uint64 `json:"steamID"` RankChange float32 `json:"rankChange"` RankOld string `json:"rankOld"` @@ -90,28 +96,28 @@ type MMRank struct { WinCount int `json:"winCount"` } -// Chat player and server chat messages -type Chat struct { +// chat player and server chat messages. +type chat struct { SteamID *int64 `json:"steamID"` Text string `json:"text"` Tick int64 `json:"tick"` Params []string `json:"params"` // params for SayText2 - IsChat bool `json:"isChat"` // true for Chat and variable for SayText + IsChat bool `json:"isChat"` // true for chat and variable for SayText // Unclear: Seems true for ChatMessages to allchat // but false for SayText admin commands to all chat IsChatAll bool `json:"isChatAll"` Type string `json:"type"` } -// ConnectAction is the act of connecting or disconnecting to the server -type ConnectAction struct { +// connectAction is the act of connecting or disconnecting to the server. +type connectAction struct { Tick int64 `json:"tick"` ConnectType string `json:"action"` SteamID uint64 `json:"steamID"` } -// GameRound contains round info and events -type GameRound struct { +// gameRound contains round info and events. +type gameRound struct { RoundNum int64 `json:"roundNum"` IsWarmup bool `json:"isWarmup"` StartTick int64 `json:"startTick"` @@ -137,31 +143,31 @@ type GameRound struct { TRoundStartEqVal int64 `json:"tRoundStartEqVal"` TRoundMoneySpend int64 `json:"tRoundSpendMoney"` TBuyType string `json:"tBuyType"` - CTSide PlayerTeams `json:"ctSide"` - TSide PlayerTeams `json:"tSide"` - Kills []KillAction `json:"kills"` - Damages []DamageAction `json:"damages"` - Grenades []GrenadeAction `json:"grenades"` - Bomb []BombAction `json:"bombEvents"` - WeaponFires []WeaponFireAction `json:"weaponFires"` - Flashes []FlashAction `json:"flashes"` - Frames []GameFrame `json:"frames"` -} - -// PlayerTeam -type PlayerTeams struct { + CTSide playerTeams `json:"ctSide"` + TSide playerTeams `json:"tSide"` + Kills []killAction `json:"kills"` + Damages []damageAction `json:"damages"` + Grenades []grenadeAction `json:"grenades"` + Bomb []bombAction `json:"bombEvents"` + WeaponFires []weaponFireAction `json:"weaponFires"` + Flashes []flashAction `json:"flashes"` + Frames []gameFrame `json:"frames"` +} + +// PlayerTeam. +type playerTeams struct { TeamName string `json:"teamName"` - Players []Players `json:"players"` + Players []players `json:"players"` } -// Players -type Players struct { +// players. +type players struct { PlayerName string `json:"playerName"` SteamID int64 `json:"steamID"` } -// GrenadeAction events -type GrenadeAction struct { +// grenadeAction events. +type grenadeAction struct { ThrowTick int64 `json:"throwTick"` DestroyTick int64 `json:"destroyTick"` ThrowSecond float64 `json:"throwSeconds"` @@ -182,8 +188,8 @@ type GrenadeAction struct { UniqueID int64 `json:"entityId"` } -// BombAction events -type BombAction struct { +// bombAction events. +type bombAction struct { Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` @@ -197,8 +203,8 @@ type BombAction struct { BombSite *string `json:"bombSite"` } -// DamageAction events -type DamageAction struct { +// damageAction events. +type damageAction struct { Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` @@ -233,8 +239,8 @@ type DamageAction struct { ZoomLevel *int64 `json:"zoomLevel"` } -// KillAction events -type KillAction struct { +// killAction events. +type killAction struct { Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` @@ -284,8 +290,8 @@ type KillAction struct { WeaponClass string `json:"weaponClass"` } -// WeaponFireAction events -type WeaponFireAction struct { +// weaponFireAction events. +type weaponFireAction struct { Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` @@ -306,8 +312,8 @@ type WeaponFireAction struct { ZoomLevel int64 `json:"zoomLevel"` } -// FlashAction events -type FlashAction struct { +// flashAction events. +type flashAction struct { Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` @@ -332,57 +338,57 @@ type FlashAction struct { FlashDuration *float64 `json:"flashDuration"` } -// GameFrame (game state at time t) -type GameFrame struct { +// gameFrame (game state at time t). +type gameFrame struct { IsKillFrame bool `json:"isKillFrame"` Tick int64 `json:"tick"` Second float64 `json:"seconds"` ClockTime string `json:"clockTime"` - T TeamFrameInfo `json:"t"` - CT TeamFrameInfo `json:"ct"` + T teamFrameInfo `json:"t"` + CT teamFrameInfo `json:"ct"` BombPlanted bool `json:"bombPlanted"` BombSite string `json:"bombsite"` - Bomb BombInfo `json:"bomb"` - Projectiles []GrenadeInfo `json:"projectiles"` - Smokes []Smoke `json:"smokes"` - Fires []Fire `json:"fires"` + Bomb bombInfo `json:"bomb"` + Projectiles []grenadeInfo `json:"projectiles"` + Smokes []smoke `json:"smokes"` + Fires []fire `json:"fires"` } -// Bomb location -type BombInfo struct { +// Bomb location. +type bombInfo struct { X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } -// Projectile -type GrenadeInfo struct { +// Projectile. +type grenadeInfo struct { ProjectileType string `json:"projectileType"` X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } -// Inferno from molly or incend. grenade -type Fire struct { +// Inferno from molly or incend. grenade. +type fire struct { UniqueID int64 `json:"uniqueID"` X float64 `json:"x"` Y float64 `json:"y"` Z float64 `json:"z"` } -// TeamFrameInfo at time t -type TeamFrameInfo struct { +// teamFrameInfo at time t. +type teamFrameInfo struct { Side string `json:"side"` Team string `json:"teamName"` CurrentEqVal int64 `json:"teamEqVal"` AlivePlayers int64 `json:"alivePlayers"` TotalUtility int64 `json:"totalUtility"` - Players []PlayerInfo `json:"players"` + Players []playerInfo `json:"players"` } -// PlayerInfo at time t -type PlayerInfo struct { +// playerInfo at time t. +type playerInfo struct { PlayerSteamID int64 `json:"steamID"` PlayerName string `json:"name"` PlayerTeam string `json:"team"` @@ -423,7 +429,7 @@ type PlayerInfo struct { IsScoped bool `json:"isScoped"` IsWalking bool `json:"isWalking"` IsUnknown bool `json:"isUnknown"` - Inventory []WeaponInfo `json:"inventory"` + Inventory []weaponInfo `json:"inventory"` Spotters []int64 `json:"spotters"` EqVal int64 `json:"equipmentValue"` EqValFreeze int64 `json:"equipmentValueFreezetimeEnd"` @@ -438,16 +444,16 @@ type PlayerInfo struct { ZoomLevel int64 `json:"zoomLevel"` } -// WeaponInfo contains data on an inventory weapon -type WeaponInfo struct { +// weaponInfo contains data on an inventory weapon. +type weaponInfo struct { WeaponName string `json:"weaponName"` WeaponClass string `json:"weaponClass"` AmmoInMagazine int64 `json:"ammoInMagazine"` AmmoInReserve int64 `json:"ammoInReserve"` } -// Smoke holds current smoke info -type Smoke struct { +// smoke holds current smoke info. +type smoke struct { GrenadeEntityID int64 `json:"grenadeEntityID"` StartTick int64 `json:"startTick"` X float64 `json:"x"` @@ -460,7 +466,7 @@ func convertRank(r int) string { case -1: return "Expired" case 0: - return "Unranked" + return unranked case 1: return "Silver 1" case 2: @@ -498,102 +504,102 @@ func convertRank(r int) string { case 18: return "The Global Elite" default: - return "Unranked" + return unranked } } func convertRoundEndReason(r events.RoundEndReason) string { switch reason := r; reason { - case 1: + case events.RoundEndReasonTargetBombed: return "TargetBombed" - case 2: + case events.RoundEndReasonVIPEscaped: return "VIPEscaped" - case 3: + case events.RoundEndReasonVIPKilled: return "VIPKilled" - case 4: + case events.RoundEndReasonTerroristsEscaped: return "TerroristsEscaped" - case 5: + case events.RoundEndReasonCTStoppedEscape: return "CTStoppedEscape" - case 6: + case events.RoundEndReasonTerroristsStopped: return "TerroristsStopped" - case 7: + case events.RoundEndReasonBombDefused: return "BombDefused" - case 8: + case events.RoundEndReasonCTWin: return "CTWin" - case 9: + case events.RoundEndReasonTerroristsWin: return "TerroristsWin" - case 10: + case events.RoundEndReasonDraw: return "Draw" - case 11: + case events.RoundEndReasonHostagesRescued: return "HostagesRescued" - case 12: + case events.RoundEndReasonTargetSaved: return "TargetSaved" - case 13: + case events.RoundEndReasonHostagesNotRescued: return "HostagesNotRescued" - case 14: + case events.RoundEndReasonTerroristsNotEscaped: return "TerroristsNotEscaped" - case 15: + case events.RoundEndReasonVIPNotEscaped: return "VIPNotEscaped" - case 16: + case events.RoundEndReasonGameStart: return "GameStart" - case 17: + case events.RoundEndReasonTerroristsSurrender: return "TerroristsSurrender" - case 18: + case events.RoundEndReasonCTSurrender: return "CTSurrender" default: - return "Unknown" + return unknown } } func convertHitGroup(hg events.HitGroup) string { switch hitGroup := hg; hitGroup { - case 0: + case events.HitGroupGeneric: return "Generic" - case 1: + case events.HitGroupHead: return "Head" - case 2: + case events.HitGroupChest: return "Chest" - case 3: + case events.HitGroupStomach: return "Stomach" - case 4: + case events.HitGroupLeftArm: return "LeftArm" - case 5: + case events.HitGroupRightArm: return "RightArm" - case 6: + case events.HitGroupLeftLeg: return "LeftLeg" - case 7: + case events.HitGroupRightLeg: return "RightLeg" - case 8: + case events.HitGroupNeck: return "Neck" - case 10: + case events.HitGroupGear: return "Gear" default: - return "Unknown" + return unknown } } func convertWeaponClass(wc common.EquipmentClass) string { switch weaponClass := wc; weaponClass { - case 0: - return "Unknown" - case 1: + case common.EqClassUnknown: + return unknown + case common.EqClassPistols: return "Pistols" - case 2: + case common.EqClassSMG: return "SMG" - case 3: + case common.EqClassHeavy: return "Heavy" - case 4: + case common.EqClassRifle: return "Rifle" - case 5: + case common.EqClassEquipment: return "Equipment" - case 6: + case common.EqClassGrenade: return "Grenade" default: - return "Unknown" + return unknown } } -func determineSecond(tick int64, currentRound GameRound, currentGame Game) float64 { +func determineSecond(tick int64, currentRound gameRound, tickRate int64) float64 { if tick <= 0 { return float64(0) } @@ -603,56 +609,62 @@ func determineSecond(tick int64, currentRound GameRound, currentGame Game) float } else { phaseEndTick = *currentRound.BombPlantTick } - return float64((float64(tick) - float64(phaseEndTick)) / float64(currentGame.TickRate)) + + return (float64(tick) - float64(phaseEndTick)) / float64(tickRate) } func formatTimeNumber(num int64) string { if num < 10 { return "0" + fmt.Sprint(num) - } else { - return fmt.Sprint(num) } + + return fmt.Sprint(num) } -func calculateClocktime(tick int64, currentRound GameRound, currentGame Game) string { +func calculateClocktime(tick int64, currentRound gameRound, tickRate int64) string { if tick <= 0 { - return "00:00" + return zeroTime } - - var seconds_remaining float64 + var secondsPerMinute float64 = 60 + var roundLengthSeconds float64 = 115 + var bombTimerSeconds float64 = 40 + var secondsRemaining float64 var phaseEndTick int64 + var secondsSincePhaseChange float64 + if currentRound.BombPlantTick == nil { phaseEndTick = currentRound.FreezeTimeEndTick - seconds_remaining = 115 - (float64((float64(tick) - float64(phaseEndTick)) / float64(currentGame.TickRate))) + secondsSincePhaseChange = (float64(tick) - float64(phaseEndTick)) / float64(tickRate) + secondsRemaining = roundLengthSeconds - secondsSincePhaseChange } else { phaseEndTick = *currentRound.BombPlantTick - seconds_remaining = 40 - (float64((float64(tick) - float64(phaseEndTick)) / float64(currentGame.TickRate))) + secondsSincePhaseChange = (float64(tick) - float64(phaseEndTick)) / float64(tickRate) + secondsRemaining = bombTimerSeconds - secondsSincePhaseChange } - minutes := int64(math.Floor((seconds_remaining / 60))) - seconds := int64(math.Ceil((seconds_remaining - 60*float64(minutes)))) + minutes := int64(math.Floor((secondsRemaining / secondsPerMinute))) + seconds := int64(math.Ceil((secondsRemaining - secondsPerMinute*float64(minutes)))) if (minutes < 0) || (seconds < 0) { - return "00:00" + return zeroTime } return formatTimeNumber(minutes) + ":" + formatTimeNumber(seconds) } -func playerInList(p *common.Player, players []PlayerInfo) bool { +func playerInList(p *common.Player, players []playerInfo) bool { if len(players) > 0 { for _, i := range players { if int64(p.SteamID64) == i.PlayerSteamID { return true } } - } else { - return false } + return false } -func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { - currentPlayer := PlayerInfo{} +func parsePlayer(gs dem.GameState, p *common.Player) playerInfo { + currentPlayer := playerInfo{} currentPlayer.PlayerSteamID = int64(p.SteamID64) currentPlayer.PlayerName = p.Name if p.TeamState != nil { @@ -664,8 +676,12 @@ func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { currentPlayer.PlayerSide = "T" case common.TeamCounterTerrorists: currentPlayer.PlayerSide = "CT" + case common.TeamSpectators: + currentPlayer.PlayerSide = spectator + case common.TeamUnassigned: + currentPlayer.PlayerSide = unassigned default: - currentPlayer.PlayerSide = "Unknown" + currentPlayer.PlayerSide = unknown } playerPos := p.LastAlivePosition @@ -673,15 +689,15 @@ func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { playerVel := p.Velocity() // Calc other metrics - currentPlayer.X = float64(playerPos.X) - currentPlayer.Y = float64(playerPos.Y) - currentPlayer.Z = float64(playerPos.Z) - currentPlayer.EyeX = float64(playerEyePos.X) - currentPlayer.EyeY = float64(playerEyePos.Y) - currentPlayer.EyeZ = float64(playerEyePos.Z) - currentPlayer.VelX = float64(playerVel.X) - currentPlayer.VelY = float64(playerVel.Y) - currentPlayer.VelZ = float64(playerVel.Z) + currentPlayer.X = playerPos.X + currentPlayer.Y = playerPos.Y + currentPlayer.Z = playerPos.Z + currentPlayer.EyeX = playerEyePos.X + currentPlayer.EyeY = playerEyePos.Y + currentPlayer.EyeZ = playerEyePos.Z + currentPlayer.VelX = playerVel.X + currentPlayer.VelY = playerVel.Y + currentPlayer.VelZ = playerVel.Z currentPlayer.ViewX = float64(p.ViewDirectionX()) currentPlayer.ViewY = float64(p.ViewDirectionY()) currentPlayer.LastPlaceName = p.LastPlaceName() @@ -728,14 +744,12 @@ func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { if spottedOtherPlayer { spottedPlayers = append(spottedPlayers, int64(player.SteamID64)) } - spottedOtherPlayer = false } for _, player := range gs.TeamTerrorists().Members() { spottedOtherPlayer = p.HasSpotted(player) if spottedOtherPlayer { spottedPlayers = append(spottedPlayers, int64(player.SteamID64)) } - spottedOtherPlayer = false } currentPlayer.Spotters = spottedPlayers @@ -745,28 +759,28 @@ func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { if w != nil { if (w.String() != "Knife") && (w.String() != "C4") { // Can't drop the knife - currentWeapon := WeaponInfo{} + currentWeapon := weaponInfo{} currentWeapon.WeaponName = w.String() currentWeapon.WeaponClass = convertWeaponClass(w.Class()) currentWeapon.AmmoInMagazine = int64(w.AmmoInMagazine()) currentWeapon.AmmoInReserve = int64(w.AmmoReserve()) - //currentPlayer.Inventory = append(currentPlayer.Inventory, w.String()) + // currentPlayer.Inventory = append(currentPlayer.Inventory, w.String()) currentPlayer.Inventory = append(currentPlayer.Inventory, currentWeapon) - if w.Class() == 6 { - currentPlayer.TotalUtility = currentPlayer.TotalUtility + 1 - if w.Type == 502 || w.Type == 503 { - currentPlayer.FireGrenade += 1 + if w.Class() == common.EqClassGrenade { + currentPlayer.TotalUtility++ + if w.Type == common.EqMolotov || w.Type == common.EqIncendiary { + currentPlayer.FireGrenade++ } - if w.Type == 504 { + if w.Type == common.EqFlash { currentPlayer.FlashGrenade += int64(w.AmmoInMagazine()) + int64(w.AmmoReserve()) } - if w.Type == 505 { - currentPlayer.SmokeGrenade += 1 + if w.Type == common.EqSmoke { + currentPlayer.SmokeGrenade++ } - if w.Type == 506 { - currentPlayer.HEGrenade += 1 + if w.Type == common.EqHE { + currentPlayer.HEGrenade++ } } } @@ -776,230 +790,178 @@ func parsePlayer(gs dem.GameState, p *common.Player) PlayerInfo { } } } + return currentPlayer } -func parseTeamBuy(eqVal int64, Side string, Style string) string { - if Style == "hltv" { - // Taken from hltv economy tab - if eqVal < 5000 { - return "Full Eco" - } else if (eqVal >= 5000) && (eqVal < 10000) { - return "Semi Eco" - } else if (eqVal >= 10000) && (eqVal < 20000) { - return "Semi Buy" - } else if eqVal >= 20000 { - return "Full Buy" - } else { - return "Unknown" - } - } else if Style == "csgo" { +func parseTeamBuy(eqVal int64, side string, style string) string { + fullEco := "Full Eco" + semiEco := "Semi Eco" + semiBuy := "Semi Buy" + fullBuy := "Full Buy" + switch { + case style == "csgo": // Created this using 4100 and 3700 as armor+gun for CT and T - if Side == "CT" { - if eqVal < 2000 { - return "Full Eco" - } else if (eqVal >= 2000) && (eqVal < 6000) { + if side == "CT" { + switch { + case eqVal < 2000: + return fullEco + case (eqVal >= 2000) && (eqVal < 6000): return "Eco" - } else if (eqVal >= 6000) && (eqVal < 22000) { + case (eqVal >= 6000) && (eqVal < 22000): return "Half Buy" - } else if eqVal >= 22000 { - return "Full Buy" - } else { - return "Unknown" + case eqVal >= 22000: + return fullBuy + default: + return unknown } } else { - if eqVal < 2000 { - return "Full Eco" - } else if (eqVal >= 2000) && (eqVal < 6000) { + switch { + case eqVal < 2000: + return fullEco + case (eqVal >= 2000) && (eqVal < 6000): return "Eco" - } else if (eqVal >= 6000) && (eqVal < 18500) { + case (eqVal >= 6000) && (eqVal < 18500): return "Half Buy" - } else if eqVal >= 18500 { - return "Full Buy" - } else { - return "Unknown" + case eqVal >= 18500: + return fullBuy + default: + return unknown } } - } else { - // Default to hltv style - return parseTeamBuy(eqVal, Side, "hltv") + default: + // Taken from hltv economy tab + switch { + case eqVal < 5000: + return fullEco + case (eqVal >= 5000) && (eqVal < 10000): + return semiEco + case (eqVal >= 10000) && (eqVal < 20000): + return semiBuy + case eqVal >= 20000: + return fullBuy + default: + return unknown + } } } -func isTrade(killA KillAction, killB KillAction, tickRate int64, tradeTime int64) bool { - // First, identify is killA has a killer. If there is no killer, there cannot be a trade +func isTrade(killA killAction, killB killAction, tickRate int64, tradeTime int64) bool { + // First, identify if killA has a killer. If there is no killer, there cannot be a trade if killA.AttackerSteamID == nil { return false - } else { - // If the the previous killer is not the person killed, it is not a trade - if killB.VictimSteamID != nil { - if *killB.VictimSteamID == *killA.AttackerSteamID { - return inTradeWindow(killA, killB, tickRate, tradeTime) - } + } + // If the previous killer is not the person killed, it is not a trade + if killB.VictimSteamID != nil { + if *killB.VictimSteamID == *killA.AttackerSteamID { + return inTradeWindow(killA, killB, tickRate, tradeTime) } - return false } + + return false } -func inTradeWindow(killA KillAction, killB KillAction, tickRate int64, tradeTime int64) bool { +func inTradeWindow(killA killAction, killB killAction, tickRate int64, tradeTime int64) bool { return (killB.Tick - killA.Tick) <= tradeTime*tickRate } -func countAlivePlayers(players []PlayerInfo) int64 { +func countAlivePlayers(players []playerInfo) int64 { var alivePlayers int64 - alivePlayers = 0 for _, p := range players { if p.IsAlive { - alivePlayers = alivePlayers + 1 + alivePlayers++ } } + return alivePlayers } -func countUtility(players []PlayerInfo) int64 { +func countUtility(players []playerInfo) int64 { var totalUtility int64 - totalUtility = 0 for _, p := range players { if p.IsAlive { - totalUtility = totalUtility + p.TotalUtility + totalUtility += p.TotalUtility } } + return totalUtility } -// Define cleaning functions +// Define cleaning functions. func cleanMapName(mapName string) string { lastSlash := strings.LastIndex(mapName, "/") if lastSlash == -1 { return mapName } + return mapName[lastSlash+1:] } -func removeExpiredSmoke(s []Smoke, i int) []Smoke { +func removeExpiredSmoke(s []smoke, i int) []smoke { s[i] = s[len(s)-1] + return s[:len(s)-1] } -// Main -func main() { - /* Parse the arguments - - Run the parser as follows: go run parse_demo.go -demo /path/to/demo.dem -parserate 1/2/4/8/16/32/64/128 -demoID someDemoIDString - - The parserate should be one of 2^0 to 2^7. The lower the value, the more frames are collected. Indicates spacing between parsed demo frames in ticks. - */ - - fl := new(flag.FlagSet) - demoPathPtr := fl.String("demo", "", "Demo file `path`") - parseRatePtr := fl.Int("parserate", 128, "Parse rate, indicates spacing between ticks") - parseFramesPtr := fl.Bool("parseframes", false, "Parse frames") - parseKillFramesPtr := fl.Bool("parsekillframes", false, "Parse kill frames") - tradeTimePtr := fl.Int("tradetime", 5, "Trade time frame (in seconds)") - roundBuyPtr := fl.String("buystyle", "hltv", "Round buy style") - damagesRolledPtr := fl.Bool("dmgrolled", false, "Roll up damages") - demoIDPtr := fl.String("demoid", "", "Demo string ID") - jsonIndentationPtr := fl.Bool("jsonindentation", false, "Indent JSON file") - parseChatPtr := fl.Bool("parsechat", false, "Parse chat messages") - outpathPtr := fl.String("out", "", "Path to write output JSON") - - err := fl.Parse(os.Args[1:]) - checkError(err) - - demPath := *demoPathPtr - parseRate := *parseRatePtr - parseFrames := *parseFramesPtr - parseKillFrames := *parseKillFramesPtr - tradeTime := int64(*tradeTimePtr) - roundBuyStyle := *roundBuyPtr - damagesRolled := *damagesRolledPtr - jsonIndentation := *jsonIndentationPtr - parseChat := *parseChatPtr - outpath := *outpathPtr - - // Read in demofile - f, err := os.Open(demPath) - checkError(err) - defer f.Close() - - // Create new demoparser - p := dem.NewParser(f) - defer p.Close() - - // Parse demofile header - header, err := p.ParseHeader() - checkError(err) - - // Parse nav mesh given the map name - currentMap := header.MapName - currentMap = cleanMapName(currentMap) - - // Create flags to guide parsing - roundStarted := 0 - roundInEndTime := 0 - roundInFreezetime := 0 - currentFrameIdx := 0 - convParsed := 0 - - // Create game object, then initial round object - currentGame := Game{} - currentGame.MatchName = *demoIDPtr - currentGame.Map = cleanMapName(currentMap) - if p.TickRate() == 0 { - currentGame.TickRate = 128 - } else { - currentGame.TickRate = int64(math.Round(p.TickRate())) // Rounds to 127 instead - } - currentGame.PlaybackTicks = int64(header.PlaybackTicks) - currentGame.PlaybackFrames = int64(header.PlaybackFrames) - currentGame.ClientName = header.ClientName - - // Create empty smoke tracking list - smokes := []Smoke{} - - // Set parsing options - parsingOpts := ParserOpts{} - parsingOpts.ParseRate = int(parseRate) - parsingOpts.ParseFrames = parseFrames - parsingOpts.ParseKillFrames = parseKillFrames - parsingOpts.TradeTime = tradeTime - parsingOpts.RoundBuyStyle = roundBuyStyle - parsingOpts.DamagesRolled = damagesRolled - parsingOpts.ParseChat = parseChat - currentGame.ParsingOpts = parsingOpts +func initializeRound(currentRound *gameRound) { + currentRound.Bomb = []bombAction{} + currentRound.Damages = []damageAction{} + currentRound.Flashes = []flashAction{} + currentRound.Frames = []gameFrame{} + currentRound.Grenades = []grenadeAction{} + currentRound.Kills = []killAction{} + currentRound.WeaponFires = []weaponFireAction{} +} - currentRound := GameRound{} +func registerChatHandlers(demoParser *dem.Parser, currentGame *game) { + // Register handler for chat messages (ChatMessage) + (*demoParser).RegisterEventHandler(func(e events.ChatMessage) { + if e.Sender != nil { + gs := (*demoParser).GameState() + chatMessage := chat{} + senderSteamID := int64(e.Sender.SteamID64) + chatMessage.SteamID = &senderSteamID + chatMessage.Text = e.Text + chatMessage.Tick = int64(gs.IngameTick()) + chatMessage.IsChat = true + chatMessage.IsChatAll = e.IsChatAll + chatMessage.Type = "ChatMessage" - // Create empty action lists for first round - currentRound.Bomb = []BombAction{} - currentRound.Damages = []DamageAction{} - currentRound.Flashes = []FlashAction{} - currentRound.Frames = []GameFrame{} - currentRound.Grenades = []GrenadeAction{} - currentRound.Kills = []KillAction{} - currentRound.WeaponFires = []WeaponFireAction{} + currentGame.Chat = append(currentGame.Chat, chatMessage) + } + }) - RoundRestartDelay := int64(5) + // Register handler for chat messages (SayText) + (*demoParser).RegisterEventHandler(func(e events.SayText) { + gs := (*demoParser).GameState() + chatMessage := chat{} + chatMessage.Text = e.Text + chatMessage.Tick = int64(gs.IngameTick()) + chatMessage.IsChat = e.IsChat + chatMessage.IsChatAll = e.IsChatAll + chatMessage.Type = "SayText" + + currentGame.Chat = append(currentGame.Chat, chatMessage) + }) - // Create empty lists - currentGame.MMRanks = []MMRank{} - currentGame.Chat = []Chat{} - currentGame.MatchPhases.AnnFinalRound = []int64{} - currentGame.MatchPhases.AnnLastRoundHalf = []int64{} - currentGame.MatchPhases.AnnMatchStarted = []int64{} - currentGame.MatchPhases.GameHalfEnded = []int64{} - currentGame.MatchPhases.MatchStart = []int64{} - currentGame.MatchPhases.MatchStartedChanged = []int64{} - currentGame.MatchPhases.WarmupChanged = []int64{} - currentGame.MatchPhases.TeamSwitch = []int64{} - currentGame.MatchPhases.RoundStarted = []int64{} - currentGame.MatchPhases.RoundFreezeEnded = []int64{} - currentGame.MatchPhases.RoundEnded = []int64{} - currentGame.MatchPhases.RoundEndedOfficial = []int64{} + // Register handler for chat messages (SayText2) + (*demoParser).RegisterEventHandler(func(e events.SayText2) { + gs := (*demoParser).GameState() + chatMessage := chat{} + chatMessage.Text = e.Params[1] + chatMessage.Params = e.Params + chatMessage.Tick = int64(gs.IngameTick()) + chatMessage.IsChat = e.IsChat + chatMessage.IsChatAll = e.IsChatAll + chatMessage.Type = "SayText2" + + currentGame.Chat = append(currentGame.Chat, chatMessage) + }) +} - // Parse rank updates - p.RegisterEventHandler(func(e events.RankUpdate) { - rankUpdate := MMRank{} +func registerRankUpdateHandler(demoParser *dem.Parser, currentGame *game) { + (*demoParser).RegisterEventHandler(func(e events.RankUpdate) { + rankUpdate := mMRank{} rankUpdate.SteamID = e.SteamID64() rankUpdate.RankChange = e.RankChange @@ -1009,57 +971,13 @@ func main() { currentGame.MMRanks = append(currentGame.MMRanks, rankUpdate) }) +} - if parseChat { - // Register handler for chat messages (ChatMessage) - p.RegisterEventHandler(func(e events.ChatMessage) { - if e.Sender != nil { - gs := p.GameState() - chatMessage := Chat{} - senderSteamID := int64(e.Sender.SteamID64) - chatMessage.SteamID = &senderSteamID - chatMessage.Text = e.Text - chatMessage.Tick = int64(gs.IngameTick()) - chatMessage.IsChat = true - chatMessage.IsChatAll = e.IsChatAll - chatMessage.Type = "ChatMessage" - - currentGame.Chat = append(currentGame.Chat, chatMessage) - } - }) - - // Register handler for chat messages (SayText) - p.RegisterEventHandler(func(e events.SayText) { - gs := p.GameState() - chatMessage := Chat{} - chatMessage.Text = e.Text - chatMessage.Tick = int64(gs.IngameTick()) - chatMessage.IsChat = e.IsChat - chatMessage.IsChatAll = e.IsChatAll - chatMessage.Type = "SayText" - - currentGame.Chat = append(currentGame.Chat, chatMessage) - }) - - // Register handler for chat messages (SayText2) - p.RegisterEventHandler(func(e events.SayText2) { - gs := p.GameState() - chatMessage := Chat{} - chatMessage.Text = e.Params[1] - chatMessage.Params = e.Params - chatMessage.Tick = int64(gs.IngameTick()) - chatMessage.IsChat = e.IsChat - chatMessage.IsChatAll = e.IsChatAll - chatMessage.Type = "SayText2" - - currentGame.Chat = append(currentGame.Chat, chatMessage) - }) - } - // Parse player connects - p.RegisterEventHandler(func(e events.PlayerConnect) { +func registerConnectHandler(demoParser *dem.Parser, currentGame *game) { + (*demoParser).RegisterEventHandler(func(e events.PlayerConnect) { if e.Player != nil { - gs := p.GameState() - playerConnected := ConnectAction{} + gs := (*demoParser).GameState() + playerConnected := connectAction{} playerConnected.Tick = int64(gs.IngameTick()) playerConnected.ConnectType = "connect" @@ -1068,12 +986,12 @@ func main() { currentGame.Connections = append(currentGame.Connections, playerConnected) } }) - - // Parse player disconnects - p.RegisterEventHandler(func(e events.PlayerDisconnected) { +} +func registerDisonnectHandler(demoParser *dem.Parser, currentGame *game) { + (*demoParser).RegisterEventHandler(func(e events.PlayerDisconnected) { if e.Player != nil { - gs := p.GameState() - playerConnected := ConnectAction{} + gs := (*demoParser).GameState() + playerConnected := connectAction{} playerConnected.Tick = int64(gs.IngameTick()) playerConnected.ConnectType = "disconnect" @@ -1082,111 +1000,116 @@ func main() { currentGame.Connections = append(currentGame.Connections, playerConnected) } }) +} - // Parse the match phases - p.RegisterEventHandler(func(e events.AnnouncementLastRoundHalf) { - gs := p.GameState() +func registerMatchphases(demoParser *dem.Parser, currentGame *game) { + (*demoParser).RegisterEventHandler(func(e events.AnnouncementLastRoundHalf) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.AnnLastRoundHalf = append(currentGame.MatchPhases.AnnLastRoundHalf, int64(gs.IngameTick())) + currentGame.MatchPhases.AnnLastRoundHalf = append(currentGame.MatchPhases.AnnLastRoundHalf, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.AnnouncementFinalRound) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.AnnouncementFinalRound) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.AnnFinalRound = append(currentGame.MatchPhases.AnnFinalRound, int64(gs.IngameTick())) + currentGame.MatchPhases.AnnFinalRound = append(currentGame.MatchPhases.AnnFinalRound, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.AnnouncementMatchStarted) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.AnnouncementMatchStarted) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.AnnMatchStarted = append(currentGame.MatchPhases.AnnMatchStarted, int64(gs.IngameTick())) + currentGame.MatchPhases.AnnMatchStarted = append(currentGame.MatchPhases.AnnMatchStarted, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.GameHalfEnded) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.GameHalfEnded) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.GameHalfEnded = append(currentGame.MatchPhases.GameHalfEnded, int64(gs.IngameTick())) + currentGame.MatchPhases.GameHalfEnded = append(currentGame.MatchPhases.GameHalfEnded, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.MatchStart) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.MatchStart) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.MatchStart = append(currentGame.MatchPhases.MatchStart, int64(gs.IngameTick())) + currentGame.MatchPhases.MatchStart = append(currentGame.MatchPhases.MatchStart, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.MatchStartedChanged) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.MatchStartedChanged) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.MatchStartedChanged = append(currentGame.MatchPhases.MatchStartedChanged, int64(gs.IngameTick())) + currentGame.MatchPhases.MatchStartedChanged = append(currentGame.MatchPhases.MatchStartedChanged, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.IsWarmupPeriodChanged) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.IsWarmupPeriodChanged) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.WarmupChanged = append(currentGame.MatchPhases.WarmupChanged, int64(gs.IngameTick())) + currentGame.MatchPhases.WarmupChanged = append(currentGame.MatchPhases.WarmupChanged, + int64(gs.IngameTick())) }) - p.RegisterEventHandler(func(e events.TeamSideSwitch) { - gs := p.GameState() + (*demoParser).RegisterEventHandler(func(e events.TeamSideSwitch) { + gs := (*demoParser).GameState() - currentGame.MatchPhases.TeamSwitch = append(currentGame.MatchPhases.TeamSwitch, int64(gs.IngameTick())) + currentGame.MatchPhases.TeamSwitch = append(currentGame.MatchPhases.TeamSwitch, + int64(gs.IngameTick())) }) +} - // Parse smokes - p.RegisterEventHandler(func(e events.SmokeStart) { - gs := p.GameState() - s := Smoke{} +func registerSmokeHandler(demoParser *dem.Parser, smokes *[]smoke) { + (*demoParser).RegisterEventHandler(func(e events.SmokeStart) { + gs := (*demoParser).GameState() + s := smoke{} s.GrenadeEntityID = e.Grenade.UniqueID() // GrenadeEntityID s.StartTick = int64(gs.IngameTick()) - s.X = float64(e.Position.X) - s.Y = float64(e.Position.Y) - s.Z = float64(e.Position.Z) + s.X = e.Position.X + s.Y = e.Position.Y + s.Z = e.Position.Z foundNade := false - for _, ele := range smokes { + for _, ele := range *smokes { if ele.GrenadeEntityID == s.GrenadeEntityID { foundNade = true } } if !foundNade { - smokes = append(smokes, s) + *smokes = append(*smokes, s) } - foundNade = false }) - p.RegisterEventHandler(func(e events.SmokeExpired) { + (*demoParser).RegisterEventHandler(func(e events.SmokeExpired) { removeID := e.Grenade.UniqueID() // e.GrenadeEntityID - for i, ele := range smokes { + for i, ele := range *smokes { if ele.GrenadeEntityID == removeID { - smokes = removeExpiredSmoke(smokes, i) + *smokes = removeExpiredSmoke(*smokes, i) } } }) +} - // Parse round starts - p.RegisterEventHandler(func(e events.RoundStart) { - gs := p.GameState() +func registerRoundStartHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + roundStarted *int, roundInFreezetime *int, roundInEndTime *int, smokes *[]smoke) { + (*demoParser).RegisterEventHandler(func(e events.RoundStart) { + gs := (*demoParser).GameState() currentGame.MatchPhases.RoundStarted = append(currentGame.MatchPhases.RoundStarted, int64(gs.IngameTick())) - if roundStarted == 1 { - currentGame.Rounds = append(currentGame.Rounds, currentRound) + if *roundStarted == 1 { + currentGame.Rounds = append(currentGame.Rounds, *currentRound) } - roundStarted = 1 - roundInFreezetime = 1 - roundInEndTime = 0 - currentRound = GameRound{} + *roundStarted = 1 + *roundInFreezetime = 1 + *roundInEndTime = 0 + *currentRound = gameRound{} // Reset smokes - smokes = []Smoke{} + *smokes = []smoke{} // Create empty action lists - currentRound.Bomb = []BombAction{} - currentRound.Damages = []DamageAction{} - currentRound.Flashes = []FlashAction{} - currentRound.Frames = []GameFrame{} - currentRound.Grenades = []GrenadeAction{} - currentRound.Kills = []KillAction{} - currentRound.WeaponFires = []WeaponFireAction{} + initializeRound(currentRound) // Parse flags currentRound.IsWarmup = gs.IsWarmupPeriod() @@ -1201,28 +1124,11 @@ func main() { currentRound.CTTeam = &ctTeam } - // Parse round money - // tPlayers := gs.TeamTerrorists().Members() - // currentRound.TBeginMoney = 0 - // ctPlayers := gs.TeamCounterTerrorists().Members() - // currentRound.CTBeginMoney = 0 - // for _, p := range tPlayers { - // if p != nil { - // currentRound.TBeginMoney += int64(p.Money()) - // } - - // } - // for _, p := range ctPlayers { - // if p != nil { - // currentRound.CTBeginMoney += int64(p.Money()) - // } - // } - // Parse the players - teamCT := PlayerTeams{} + teamCT := playerTeams{} teamCT.TeamName = gs.TeamCounterTerrorists().ClanName() for _, player := range gs.TeamCounterTerrorists().Members() { - pl := Players{} + pl := players{} pl.PlayerName = player.Name pl.SteamID = int64(player.SteamID64) foundPlayer := false @@ -1237,10 +1143,10 @@ func main() { } currentRound.CTSide = teamCT - teamT := PlayerTeams{} + teamT := playerTeams{} teamT.TeamName = gs.TeamTerrorists().ClanName() for _, player := range gs.TeamTerrorists().Members() { - pl := Players{} + pl := players{} pl.PlayerName = player.Name pl.SteamID = int64(player.SteamID64) foundPlayer := false @@ -1255,11 +1161,16 @@ func main() { } currentRound.TSide = teamT }) +} +func registerRoundFreezeTimeEndHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + convParsed *int, roundRestartDelay *int64, + roundStarted *int, roundInFreezetime *int, roundInEndTime *int, smokes *[]smoke) { // Parse round freezetime ends - p.RegisterEventHandler(func(e events.RoundFreezetimeEnd) { - gs := p.GameState() - currentGame.MatchPhases.RoundFreezeEnded = append(currentGame.MatchPhases.RoundFreezeEnded, int64(gs.IngameTick())) + (*demoParser).RegisterEventHandler(func(e events.RoundFreezetimeEnd) { + gs := (*demoParser).GameState() + currentGame.MatchPhases.RoundFreezeEnded = append(currentGame.MatchPhases.RoundFreezeEnded, + int64(gs.IngameTick())) // Reupdate the teams to make sure currentRound.TScore = int64(gs.TeamTerrorists().Score()) @@ -1272,15 +1183,15 @@ func main() { } // Reset smokes - smokes = []Smoke{} + *smokes = []smoke{} // Determine if round is still in warmup mode currentRound.IsWarmup = gs.IsWarmupPeriod() // If convars aren't parsed, do so - if convParsed == 0 { + if *convParsed == 0 { // If convars are unparsed, record the convars of the server - serverConfig := ServerConVar{} + serverConfig := serverConVar{} conv := gs.Rules().ConVars() serverConfig.CashBombDefused, _ = strconv.ParseInt(conv["cash_player_bomb_defused"], 10, 64) serverConfig.CashBombPlanted, _ = strconv.ParseInt(conv["cash_player_bomb_planted"], 10, 64) @@ -1290,7 +1201,8 @@ func main() { serverConfig.CashWinElimination, _ = strconv.ParseInt(conv["cash_team_elimination_bomb_map"], 10, 64) serverConfig.CashPlayerKilledDefault, _ = strconv.ParseInt(conv["cash_player_killed_enemy_default"], 10, 64) serverConfig.CashTeamLoserBonus, _ = strconv.ParseInt(conv["cash_team_loser_bonus"], 10, 64) - serverConfig.CashTeamLoserBonusConsecutive, _ = strconv.ParseInt(conv["cash_team_loser_bonus_consecutive_rounds"], 10, 64) + serverConfig.CashTeamLoserBonusConsecutive, _ = strconv.ParseInt( + conv["cash_team_loser_bonus_consecutive_rounds"], 10, 64) serverConfig.MaxRounds, _ = strconv.ParseInt(conv["mp_maxrounds"], 10, 64) serverConfig.RoundTime, _ = strconv.ParseInt(conv["mp_roundtime"], 10, 64) serverConfig.RoundTimeDefuse, _ = strconv.ParseInt(conv["mp_roundtime_defuse"], 10, 64) @@ -1301,31 +1213,25 @@ func main() { serverConfig.TimeoutsAllowed, _ = strconv.ParseInt(conv["mp_team_timeout_max"], 10, 64) serverConfig.CoachingAllowed, _ = strconv.ParseInt(conv["sv_coaching_enabled"], 10, 64) currentGame.ServerVars = serverConfig - convParsed = 1 + *convParsed = 1 // Change so that round restarts are parsed using the server convar if serverConfig.RoundRestartDelay == 0 { - RoundRestartDelay = 5 // This is default on many servers, I think + *roundRestartDelay = 5 // This is default on many servers, I think } else { - RoundRestartDelay = serverConfig.RoundRestartDelay + *roundRestartDelay = serverConfig.RoundRestartDelay } } - if roundInFreezetime == 0 { + if *roundInFreezetime == 0 { // This means the RoundStart event did not fire, but the FreezeTimeEnd did - currentGame.Rounds = append(currentGame.Rounds, currentRound) - roundStarted = 1 - roundInEndTime = 0 - currentRound = GameRound{} + currentGame.Rounds = append(currentGame.Rounds, *currentRound) + *roundStarted = 1 + *roundInEndTime = 0 + *currentRound = gameRound{} // Create empty action lists - currentRound.Bomb = []BombAction{} - currentRound.Damages = []DamageAction{} - currentRound.Flashes = []FlashAction{} - currentRound.Frames = []GameFrame{} - currentRound.Grenades = []GrenadeAction{} - currentRound.Kills = []KillAction{} - currentRound.WeaponFires = []WeaponFireAction{} + initializeRound(currentRound) currentRound.IsWarmup = gs.IsWarmupPeriod() currentRound.RoundNum = int64(len(currentGame.Rounds) + 1) @@ -1350,10 +1256,10 @@ func main() { } // Parse the players - teamCT := PlayerTeams{} + teamCT := playerTeams{} teamCT.TeamName = gs.TeamCounterTerrorists().ClanName() for _, player := range gs.TeamCounterTerrorists().Members() { - pl := Players{} + pl := players{} pl.PlayerName = player.Name pl.SteamID = int64(player.SteamID64) foundPlayer := false @@ -1368,10 +1274,10 @@ func main() { } currentRound.CTSide = teamCT - teamT := PlayerTeams{} + teamT := playerTeams{} teamT.TeamName = gs.TeamTerrorists().ClanName() for _, player := range gs.TeamTerrorists().Members() { - pl := Players{} + pl := players{} pl.PlayerName = player.Name pl.SteamID = int64(player.SteamID64) foundPlayer := false @@ -1386,22 +1292,30 @@ func main() { } currentRound.TSide = teamT - roundInFreezetime = 0 + *roundInFreezetime = 0 currentRound.FreezeTimeEndTick = int64(gs.IngameTick()) }) +} - p.RegisterEventHandler(func(e events.RoundEndOfficial) { - gs := p.GameState() - currentGame.MatchPhases.RoundEndedOfficial = append(currentGame.MatchPhases.RoundEndedOfficial, int64(gs.IngameTick())) +func registerRoundEndOfficialHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + roundInEndTime *int, roundRestartDelay *int64) { + (*demoParser).RegisterEventHandler(func(e events.RoundEndOfficial) { + gs := (*demoParser).GameState() + currentGame.MatchPhases.RoundEndedOfficial = append(currentGame.MatchPhases.RoundEndedOfficial, + int64(gs.IngameTick())) - if roundInEndTime == 0 { - currentRound.EndTick = int64(gs.IngameTick()) - (RoundRestartDelay * currentGame.TickRate) + if *roundInEndTime == 0 { + currentRound.EndTick = int64(gs.IngameTick()) - (*roundRestartDelay * currentGame.TickRate) currentRound.EndOfficialTick = int64(gs.IngameTick()) - currentRound.CTBuyType = parseTeamBuy(currentRound.CTFreezeTimeEndEqVal, "CT", currentGame.ParsingOpts.RoundBuyStyle) - currentRound.TBuyType = parseTeamBuy(currentRound.TFreezeTimeEndEqVal, "T", currentGame.ParsingOpts.RoundBuyStyle) - // currentRound.CTBuyType = parseTeamBuy(currentRound.CTRoundStartEqVal+currentRound.CTSpend, "CT", currentGame.ParsingOpts.RoundBuyStyle) - // currentRound.TBuyType = parseTeamBuy(currentRound.TRoundStartEqVal+currentRound.TSpend, "T", currentGame.ParsingOpts.RoundBuyStyle) + currentRound.CTBuyType = parseTeamBuy(currentRound.CTFreezeTimeEndEqVal, "CT", + currentGame.ParsingOpts.RoundBuyStyle) + currentRound.TBuyType = parseTeamBuy(currentRound.TFreezeTimeEndEqVal, "T", + currentGame.ParsingOpts.RoundBuyStyle) + // currentRound.CTBuyType = parseTeamBuy(currentRound.CTRoundStartEqVal+currentRound.CTSpend, + // "CT", currentGame.ParsingOpts.RoundBuyStyle) + // currentRound.TBuyType = parseTeamBuy(currentRound.TRoundStartEqVal+currentRound.TSpend, "T", + // currentGame.ParsingOpts.RoundBuyStyle) // Parse who won the round, not great...but a stopgap measure tPlayers := gs.TeamTerrorists().Members() @@ -1410,12 +1324,12 @@ func main() { aliveCT := 0 for _, p := range tPlayers { if p.IsAlive() && p != nil { - aliveT = aliveT + 1 + aliveT++ } } for _, p := range ctPlayers { if p.IsAlive() && p != nil { - aliveCT = aliveCT + 1 + aliveCT++ } } if aliveCT == 0 { @@ -1442,16 +1356,17 @@ func main() { currentRound.WinningSide = "CT" } } else { - currentRound.EndTick = int64(gs.IngameTick()) - (RoundRestartDelay * currentGame.TickRate) currentRound.EndOfficialTick = int64(gs.IngameTick()) } }) +} - // Parse round ends - p.RegisterEventHandler(func(e events.RoundEnd) { - gs := p.GameState() +func registerRoundEndHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + roundStarted *int, roundInEndTime *int, roundRestartDelay *int64) { + (*demoParser).RegisterEventHandler(func(e events.RoundEnd) { + gs := (*demoParser).GameState() - if roundStarted == 1 { + if *roundStarted == 1 { if (gs.TeamTerrorists() != nil) && (gs.TeamCounterTerrorists() != nil) { tTeam := gs.TeamTerrorists().ClanName() ctTeam := gs.TeamCounterTerrorists().ClanName() @@ -1462,8 +1377,8 @@ func main() { currentGame.MatchPhases.RoundEnded = append(currentGame.MatchPhases.RoundEnded, int64(gs.IngameTick())) - if roundStarted == 0 { - roundStarted = 1 + if *roundStarted == 0 { + *roundStarted = 1 currentRound.RoundNum = 0 currentRound.StartTick = 0 @@ -1477,9 +1392,9 @@ func main() { } } - roundInEndTime = 1 + *roundInEndTime = 1 - winningTeam := "CT" + var winningTeam string switch e.Winner { case common.TeamTerrorists: winningTeam = "T" @@ -1489,12 +1404,16 @@ func main() { winningTeam = "CT" currentRound.EndCTScore = currentRound.CTScore + 1 currentRound.EndTScore = currentRound.TScore + case common.TeamSpectators: + winningTeam = "Spectators" + case common.TeamUnassigned: + winningTeam = unassigned default: - winningTeam = "Unknown" + winningTeam = unknown } currentRound.EndTick = int64(gs.IngameTick()) - currentRound.EndOfficialTick = int64(gs.IngameTick()) + (RoundRestartDelay * currentGame.TickRate) + currentRound.EndOfficialTick = int64(gs.IngameTick()) + (*roundRestartDelay * currentGame.TickRate) currentRound.Reason = convertRoundEndReason(e.Reason) currentRound.WinningSide = winningTeam @@ -1511,28 +1430,38 @@ func main() { } } - currentRound.CTBuyType = parseTeamBuy(currentRound.CTFreezeTimeEndEqVal, "CT", currentGame.ParsingOpts.RoundBuyStyle) - currentRound.TBuyType = parseTeamBuy(currentRound.TFreezeTimeEndEqVal, "T", currentGame.ParsingOpts.RoundBuyStyle) - // currentRound.CTBuyType = parseTeamBuy(currentRound.CTRoundStartEqVal+currentRound.CTSpend, "CT", currentGame.ParsingOpts.RoundBuyStyle) - // currentRound.TBuyType = parseTeamBuy(currentRound.TRoundStartEqVal+currentRound.TSpend, "T", currentGame.ParsingOpts.RoundBuyStyle) - + currentRound.CTBuyType = parseTeamBuy(currentRound.CTFreezeTimeEndEqVal, "CT", + currentGame.ParsingOpts.RoundBuyStyle) + currentRound.TBuyType = parseTeamBuy(currentRound.TFreezeTimeEndEqVal, "T", + currentGame.ParsingOpts.RoundBuyStyle) + // currentRound.CTBuyType = parseTeamBuy(currentRound.CTRoundStartEqVal+currentRound.CTSpend, "CT", + // currentGame.ParsingOpts.RoundBuyStyle) + // currentRound.TBuyType = parseTeamBuy(currentRound.TRoundStartEqVal+currentRound.TSpend, "T", + // currentGame.ParsingOpts.RoundBuyStyle) }) +} - // Parse bomb defuses - p.RegisterEventHandler(func(e events.BombDefused) { - gs := p.GameState() +func getBombSite(site rune) string { + switch site { + case rune(events.BombsiteA): + return "A" + case rune(events.BombsiteB): + return "B" + default: + return "" + } +} - currentBomb := BombAction{} +func registerBombDefusedHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombDefused) { + gs := (*demoParser).GameState() + + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) currentBomb.BombAction = "defuse" - bombSite := "" - if e.Site == 65 { - bombSite = "A" - } else if e.Site == 66 { - bombSite = "B" - } + bombSite := getBombSite(rune(e.Site)) currentBomb.BombSite = &bombSite currentBomb.PlayerSteamID = int64(e.Player.SteamID64) @@ -1543,29 +1472,30 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // add bomb event currentRound.Bomb = append(currentRound.Bomb, currentBomb) }) +} - // Parse bomb defuses - p.RegisterEventHandler(func(e events.BombDefuseStart) { - gs := p.GameState() +func registerBombDefuseStartHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombDefuseStart) { + gs := (*demoParser).GameState() - currentBomb := BombAction{} + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) currentBomb.BombAction = "defuse_start" // Find bombsite where event is planted bombSite := "" bombPlantFound := false for _, b := range currentRound.Bomb { - if b.BombAction == "plant" { + if b.BombAction == plant { bombSite = *b.BombSite bombPlantFound = true } @@ -1580,31 +1510,32 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // add if bombPlantFound { currentRound.Bomb = append(currentRound.Bomb, currentBomb) } }) +} - // Parse bomb defuses - p.RegisterEventHandler(func(e events.BombDefuseAborted) { - gs := p.GameState() +func registerBombDefuseAbortHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombDefuseAborted) { + gs := (*demoParser).GameState() - currentBomb := BombAction{} + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) currentBomb.BombAction = "defuse_aborted" // Find bombsite where event is planted bombSite := "" bombPlantFound := false for _, b := range currentRound.Bomb { - if b.BombAction == "plant" { + if b.BombAction == plant { bombSite = *b.BombSite bombPlantFound = true } @@ -1619,51 +1550,52 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // Add Bomb Event if bombPlantFound { currentRound.Bomb = append(currentRound.Bomb, currentBomb) } }) +} - // Parse weapon fires - p.RegisterEventHandler(func(e events.WeaponFire) { - gs := p.GameState() +func registerWeaponFiresHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.WeaponFire) { + gs := (*demoParser).GameState() if (e.Weapon != nil) && (e.Weapon.String() != "Knife") && (e.Weapon.String() != "C4") && (e.Shooter != nil) { - currentWeaponFire := WeaponFireAction{} + currentWeaponFire := weaponFireAction{} currentWeaponFire.Tick = int64(gs.IngameTick()) - currentWeaponFire.Second = determineSecond(currentWeaponFire.Tick, currentRound, currentGame) - currentWeaponFire.ClockTime = calculateClocktime(currentWeaponFire.Tick, currentRound, currentGame) + currentWeaponFire.Second = determineSecond(currentWeaponFire.Tick, *currentRound, currentGame.TickRate) + currentWeaponFire.ClockTime = calculateClocktime(currentWeaponFire.Tick, *currentRound, currentGame.TickRate) currentWeaponFire.PlayerSteamID = int64(e.Shooter.SteamID64) currentWeaponFire.PlayerName = e.Shooter.Name if e.Shooter.TeamState != nil { currentWeaponFire.PlayerTeam = e.Shooter.TeamState.ClanName() } - playerSide := "Unknown" + var playerSide string switch e.Shooter.Team { case common.TeamTerrorists: playerSide = "T" case common.TeamCounterTerrorists: playerSide = "CT" case common.TeamSpectators: - playerSide = "Spectator" + playerSide = spectator case common.TeamUnassigned: - playerSide = "Unassigned" + playerSide = unassigned default: - playerSide = "Unknown" + playerSide = unknown } currentWeaponFire.PlayerSide = playerSide // Player loc playerPos := e.Shooter.LastAlivePosition - currentWeaponFire.PlayerX = float64(playerPos.X) - currentWeaponFire.PlayerY = float64(playerPos.Y) - currentWeaponFire.PlayerZ = float64(playerPos.Z) + currentWeaponFire.PlayerX = playerPos.X + currentWeaponFire.PlayerY = playerPos.Y + currentWeaponFire.PlayerZ = playerPos.Z currentWeaponFire.Weapon = e.Weapon.String() currentWeaponFire.WeaponClass = convertWeaponClass(e.Weapon.Class()) currentWeaponFire.AmmoInMagazine = int64(e.Weapon.AmmoInMagazine()) @@ -1677,16 +1609,17 @@ func main() { currentRound.WeaponFires = append(currentRound.WeaponFires, currentWeaponFire) } }) +} - // Parse player flashes - p.RegisterEventHandler(func(e events.PlayerFlashed) { - gs := p.GameState() +func registerPlayerFlashedHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.PlayerFlashed) { + gs := (*demoParser).GameState() if e.Attacker != nil { - currentFlash := FlashAction{} + currentFlash := flashAction{} currentFlash.Tick = int64(gs.IngameTick()) - currentFlash.Second = determineSecond(currentFlash.Tick, currentRound, currentGame) - currentFlash.ClockTime = calculateClocktime(currentFlash.Tick, currentRound, currentGame) + currentFlash.Second = determineSecond(currentFlash.Tick, *currentRound, currentGame.TickRate) + currentFlash.ClockTime = calculateClocktime(currentFlash.Tick, *currentRound, currentGame.TickRate) // Attacker currentFlash.AttackerSteamID = int64(e.Attacker.SteamID64) @@ -1694,27 +1627,27 @@ func main() { if e.Attacker.TeamState != nil { currentFlash.AttackerTeam = e.Attacker.TeamState.ClanName() } - attackerSide := "Unknown" + var attackerSide string switch e.Attacker.Team { case common.TeamTerrorists: attackerSide = "T" case common.TeamCounterTerrorists: attackerSide = "CT" case common.TeamSpectators: - attackerSide = "Spectator" + attackerSide = spectator case common.TeamUnassigned: - attackerSide = "Unassigned" + attackerSide = unassigned default: - attackerSide = "Unknown" + attackerSide = unknown } currentFlash.AttackerSide = attackerSide // Attacker loc attackerPos := e.Attacker.LastAlivePosition - currentFlash.AttackerX = float64(attackerPos.X) - currentFlash.AttackerY = float64(attackerPos.Y) - currentFlash.AttackerZ = float64(attackerPos.Z) + currentFlash.AttackerX = attackerPos.X + currentFlash.AttackerY = attackerPos.Y + currentFlash.AttackerZ = attackerPos.Z currentFlash.AttackerViewX = float64(e.Attacker.ViewDirectionX()) currentFlash.AttackerViewY = float64(e.Attacker.ViewDirectionY()) @@ -1731,18 +1664,18 @@ func main() { } currentFlash.PlayerTeam = &playerClanName - playerSide := "Unknown" + playerSide := unknown switch e.Player.Team { case common.TeamTerrorists: playerSide = "T" case common.TeamCounterTerrorists: playerSide = "CT" case common.TeamSpectators: - playerSide = "Spectator" + playerSide = spectator case common.TeamUnassigned: - playerSide = "Unassigned" + playerSide = unassigned default: - playerSide = "Unknown" + playerSide = unknown } currentFlash.PlayerSide = &playerSide @@ -1750,9 +1683,9 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - playerX := float64(playerPos.X) - playerY := float64(playerPos.Y) - playerZ := float64(playerPos.Z) + playerX := playerPos.X + playerY := playerPos.Y + playerZ := playerPos.Z currentFlash.PlayerX = &playerX currentFlash.PlayerY = &playerY currentFlash.PlayerZ = &playerZ @@ -1762,35 +1695,33 @@ func main() { currentFlash.PlayerViewY = &playerViewY // Calculate flash duration in seconds - flashDuration := float64(e.Player.FlashDurationTimeRemaining()) / 1000000000 + nanoSecondsPerSecond := 1000000000 + flashDuration := float64(e.Player.FlashDurationTimeRemaining()) / float64(nanoSecondsPerSecond) currentFlash.FlashDuration = &flashDuration // Add to list - if *currentFlash.PlayerSide != "Spectator" && *currentFlash.PlayerSide != "Unassigned" && *currentFlash.PlayerSide != "Unknown" { + if *currentFlash.PlayerSide != spectator && + *currentFlash.PlayerSide != unassigned && + *currentFlash.PlayerSide != unknown { currentRound.Flashes = append(currentRound.Flashes, currentFlash) } } } } - }) +} - // Parse bomb plants - p.RegisterEventHandler(func(e events.BombPlanted) { - gs := p.GameState() +func registerBombPlantedHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombPlanted) { + gs := (*demoParser).GameState() - currentBomb := BombAction{} + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) - currentBomb.BombAction = "plant" + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.BombAction = plant - bombSite := "" - if e.Site == 65 { - bombSite = "A" - } else if e.Site == 66 { - bombSite = "B" - } + bombSite := getBombSite(rune(e.Site)) currentBomb.BombSite = &bombSite currentBomb.PlayerSteamID = int64(e.Player.SteamID64) @@ -1801,32 +1732,28 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // Bomb event currentRound.Bomb = append(currentRound.Bomb, currentBomb) plantTick := int64(gs.IngameTick()) currentRound.BombPlantTick = &plantTick }) +} - // Parse bomb plants - p.RegisterEventHandler(func(e events.BombPlantBegin) { - gs := p.GameState() +func registerBombPlantBeginHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombPlantBegin) { + gs := (*demoParser).GameState() - currentBomb := BombAction{} + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) currentBomb.BombAction = "plant_begin" - bombSite := "" - if e.Site == 65 { - bombSite = "A" - } else if e.Site == 66 { - bombSite = "B" - } + bombSite := getBombSite(rune(e.Site)) currentBomb.BombSite = &bombSite currentBomb.PlayerSteamID = int64(e.Player.SteamID64) @@ -1837,22 +1764,23 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // Bomb event currentRound.Bomb = append(currentRound.Bomb, currentBomb) }) +} - // Parse bomb plants - p.RegisterEventHandler(func(e events.BombPlantAborted) { - gs := p.GameState() +func registerBombPlantAbortedHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.BombPlantAborted) { + gs := (*demoParser).GameState() - currentBomb := BombAction{} + currentBomb := bombAction{} currentBomb.Tick = int64(gs.IngameTick()) - currentBomb.Second = determineSecond(currentBomb.Tick, currentRound, currentGame) - currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, currentRound, currentGame) + currentBomb.Second = determineSecond(currentBomb.Tick, *currentRound, currentGame.TickRate) + currentBomb.ClockTime = calculateClocktime(currentBomb.Tick, *currentRound, currentGame.TickRate) currentBomb.BombAction = "plant_abort" // Find bombsite where event is planted @@ -1874,31 +1802,31 @@ func main() { // Player loc playerPos := e.Player.LastAlivePosition - currentBomb.PlayerX = float64(playerPos.X) - currentBomb.PlayerY = float64(playerPos.Y) - currentBomb.PlayerZ = float64(playerPos.Z) + currentBomb.PlayerX = playerPos.X + currentBomb.PlayerY = playerPos.Y + currentBomb.PlayerZ = playerPos.Z // Add Bomb event if bombPlantFound { currentRound.Bomb = append(currentRound.Bomb, currentBomb) } }) +} - // Parse grenade throws - p.RegisterEventHandler(func(e events.GrenadeProjectileThrow) { - gs := p.GameState() +func registerGrenadeThrowHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.GrenadeProjectileThrow) { + gs := (*demoParser).GameState() if e.Projectile.Thrower != nil { - currentGrenade := GrenadeAction{} + currentGrenade := grenadeAction{} currentGrenade.UniqueID = e.Projectile.UniqueID() currentGrenade.ThrowTick = int64(gs.IngameTick()) - currentGrenade.ThrowSecond = determineSecond(currentGrenade.ThrowTick, currentRound, currentGame) - currentGrenade.ThrowClockTime = calculateClocktime(currentGrenade.ThrowTick, currentRound, currentGame) + currentGrenade.ThrowSecond = determineSecond(currentGrenade.ThrowTick, *currentRound, currentGame.TickRate) + currentGrenade.ThrowClockTime = calculateClocktime(currentGrenade.ThrowTick, *currentRound, currentGame.TickRate) currentGrenade.ThrowerSteamID = int64(e.Projectile.Thrower.SteamID64) currentGrenade.ThrowerName = e.Projectile.Thrower.Name currentGrenade.Grenade = e.Projectile.WeaponInstance.String() - playerSide := "Unknown" tTeam := "" ctTeam := "" @@ -1907,6 +1835,7 @@ func main() { ctTeam = gs.TeamCounterTerrorists().ClanName() } + var playerSide string switch e.Projectile.Thrower.Team { case common.TeamTerrorists: playerSide = "T" @@ -1915,13 +1844,13 @@ func main() { playerSide = "CT" currentGrenade.ThrowerTeam = ctTeam case common.TeamSpectators: - playerSide = "Spectator" + playerSide = spectator currentGrenade.ThrowerTeam = "" case common.TeamUnassigned: - playerSide = "Unassigned" + playerSide = unassigned currentGrenade.ThrowerTeam = "" default: - playerSide = "Unknown" + playerSide = unknown currentGrenade.ThrowerTeam = "" } currentGrenade.ThrowerSide = playerSide @@ -1929,9 +1858,9 @@ func main() { // Player location (use weaponfire event) playerPos := e.Projectile.Position() - currentGrenade.ThrowerX = float64(playerPos.X) - currentGrenade.ThrowerY = float64(playerPos.Y) - currentGrenade.ThrowerZ = float64(playerPos.Z) + currentGrenade.ThrowerX = playerPos.X + currentGrenade.ThrowerY = playerPos.Y + currentGrenade.ThrowerZ = playerPos.Z // Add grenade event if playerSide == "CT" || playerSide == "T" { @@ -1939,46 +1868,51 @@ func main() { } } }) +} - // Parse grenade destroys - p.RegisterEventHandler(func(e events.GrenadeProjectileDestroy) { - gs := p.GameState() +func registerGrenadeDestroyHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.GrenadeProjectileDestroy) { + gs := (*demoParser).GameState() if e.Projectile.Thrower != nil { for i, g := range currentRound.Grenades { if g.UniqueID == e.Projectile.UniqueID() { currentRound.Grenades[i].DestroyTick = int64(gs.IngameTick()) - currentRound.Grenades[i].DestroySecond = determineSecond(currentRound.Grenades[i].DestroyTick, currentRound, currentGame) - currentRound.Grenades[i].DestroyClockTime = calculateClocktime(currentRound.Grenades[i].DestroyTick, currentRound, currentGame) + currentRound.Grenades[i].DestroySecond = determineSecond( + currentRound.Grenades[i].DestroyTick, *currentRound, currentGame.TickRate) + currentRound.Grenades[i].DestroyClockTime = calculateClocktime( + currentRound.Grenades[i].DestroyTick, *currentRound, currentGame.TickRate) // Grenade Location grenadePos := e.Projectile.Position() - currentRound.Grenades[i].GrenadeX = float64(grenadePos.X) - currentRound.Grenades[i].GrenadeY = float64(grenadePos.Y) - currentRound.Grenades[i].GrenadeZ = float64(grenadePos.Z) + currentRound.Grenades[i].GrenadeX = grenadePos.X + currentRound.Grenades[i].GrenadeY = grenadePos.Y + currentRound.Grenades[i].GrenadeZ = grenadePos.Z } } } }) +} - // Parse kill events - p.RegisterEventHandler(func(e events.Kill) { - gs := p.GameState() +func registerKillHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + smokes *[]smoke, roundInFreezetime *int, parseKillFrames *bool) { + (*demoParser).RegisterEventHandler(func(e events.Kill) { + gs := (*demoParser).GameState() - if (roundInFreezetime == 0) && parseKillFrames { - currentFrame := GameFrame{} + if (*roundInFreezetime == 0) && *parseKillFrames { + currentFrame := gameFrame{} currentFrame.IsKillFrame = true // Create empty player lists - currentFrame.CT.Players = []PlayerInfo{} - currentFrame.T.Players = []PlayerInfo{} + currentFrame.CT.Players = []playerInfo{} + currentFrame.T.Players = []playerInfo{} currentFrame.Tick = int64(gs.IngameTick()) - currentFrame.Second = determineSecond(currentFrame.Tick, currentRound, currentGame) - currentFrame.ClockTime = calculateClocktime(currentFrame.Tick, currentRound, currentGame) + currentFrame.Second = determineSecond(currentFrame.Tick, *currentRound, currentGame.TickRate) + currentFrame.ClockTime = calculateClocktime(currentFrame.Tick, *currentRound, currentGame.TickRate) // Parse T - currentFrame.T = TeamFrameInfo{} + currentFrame.T = teamFrameInfo{} currentFrame.T.Side = "T" if gs.TeamTerrorists() != nil { currentFrame.T.Team = gs.TeamTerrorists().ClanName() @@ -1999,7 +1933,7 @@ func main() { // currentFrame.T.CurrentEqVal = sumPlayerEqVal(currentFrame.T.Players) // Parse CT - currentFrame.CT = TeamFrameInfo{} + currentFrame.CT = teamFrameInfo{} currentFrame.CT.Side = "CT" if gs.TeamCounterTerrorists() != nil { currentFrame.CT.Team = gs.TeamCounterTerrorists().ClanName() @@ -2021,48 +1955,48 @@ func main() { // Parse projectiles objects allGrenades := gs.GrenadeProjectiles() - currentFrame.Projectiles = []GrenadeInfo{} + currentFrame.Projectiles = []grenadeInfo{} for _, ele := range allGrenades { - currentProjectile := GrenadeInfo{} + currentProjectile := grenadeInfo{} currentProjectile.ProjectileType = ele.WeaponInstance.String() objPos := ele.Trajectory[len(ele.Trajectory)-1] - currentProjectile.X = float64(objPos.X) - currentProjectile.Y = float64(objPos.Y) - currentProjectile.Z = float64(objPos.Z) + currentProjectile.X = objPos.X + currentProjectile.Y = objPos.Y + currentProjectile.Z = objPos.Z currentFrame.Projectiles = append(currentFrame.Projectiles, currentProjectile) } // Parse infernos allInfernos := gs.Infernos() - currentFrame.Fires = []Fire{} + currentFrame.Fires = []fire{} for _, ele := range allInfernos { - currentFire := Fire{} + currentFire := fire{} objPos := ele.Entity.Position() currentFire.UniqueID = ele.UniqueID() - currentFire.X = float64(objPos.X) - currentFire.Y = float64(objPos.Y) - currentFire.Z = float64(objPos.Z) + currentFire.X = objPos.X + currentFire.Y = objPos.Y + currentFire.Z = objPos.Z currentFrame.Fires = append(currentFrame.Fires, currentFire) } // Parse smokes - currentFrame.Smokes = []Smoke{} - currentFrame.Smokes = smokes + currentFrame.Smokes = []smoke{} + currentFrame.Smokes = *smokes // Parse bomb bombObj := gs.Bomb() - currentBomb := BombInfo{} + currentBomb := bombInfo{} objPos := bombObj.Position() - currentBomb.X = float64(objPos.X) - currentBomb.Y = float64(objPos.Y) - currentBomb.Z = float64(objPos.Z) + currentBomb.X = objPos.X + currentBomb.Y = objPos.Y + currentBomb.Z = objPos.Z currentFrame.Bomb = currentBomb if len(currentRound.Bomb) > 0 { for _, b := range currentRound.Bomb { - if b.BombAction == "plant" { + if b.BombAction == plant { currentFrame.BombPlanted = true currentFrame.BombSite = *b.BombSite } @@ -2074,10 +2008,10 @@ func main() { currentRound.Frames = append(currentRound.Frames, currentFrame) } - currentKill := KillAction{} + currentKill := killAction{} currentKill.Tick = int64(gs.IngameTick()) - currentKill.Second = determineSecond(currentKill.Tick, currentRound, currentGame) - currentKill.ClockTime = calculateClocktime(currentKill.Tick, currentRound, currentGame) + currentKill.Second = determineSecond(currentKill.Tick, *currentRound, currentGame.TickRate) + currentKill.ClockTime = calculateClocktime(currentKill.Tick, *currentRound, currentGame.TickRate) if e.Weapon != nil { currentKill.Weapon = e.Weapon.String() currentKill.WeaponClass = convertWeaponClass(e.Weapon.Class()) @@ -2099,7 +2033,7 @@ func main() { attackerTeamName := e.Killer.TeamState.ClanName() currentKill.AttackerTeam = &attackerTeamName } - attackerSide := "Unknown" + attackerSide := unknown switch e.Killer.Team { case common.TeamTerrorists: @@ -2107,11 +2041,11 @@ func main() { case common.TeamCounterTerrorists: attackerSide = "CT" case common.TeamSpectators: - attackerSide = "Spectator" + attackerSide = spectator case common.TeamUnassigned: - attackerSide = "Unassigned" + attackerSide = unassigned default: - attackerSide = "Unknown" + attackerSide = unknown } currentKill.AttackerSide = &attackerSide @@ -2136,7 +2070,7 @@ func main() { victimTeamName := e.Victim.TeamState.ClanName() currentKill.VictimTeam = &victimTeamName } - victimSide := "Unknown" + victimSide := unknown switch e.Victim.Team { case common.TeamTerrorists: @@ -2144,11 +2078,11 @@ func main() { case common.TeamCounterTerrorists: victimSide = "CT" case common.TeamSpectators: - victimSide = "Spectator" + victimSide = spectator case common.TeamUnassigned: - victimSide = "Unassigned" + victimSide = unassigned default: - victimSide = "Unknown" + victimSide = unknown } currentKill.VictimSide = &victimSide @@ -2193,7 +2127,6 @@ func main() { currentKill.IsTeamkill = true currentKill.IsSuicide = true } - } // Assister @@ -2206,18 +2139,18 @@ func main() { assistTeamName := e.Assister.TeamState.ClanName() currentKill.AssisterTeam = &assistTeamName } - assisterSide := "Unknown" + assisterSide := unknown switch e.Assister.Team { case common.TeamTerrorists: assisterSide = "T" case common.TeamCounterTerrorists: assisterSide = "CT" case common.TeamSpectators: - assisterSide = "Spectator" + assisterSide = spectator case common.TeamUnassigned: - assisterSide = "Unassigned" + assisterSide = unassigned default: - assisterSide = "Unknown" + assisterSide = unknown } currentKill.AssisterSide = &assisterSide } @@ -2227,8 +2160,11 @@ func main() { currentKill.IsFirstKill = true } else { currentKill.IsFirstKill = false - for i := len(currentRound.Kills) - 1; i >= 0 && inTradeWindow(currentRound.Kills[i], currentKill, currentGame.TickRate, currentGame.ParsingOpts.TradeTime) && !currentKill.IsTrade; i-- { - currentKill.IsTrade = isTrade(currentRound.Kills[i], currentKill, currentGame.TickRate, currentGame.ParsingOpts.TradeTime) + for i := len(currentRound.Kills) - 1; i >= 0 && + inTradeWindow(currentRound.Kills[i], currentKill, currentGame.TickRate, + currentGame.ParsingOpts.TradeTime) && !currentKill.IsTrade; i-- { + currentKill.IsTrade = isTrade(currentRound.Kills[i], currentKill, + currentGame.TickRate, currentGame.ParsingOpts.TradeTime) if len(currentRound.Kills) > 0 && e.Victim != nil && currentKill.IsTrade { currentKill.PlayerTradedName = currentRound.Kills[i].VictimName currentKill.PlayerTradedSteamID = currentRound.Kills[i].VictimSteamID @@ -2242,7 +2178,6 @@ func main() { if e.Victim != nil { currentKill.VictimBlinded = e.Victim.IsBlinded() if e.Victim.IsBlinded() { - // This will only be true if in the killfeed the assister is the flasher if e.AssistedFlash { currentKill.AssisterSteamID = nil @@ -2253,7 +2188,10 @@ func main() { // Find their latest flash event for _, flash := range currentRound.Flashes { - if (*flash.PlayerSteamID == *currentKill.VictimSteamID) && (flash.Tick >= currentKill.Tick-5*currentGame.TickRate) && (flash.Tick <= currentKill.Tick) { + flash := flash + if (flash.PlayerSteamID == currentKill.VictimSteamID) && + (flash.Tick >= currentKill.Tick-5*currentGame.TickRate) && + (flash.Tick <= currentKill.Tick) { currentKill.FlashThrowerSteamID = &flash.AttackerSteamID currentKill.FlashThrowerName = &flash.AttackerName currentKill.FlashThrowerTeam = &flash.AttackerTeam @@ -2266,15 +2204,16 @@ func main() { // Add Kill currentRound.Kills = append(currentRound.Kills, currentKill) }) +} - // Parse damage events - p.RegisterEventHandler(func(e events.PlayerHurt) { - gs := p.GameState() +func registerDamageHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound) { + (*demoParser).RegisterEventHandler(func(e events.PlayerHurt) { + gs := (*demoParser).GameState() - currentDamage := DamageAction{} + currentDamage := damageAction{} currentDamage.Tick = int64(gs.IngameTick()) - currentDamage.Second = determineSecond(currentDamage.Tick, currentRound, currentGame) - currentDamage.ClockTime = calculateClocktime(currentDamage.Tick, currentRound, currentGame) + currentDamage.Second = determineSecond(currentDamage.Tick, *currentRound, currentGame.TickRate) + currentDamage.ClockTime = calculateClocktime(currentDamage.Tick, *currentRound, currentGame.TickRate) if e.Weapon != nil { currentDamage.Weapon = e.Weapon.String() currentDamage.WeaponClass = convertWeaponClass(e.Weapon.Class()) @@ -2296,18 +2235,18 @@ func main() { currentDamage.AttackerTeam = &attackerTeamName } - attackerSide := "Unknown" + attackerSide := unknown switch e.Attacker.Team { case common.TeamTerrorists: attackerSide = "T" case common.TeamCounterTerrorists: attackerSide = "CT" case common.TeamSpectators: - attackerSide = "Spectator" + attackerSide = spectator case common.TeamUnassigned: - attackerSide = "Unassigned" + attackerSide = unassigned default: - attackerSide = "Unknown" + attackerSide = unknown } currentDamage.AttackerSide = &attackerSide @@ -2340,18 +2279,18 @@ func main() { currentDamage.VictimTeam = &victimTeamName } - victimSide := "Unknown" + victimSide := unknown switch e.Player.Team { case common.TeamTerrorists: victimSide = "T" case common.TeamCounterTerrorists: victimSide = "CT" case common.TeamSpectators: - victimSide = "Spectator" + victimSide = spectator case common.TeamUnassigned: - victimSide = "Unassigned" + victimSide = unassigned default: - victimSide = "Unknown" + victimSide = unknown } currentDamage.VictimSide = &victimSide @@ -2388,12 +2327,14 @@ func main() { // Add damages currentRound.Damages = append(currentRound.Damages, currentDamage) }) +} - // Parse a demo frame. If parse rate is 1, then every frame is parsed. If parse rate is 2, then every 2 frames is parsed, and so on - p.RegisterEventHandler(func(e events.FrameDone) { - gs := p.GameState() +func registerFrameHandler(demoParser *dem.Parser, currentGame *game, currentRound *gameRound, + smokes *[]smoke, roundInFreezetime *int, roundInEndTime *int, currentFrameIdx *int, parseFrames *bool) { + (*demoParser).RegisterEventHandler(func(e events.FrameDone) { + gs := (*demoParser).GameState() - if (roundInFreezetime == 0) && (roundInEndTime == 0) { + if (*roundInFreezetime == 0) && (*roundInEndTime == 0) { currentRound.CTRoundStartEqVal = int64(gs.TeamCounterTerrorists().RoundStartEquipmentValue()) currentRound.TRoundStartEqVal = int64(gs.TeamTerrorists().RoundStartEquipmentValue()) currentRound.CTFreezeTimeEndEqVal = int64(gs.TeamCounterTerrorists().FreezeTimeEndEquipmentValue()) @@ -2402,20 +2343,20 @@ func main() { currentRound.TRoundMoneySpend = int64(gs.TeamTerrorists().MoneySpentThisRound()) } - if (roundInFreezetime == 0) && (currentFrameIdx == 0) && parseFrames { - currentFrame := GameFrame{} + if (*roundInFreezetime == 0) && (*currentFrameIdx == 0) && *parseFrames { + currentFrame := gameFrame{} currentFrame.IsKillFrame = false // Create empty player lists - currentFrame.CT.Players = []PlayerInfo{} - currentFrame.T.Players = []PlayerInfo{} + currentFrame.CT.Players = []playerInfo{} + currentFrame.T.Players = []playerInfo{} currentFrame.Tick = int64(gs.IngameTick()) - currentFrame.Second = determineSecond(currentFrame.Tick, currentRound, currentGame) - currentFrame.ClockTime = calculateClocktime(currentFrame.Tick, currentRound, currentGame) + currentFrame.Second = determineSecond(currentFrame.Tick, *currentRound, currentGame.TickRate) + currentFrame.ClockTime = calculateClocktime(currentFrame.Tick, *currentRound, currentGame.TickRate) // Parse T - currentFrame.T = TeamFrameInfo{} + currentFrame.T = teamFrameInfo{} currentFrame.T.Side = "T" if gs.TeamTerrorists() != nil { currentFrame.T.Team = gs.TeamTerrorists().ClanName() @@ -2436,7 +2377,7 @@ func main() { // currentFrame.T.CurrentEqVal = sumPlayerEqVal(currentFrame.T.Players) // Parse CT - currentFrame.CT = TeamFrameInfo{} + currentFrame.CT = teamFrameInfo{} currentFrame.CT.Side = "CT" if gs.TeamCounterTerrorists() != nil { currentFrame.CT.Team = gs.TeamCounterTerrorists().ClanName() @@ -2458,48 +2399,48 @@ func main() { // Parse projectiles objects allGrenades := gs.GrenadeProjectiles() - currentFrame.Projectiles = []GrenadeInfo{} + currentFrame.Projectiles = []grenadeInfo{} for _, ele := range allGrenades { - currentProjectile := GrenadeInfo{} + currentProjectile := grenadeInfo{} currentProjectile.ProjectileType = ele.WeaponInstance.String() objPos := ele.Trajectory[len(ele.Trajectory)-1] - currentProjectile.X = float64(objPos.X) - currentProjectile.Y = float64(objPos.Y) - currentProjectile.Z = float64(objPos.Z) + currentProjectile.X = objPos.X + currentProjectile.Y = objPos.Y + currentProjectile.Z = objPos.Z currentFrame.Projectiles = append(currentFrame.Projectiles, currentProjectile) } // Parse infernos allInfernos := gs.Infernos() - currentFrame.Fires = []Fire{} + currentFrame.Fires = []fire{} for _, ele := range allInfernos { - currentFire := Fire{} + currentFire := fire{} objPos := ele.Entity.Position() currentFire.UniqueID = ele.UniqueID() - currentFire.X = float64(objPos.X) - currentFire.Y = float64(objPos.Y) - currentFire.Z = float64(objPos.Z) + currentFire.X = objPos.X + currentFire.Y = objPos.Y + currentFire.Z = objPos.Z currentFrame.Fires = append(currentFrame.Fires, currentFire) } // Parse smokes - currentFrame.Smokes = []Smoke{} - currentFrame.Smokes = smokes + currentFrame.Smokes = []smoke{} + currentFrame.Smokes = *smokes // Parse bomb bombObj := gs.Bomb() - currentBomb := BombInfo{} + currentBomb := bombInfo{} objPos := bombObj.Position() - currentBomb.X = float64(objPos.X) - currentBomb.Y = float64(objPos.Y) - currentBomb.Z = float64(objPos.Z) + currentBomb.X = objPos.X + currentBomb.Y = objPos.Y + currentBomb.Z = objPos.Z currentFrame.Bomb = currentBomb if len(currentRound.Bomb) > 0 { for _, b := range currentRound.Bomb { - if b.BombAction == "plant" { + if b.BombAction == plant { currentFrame.BombPlanted = true currentFrame.BombSite = *b.BombSite } @@ -2519,21 +2460,224 @@ func main() { } } - if currentFrameIdx == (currentGame.ParsingOpts.ParseRate - 1) { - currentFrameIdx = 0 + if *currentFrameIdx == (currentGame.ParsingOpts.ParseRate - 1) { + *currentFrameIdx = 0 } else { - currentFrameIdx = currentFrameIdx + 1 + *currentFrameIdx++ } - } else { - if currentFrameIdx == (currentGame.ParsingOpts.ParseRate - 1) { - currentFrameIdx = 0 + if *currentFrameIdx == (currentGame.ParsingOpts.ParseRate - 1) { + *currentFrameIdx = 0 } else { - currentFrameIdx = currentFrameIdx + 1 + *currentFrameIdx++ } } }) +} + +func cleanAndWriteGame(currentGame *game, jsonIndentation bool, outpath string) { + // Loop through damages and see if there are any multi-damages in a single tick, + // and reduce them to one attacker-victim-weapon entry per tick + if currentGame.ParsingOpts.DamagesRolled { + for i := range currentGame.Rounds { + var tempDamages []damageAction + for j := range currentGame.Rounds[i].Damages { + if j < len(currentGame.Rounds[i].Damages) && j > 0 { + if (len(tempDamages) > 0) && + (currentGame.Rounds[i].Damages[j].Tick == tempDamages[len(tempDamages)-1].Tick) && + (currentGame.Rounds[i].Damages[j].AttackerSteamID == tempDamages[len(tempDamages)-1].AttackerSteamID) && + (currentGame.Rounds[i].Damages[j].VictimSteamID == tempDamages[len(tempDamages)-1].VictimSteamID) && + (currentGame.Rounds[i].Damages[j].Weapon == tempDamages[len(tempDamages)-1].Weapon) { + tempDamages[len(tempDamages)-1].HpDamage += currentGame.Rounds[i].Damages[j].HpDamage + tempDamages[len(tempDamages)-1].HpDamageTaken += currentGame.Rounds[i].Damages[j].HpDamageTaken + tempDamages[len(tempDamages)-1].ArmorDamage += currentGame.Rounds[i].Damages[j].ArmorDamage + tempDamages[len(tempDamages)-1].ArmorDamageTaken += currentGame.Rounds[i].Damages[j].ArmorDamageTaken + } else { + tempDamages = append(tempDamages, currentGame.Rounds[i].Damages[j]) + } + } else { + tempDamages = append(tempDamages, currentGame.Rounds[i].Damages[j]) + } + } + currentGame.Rounds[i].Damages = tempDamages + } + } + + // Write the JSON + var file []byte + var err error + if jsonIndentation { + file, err = json.MarshalIndent(currentGame, "", " ") + } else { + file, err = json.Marshal(currentGame) + } + checkError(err) + _ = os.WriteFile(outpath+"/"+currentGame.MatchName+".json", file, 0600) +} + +func ParseDemo(demPath string, demoID string, parseRate int, parseFrames bool, parseKillFrames bool, tradeTime int64, roundBuyStyle string, damagesRolled bool, jsonIndentation bool, parseChat bool, outpath string) { + // fl := new(flag.FlagSet) + // demoPathPtr := fl.String("demo", "", "Demo file `path`") + // parseRatePtr := fl.Int("parserate", 128, "Parse rate, indicates spacing between ticks") + // parseFramesPtr := fl.Bool("parseframes", false, "Parse frames") + // parseKillFramesPtr := fl.Bool("parsekillframes", false, "Parse kill frames") + // tradeTimePtr := fl.Int("tradetime", 5, "Trade time frame (in seconds)") + // roundBuyPtr := fl.String("buystyle", "hltv", "Round buy style") + // damagesRolledPtr := fl.Bool("dmgrolled", false, "Roll up damages") + // demoIDPtr := fl.String("demoid", "", "Demo string ID") + // jsonIndentationPtr := fl.Bool("jsonindentation", false, "Indent JSON file") + // parseChatPtr := fl.Bool("parsechat", false, "Parse chat messages") + // outpathPtr := fl.String("out", "", "Path to write output JSON") + + // err := fl.Parse(os.Args[1:]) + // checkError(err) + + // demPath := *demoPathPtr + // parseRate := *parseRatePtr + // parseFrames := *parseFramesPtr + // parseKillFrames := *parseKillFramesPtr + // tradeTime := int64(*tradeTimePtr) + // roundBuyStyle := *roundBuyPtr + // damagesRolled := *damagesRolledPtr + // jsonIndentation := *jsonIndentationPtr + // parseChat := *parseChatPtr + // outpath := *outpathPtr + + // Read in demofile + f, err := os.Open(demPath) + checkError(err) + defer f.Close() + + // Create new demoparser + p := dem.NewParser(f) + defer p.Close() + + // Parse demofile header + header, err := p.ParseHeader() + checkError(err) + + // Parse nav mesh given the map name + currentMap := header.MapName + currentMap = cleanMapName(currentMap) + + // Create flags to guide parsing + roundStarted := 0 + roundInEndTime := 0 + roundInFreezetime := 0 + currentFrameIdx := 0 + convParsed := 0 + // Create game object, then initial round object + currentGame := game{} + currentGame.MatchName = demoID + currentGame.Map = cleanMapName(currentMap) + if p.TickRate() == 0 { + currentGame.TickRate = 128 + } else { + currentGame.TickRate = int64(math.Round(p.TickRate())) // Rounds to 127 instead + } + currentGame.PlaybackTicks = int64(header.PlaybackTicks) + currentGame.PlaybackFrames = int64(header.PlaybackFrames) + currentGame.ClientName = header.ClientName + + // Create empty smoke tracking list + smokes := []smoke{} + + // Set parsing options + parsingOpts := parserOpts{} + parsingOpts.ParseRate = parseRate + parsingOpts.ParseFrames = parseFrames + parsingOpts.ParseKillFrames = parseKillFrames + parsingOpts.TradeTime = tradeTime + parsingOpts.RoundBuyStyle = roundBuyStyle + parsingOpts.DamagesRolled = damagesRolled + parsingOpts.ParseChat = parseChat + currentGame.ParsingOpts = parsingOpts + + currentRound := gameRound{} + + // Create empty action lists for first round + initializeRound(¤tRound) + + RoundRestartDelay := int64(5) + + // Create empty lists + currentGame.MMRanks = []mMRank{} + currentGame.Chat = []chat{} + currentGame.MatchPhases.AnnFinalRound = []int64{} + currentGame.MatchPhases.AnnLastRoundHalf = []int64{} + currentGame.MatchPhases.AnnMatchStarted = []int64{} + currentGame.MatchPhases.GameHalfEnded = []int64{} + currentGame.MatchPhases.MatchStart = []int64{} + currentGame.MatchPhases.MatchStartedChanged = []int64{} + currentGame.MatchPhases.WarmupChanged = []int64{} + currentGame.MatchPhases.TeamSwitch = []int64{} + currentGame.MatchPhases.RoundStarted = []int64{} + currentGame.MatchPhases.RoundFreezeEnded = []int64{} + currentGame.MatchPhases.RoundEnded = []int64{} + currentGame.MatchPhases.RoundEndedOfficial = []int64{} + + // Parse rank updates + registerRankUpdateHandler(&p, ¤tGame) + + if parseChat { + registerChatHandlers(&p, ¤tGame) + } + + // Parse player connects + registerConnectHandler(&p, ¤tGame) + + // Parse player disconnects + registerDisonnectHandler(&p, ¤tGame) + + // Parse the match phases + registerMatchphases(&p, ¤tGame) + + // Parse smokes + registerSmokeHandler(&p, &smokes) + + // Parse round starts + registerRoundStartHandler(&p, ¤tGame, ¤tRound, + &roundStarted, &roundInFreezetime, &roundInEndTime, &smokes) + registerRoundFreezeTimeEndHandler(&p, ¤tGame, ¤tRound, &convParsed, + &RoundRestartDelay, &roundStarted, &roundInFreezetime, &roundInEndTime, &smokes) + + // Parse round ends + registerRoundEndOfficialHandler(&p, ¤tGame, ¤tRound, &roundInEndTime, &RoundRestartDelay) + registerRoundEndHandler(&p, ¤tGame, ¤tRound, &roundStarted, &roundInEndTime, &RoundRestartDelay) + + // Parse bomb defuses + registerBombDefusedHandler(&p, ¤tGame, ¤tRound) + registerBombDefuseStartHandler(&p, ¤tGame, ¤tRound) + registerBombDefuseAbortHandler(&p, ¤tGame, ¤tRound) + + // Parse weapon fires + registerWeaponFiresHandler(&p, ¤tGame, ¤tRound) + + // Parse player flashes + registerPlayerFlashedHandler(&p, ¤tGame, ¤tRound) + + // Parse bomb plants + registerBombPlantedHandler(&p, ¤tGame, ¤tRound) + registerBombPlantBeginHandler(&p, ¤tGame, ¤tRound) + registerBombPlantAbortedHandler(&p, ¤tGame, ¤tRound) + + // Parse grenade throws + registerGrenadeThrowHandler(&p, ¤tGame, ¤tRound) + + // Parse grenade destroys + registerGrenadeDestroyHandler(&p, ¤tGame, ¤tRound) + + // Parse kill events + registerKillHandler(&p, ¤tGame, ¤tRound, &smokes, &roundInEndTime, &parseKillFrames) + + // Parse damage events + registerDamageHandler(&p, ¤tGame, ¤tRound) + + // Parse a demo frame. If parse rate is 1, then every frame is parsed. + // If parse rate is 2, then every 2 frames is parsed, and so on + registerFrameHandler(&p, ¤tGame, ¤tRound, &smokes, + &roundInFreezetime, &roundInEndTime, ¤tFrameIdx, &parseFrames) // Parse demofile to end err = p.ParseToEnd() currentGame.ParsedToFrame = int64(p.CurrentFrame()) @@ -2543,49 +2687,17 @@ func main() { // Clean rounds if len(currentGame.Rounds) > 0 { - // Loop through damages and see if there are any multi-damages in a single tick, and reduce them to one attacker-victim-weapon entry per tick - if currentGame.ParsingOpts.DamagesRolled { - for i := range currentGame.Rounds { - var tempDamages []DamageAction - for j := range currentGame.Rounds[i].Damages { - if j < len(currentGame.Rounds[i].Damages) && j > 0 { - if (len(tempDamages) > 0) && - (currentGame.Rounds[i].Damages[j].Tick == tempDamages[len(tempDamages)-1].Tick) && - (currentGame.Rounds[i].Damages[j].AttackerSteamID == tempDamages[len(tempDamages)-1].AttackerSteamID) && - (currentGame.Rounds[i].Damages[j].VictimSteamID == tempDamages[len(tempDamages)-1].VictimSteamID) && - (currentGame.Rounds[i].Damages[j].Weapon == tempDamages[len(tempDamages)-1].Weapon) { - tempDamages[len(tempDamages)].HpDamage = tempDamages[len(tempDamages)-1].HpDamage + currentGame.Rounds[i].Damages[j].HpDamage - tempDamages[len(tempDamages)].HpDamageTaken = tempDamages[len(tempDamages)-1].HpDamageTaken + currentGame.Rounds[i].Damages[j].HpDamageTaken - tempDamages[len(tempDamages)].ArmorDamage = tempDamages[len(tempDamages)-1].ArmorDamage + currentGame.Rounds[i].Damages[j].ArmorDamage - tempDamages[len(tempDamages)].ArmorDamageTaken = tempDamages[len(tempDamages)-1].ArmorDamageTaken + currentGame.Rounds[i].Damages[j].ArmorDamageTaken - } else { - tempDamages = append(tempDamages, currentGame.Rounds[i].Damages[j]) - } - } else { - tempDamages = append(tempDamages, currentGame.Rounds[i].Damages[j]) - } - } - currentGame.Rounds[i].Damages = tempDamages - } - } - - // Write the JSON - var file []byte - if jsonIndentation { - file, _ = json.MarshalIndent(currentGame, "", " ") - } else { - file, _ = json.Marshal(currentGame) - } - _ = os.WriteFile(outpath+"/"+currentGame.MatchName+".json", file, 0644) + cleanAndWriteGame(¤tGame, jsonIndentation, outpath) } // Check error checkError(err) } -// Function to handle errors +// Function to handle errors. func checkError(err error) { if err != nil { panic(err) } + } diff --git a/awpy/parser/demoparser.py b/awpy/parser/demoparser.py index dccfc7565..1e4cd7fc2 100644 --- a/awpy/parser/demoparser.py +++ b/awpy/parser/demoparser.py @@ -29,6 +29,7 @@ import pandas as pd +from awpy.parser.awpygo import awpygo from awpy.types import ColsType, Game from awpy.utils import check_go_version @@ -376,6 +377,19 @@ def parse_demo(self) -> None: cwd=path, ) stdout = proc.stdout.read().splitlines() if proc.stdout is not None else None + awpygo.ParseDemo( + self.demofile, + self.demo_id, + self.parse_rate, + self.parse_frames, + self.parse_kill_frames, + self.trade_time, + self.buy_style, + self.dmg_rolled, + self.json_indentation, + self.parse_chat, + self.outpath, + ) self.output_file = self.demo_id + ".json" if os.path.isfile(self.outpath + "/" + self.output_file): self.logger.info("Wrote demo parse output to %s", self.output_file) diff --git a/pyproject.toml b/pyproject.toml index f56699855..6e6a4e7ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -121,6 +121,7 @@ exclude = [ "node_modules", "venv", "docs", + "awpy/parser/awpygo" ] # Same as Black. @@ -146,7 +147,7 @@ convention = "google" # Accepts: "google", "numpy", or "pep257". [tool.pyright] include = ["awpy"] -exclude = ["tests"] +exclude = ["tests", "awpy/parser/awpygo"] strictListInference = true strictDictionaryInference = true strictSetInference = true