LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - py_echo.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 312 3128 10.0 %
Date: 2024-04-21 15:09:00 Functions: 20 236 8.5 %

          Line data    Source code
       1             : 
       2             : /* Python wrapper functions auto-generated by pidl */
       3             : #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
       4             : #include "lib/replace/system/python.h"
       5             : #include "python/py3compat.h"
       6             : #include "includes.h"
       7             : #include "python/modules.h"
       8             : #include <pytalloc.h>
       9             : #include "librpc/rpc/pyrpc.h"
      10             : #include "librpc/rpc/pyrpc_util.h"
      11             : #include "bin/default/librpc/gen_ndr/ndr_echo.h"
      12             : #include "bin/default/librpc/gen_ndr/ndr_echo_c.h"
      13             : 
      14             : /*
      15             :  * Suppress compiler warnings if the generated code does not call these
      16             :  * functions
      17             :  */
      18             : #ifndef _MAYBE_UNUSED_
      19             : #ifdef __has_attribute
      20             : #if __has_attribute(unused)
      21             : #define _MAYBE_UNUSED_ __attribute__ ((unused))
      22             : #else
      23             : #define _MAYBE_UNUSED_
      24             : #endif
      25             : #endif
      26             : #endif
      27             : /*
      28             :  * These functions are here to ensure they can be optimized out by
      29             :  * the compiler based on the constant input values
      30             :  */
      31             : 
      32          29 : static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
      33             : {
      34          29 :         switch (var_size) {
      35           0 :         case 8:
      36           0 :                 return UINT64_MAX;
      37           3 :         case 4:
      38           3 :                 return UINT32_MAX;
      39           4 :         case 2:
      40           4 :                 return UINT16_MAX;
      41          22 :         case 1:
      42          22 :                 return UINT8_MAX;
      43             :         }
      44             : 
      45           0 :         return 0;
      46             : }
      47             : 
      48             : static inline _MAYBE_UNUSED_ long long ndr_sizeof2intmax(size_t var_size)
      49             : {
      50             :         switch (var_size) {
      51             :         case 8:
      52             :                 return INT64_MAX;
      53             :         case 4:
      54             :                 return INT32_MAX;
      55             :         case 2:
      56             :                 return INT16_MAX;
      57             :         case 1:
      58             :                 return INT8_MAX;
      59             :         }
      60             : 
      61             :         return 0;
      62             : }
      63             : 
      64             : static PyTypeObject echo_info1_Type;
      65             : static PyTypeObject echo_info2_Type;
      66             : static PyTypeObject echo_info3_Type;
      67             : static PyTypeObject echo_info4_Type;
      68             : static PyTypeObject echo_info5_Type;
      69             : static PyTypeObject echo_info6_Type;
      70             : static PyTypeObject echo_info7_Type;
      71             : static PyTypeObject echo_Info_Type;
      72             : static PyTypeObject echo_Enum2_Type;
      73             : static PyTypeObject echo_Enum3_Type;
      74             : static PyTypeObject echo_Surrounding_Type;
      75             : static PyTypeObject rpcecho_InterfaceType;
      76             : static PyTypeObject echo_AddOne_Type;
      77             : static PyTypeObject echo_EchoData_Type;
      78             : static PyTypeObject echo_SinkData_Type;
      79             : static PyTypeObject echo_SourceData_Type;
      80             : static PyTypeObject echo_TestCall_Type;
      81             : static PyTypeObject echo_TestCall2_Type;
      82             : static PyTypeObject echo_TestSleep_Type;
      83             : static PyTypeObject echo_TestEnum_Type;
      84             : static PyTypeObject echo_TestSurrounding_Type;
      85             : static PyTypeObject echo_TestDoublePointer_Type;
      86             : 
      87             : static PyTypeObject *BaseObject_Type;
      88             : static PyTypeObject *ndr_pointer_Type;
      89             : static PyTypeObject *ClientConnection_Type;
      90             : static PyTypeObject *ndr_syntax_id_Type;
      91             : 
      92           1 : static PyObject *py_echo_info1_get_v(PyObject *obj, void *closure)
      93             : {
      94           1 :         struct echo_info1 *object = pytalloc_get_ptr(obj);
      95             :         PyObject *py_v;
      96           1 :         py_v = PyLong_FromLong((uint16_t)(object->v));
      97           1 :         return py_v;
      98             : }
      99             : 
     100           1 : static int py_echo_info1_set_v(PyObject *py_obj, PyObject *value, void *closure)
     101             : {
     102           1 :         struct echo_info1 *object = pytalloc_get_ptr(py_obj);
     103           1 :         if (value == NULL) {
     104           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v");
     105           0 :                 return -1;
     106             :         }
     107             :         {
     108           1 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
     109           1 :                 if (PyLong_Check(value)) {
     110             :                         unsigned long long test_var;
     111           1 :                         test_var = PyLong_AsUnsignedLongLong(value);
     112           1 :                         if (PyErr_Occurred() != NULL) {
     113           0 :                                 return -1;
     114             :                         }
     115           1 :                         if (test_var > uint_max) {
     116           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     117             :                                   PyLong_Type.tp_name, uint_max, test_var);
     118           0 :                                 return -1;
     119             :                         }
     120           1 :                         object->v = test_var;
     121             :                 } else {
     122           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     123             :                           PyLong_Type.tp_name);
     124           0 :                         return -1;
     125             :                 }
     126             :         }
     127           1 :         return 0;
     128             : }
     129             : 
     130             : static PyGetSetDef py_echo_info1_getsetters[] = {
     131             :         {
     132             :                 .name = discard_const_p(char, "v"),
     133             :                 .get = py_echo_info1_get_v,
     134             :                 .set = py_echo_info1_set_v,
     135             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     136             :         },
     137             :         { .name = NULL }
     138             : };
     139             : 
     140           2 : static PyObject *py_echo_info1_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     141             : {
     142           2 :         return pytalloc_new(struct echo_info1, type);
     143             : }
     144             : 
     145           1 : static PyObject *py_echo_info1_ndr_pack(PyObject *py_obj,  PyObject *Py_UNUSED(ignored))
     146             : {
     147           1 :         struct echo_info1 *object = pytalloc_get_ptr(py_obj);
     148           1 :         PyObject *ret = NULL;
     149             :         DATA_BLOB blob;
     150             :         enum ndr_err_code err;
     151           1 :         TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
     152           1 :         if (tmp_ctx == NULL) {
     153           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
     154           0 :                 return NULL;
     155             :         }
     156           1 :         err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_echo_info1);
     157           1 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     158           0 :                 TALLOC_FREE(tmp_ctx);
     159           0 :                 PyErr_SetNdrError(err);
     160           0 :                 return NULL;
     161             :         }
     162             : 
     163           1 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
     164           1 :         TALLOC_FREE(tmp_ctx);
     165           1 :         return ret;
     166             : }
     167             : 
     168           1 : static PyObject *py_echo_info1_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
     169             : {
     170           1 :         struct echo_info1 *object = pytalloc_get_ptr(py_obj);
     171           1 :         DATA_BLOB blob = {.data = NULL, .length = 0};
     172           1 :         Py_ssize_t blob_length = 0;
     173             :         enum ndr_err_code err;
     174           1 :         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
     175           1 :         PyObject *allow_remaining_obj = NULL;
     176           1 :         bool allow_remaining = false;
     177             : 
     178           1 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
     179             :                 discard_const_p(char *, kwnames),
     180             :                 &blob.data, &blob_length,
     181             :                 &allow_remaining_obj)) {
     182           0 :                 return NULL;
     183             :         }
     184           1 :         blob.length = blob_length;
     185             : 
     186           1 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
     187           0 :                 allow_remaining = true;
     188             :         }
     189             : 
     190           1 :         if (allow_remaining) {
     191           0 :                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_echo_info1);
     192             :         } else {
     193           1 :                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_echo_info1);
     194             :         }
     195           1 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     196           0 :                 PyErr_SetNdrError(err);
     197           0 :                 return NULL;
     198             :         }
     199             : 
     200           1 :         Py_RETURN_NONE;
     201             : }
     202             : 
     203           0 : static PyObject *py_echo_info1_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
     204             : {
     205           0 :         struct echo_info1 *object = pytalloc_get_ptr(py_obj);
     206             :         PyObject *ret;
     207             :         char *retstr;
     208             : 
     209           0 :         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_echo_info1, "echo_info1", object);
     210           0 :         ret = PyUnicode_FromString(retstr);
     211           0 :         talloc_free(retstr);
     212             : 
     213           0 :         return ret;
     214             : }
     215             : 
     216             : static PyMethodDef py_echo_info1_methods[] = {
     217             :         { "__ndr_pack__", (PyCFunction)py_echo_info1_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
     218             :         { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_info1_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
     219             :         { "__ndr_print__", (PyCFunction)py_echo_info1_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
     220             :         { NULL, NULL, 0, NULL }
     221             : };
     222             : 
     223             : 
     224             : static PyTypeObject echo_info1_Type = {
     225             :         PyVarObject_HEAD_INIT(NULL, 0)
     226             :         .tp_name = "echo.info1",
     227             :         .tp_getset = py_echo_info1_getsetters,
     228             :         .tp_methods = py_echo_info1_methods,
     229             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     230             :         .tp_new = py_echo_info1_new,
     231             : };
     232             : 
     233             : 
     234           0 : static PyObject *py_echo_info2_get_v(PyObject *obj, void *closure)
     235             : {
     236           0 :         struct echo_info2 *object = pytalloc_get_ptr(obj);
     237             :         PyObject *py_v;
     238           0 :         py_v = PyLong_FromLong((uint16_t)(object->v));
     239           0 :         return py_v;
     240             : }
     241             : 
     242           0 : static int py_echo_info2_set_v(PyObject *py_obj, PyObject *value, void *closure)
     243             : {
     244           0 :         struct echo_info2 *object = pytalloc_get_ptr(py_obj);
     245           0 :         if (value == NULL) {
     246           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v");
     247           0 :                 return -1;
     248             :         }
     249             :         {
     250           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
     251           0 :                 if (PyLong_Check(value)) {
     252             :                         unsigned long long test_var;
     253           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     254           0 :                         if (PyErr_Occurred() != NULL) {
     255           0 :                                 return -1;
     256             :                         }
     257           0 :                         if (test_var > uint_max) {
     258           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     259             :                                   PyLong_Type.tp_name, uint_max, test_var);
     260           0 :                                 return -1;
     261             :                         }
     262           0 :                         object->v = test_var;
     263             :                 } else {
     264           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     265             :                           PyLong_Type.tp_name);
     266           0 :                         return -1;
     267             :                 }
     268             :         }
     269           0 :         return 0;
     270             : }
     271             : 
     272             : static PyGetSetDef py_echo_info2_getsetters[] = {
     273             :         {
     274             :                 .name = discard_const_p(char, "v"),
     275             :                 .get = py_echo_info2_get_v,
     276             :                 .set = py_echo_info2_set_v,
     277             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     278             :         },
     279             :         { .name = NULL }
     280             : };
     281             : 
     282           0 : static PyObject *py_echo_info2_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     283             : {
     284           0 :         return pytalloc_new(struct echo_info2, type);
     285             : }
     286             : 
     287             : 
     288             : static PyTypeObject echo_info2_Type = {
     289             :         PyVarObject_HEAD_INIT(NULL, 0)
     290             :         .tp_name = "echo.info2",
     291             :         .tp_getset = py_echo_info2_getsetters,
     292             :         .tp_methods = NULL,
     293             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     294             :         .tp_new = py_echo_info2_new,
     295             : };
     296             : 
     297             : 
     298           0 : static PyObject *py_echo_info3_get_v(PyObject *obj, void *closure)
     299             : {
     300           0 :         struct echo_info3 *object = pytalloc_get_ptr(obj);
     301             :         PyObject *py_v;
     302           0 :         py_v = PyLong_FromUnsignedLongLong((uint32_t)(object->v));
     303           0 :         return py_v;
     304             : }
     305             : 
     306           0 : static int py_echo_info3_set_v(PyObject *py_obj, PyObject *value, void *closure)
     307             : {
     308           0 :         struct echo_info3 *object = pytalloc_get_ptr(py_obj);
     309           0 :         if (value == NULL) {
     310           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v");
     311           0 :                 return -1;
     312             :         }
     313             :         {
     314           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
     315           0 :                 if (PyLong_Check(value)) {
     316             :                         unsigned long long test_var;
     317           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     318           0 :                         if (PyErr_Occurred() != NULL) {
     319           0 :                                 return -1;
     320             :                         }
     321           0 :                         if (test_var > uint_max) {
     322           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     323             :                                   PyLong_Type.tp_name, uint_max, test_var);
     324           0 :                                 return -1;
     325             :                         }
     326           0 :                         object->v = test_var;
     327             :                 } else {
     328           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     329             :                           PyLong_Type.tp_name);
     330           0 :                         return -1;
     331             :                 }
     332             :         }
     333           0 :         return 0;
     334             : }
     335             : 
     336             : static PyGetSetDef py_echo_info3_getsetters[] = {
     337             :         {
     338             :                 .name = discard_const_p(char, "v"),
     339             :                 .get = py_echo_info3_get_v,
     340             :                 .set = py_echo_info3_set_v,
     341             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     342             :         },
     343             :         { .name = NULL }
     344             : };
     345             : 
     346           0 : static PyObject *py_echo_info3_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     347             : {
     348           0 :         return pytalloc_new(struct echo_info3, type);
     349             : }
     350             : 
     351             : 
     352             : static PyTypeObject echo_info3_Type = {
     353             :         PyVarObject_HEAD_INIT(NULL, 0)
     354             :         .tp_name = "echo.info3",
     355             :         .tp_getset = py_echo_info3_getsetters,
     356             :         .tp_methods = NULL,
     357             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     358             :         .tp_new = py_echo_info3_new,
     359             : };
     360             : 
     361             : 
     362           0 : static PyObject *py_echo_info4_get_v(PyObject *obj, void *closure)
     363             : {
     364           0 :         struct echo_info4 *object = pytalloc_get_ptr(obj);
     365             :         PyObject *py_v;
     366           0 :         py_v = PyLong_FromUnsignedLongLong(object->v);
     367           0 :         return py_v;
     368             : }
     369             : 
     370           0 : static int py_echo_info4_set_v(PyObject *py_obj, PyObject *value, void *closure)
     371             : {
     372           0 :         struct echo_info4 *object = pytalloc_get_ptr(py_obj);
     373           0 :         if (value == NULL) {
     374           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v");
     375           0 :                 return -1;
     376             :         }
     377             :         {
     378           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v));
     379           0 :                 if (PyLong_Check(value)) {
     380             :                         unsigned long long test_var;
     381           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     382           0 :                         if (PyErr_Occurred() != NULL) {
     383           0 :                                 return -1;
     384             :                         }
     385           0 :                         if (test_var > uint_max) {
     386           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     387             :                                   PyLong_Type.tp_name, uint_max, test_var);
     388           0 :                                 return -1;
     389             :                         }
     390           0 :                         object->v = test_var;
     391             :                 } else {
     392           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     393             :                           PyLong_Type.tp_name);
     394           0 :                         return -1;
     395             :                 }
     396             :         }
     397           0 :         return 0;
     398             : }
     399             : 
     400             : static PyGetSetDef py_echo_info4_getsetters[] = {
     401             :         {
     402             :                 .name = discard_const_p(char, "v"),
     403             :                 .get = py_echo_info4_get_v,
     404             :                 .set = py_echo_info4_set_v,
     405             :                 .doc = discard_const_p(char, "PIDL-generated element of base type hyper")
     406             :         },
     407             :         { .name = NULL }
     408             : };
     409             : 
     410           0 : static PyObject *py_echo_info4_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     411             : {
     412           0 :         return pytalloc_new(struct echo_info4, type);
     413             : }
     414             : 
     415             : 
     416             : static PyTypeObject echo_info4_Type = {
     417             :         PyVarObject_HEAD_INIT(NULL, 0)
     418             :         .tp_name = "echo.info4",
     419             :         .tp_getset = py_echo_info4_getsetters,
     420             :         .tp_methods = NULL,
     421             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     422             :         .tp_new = py_echo_info4_new,
     423             : };
     424             : 
     425             : 
     426           0 : static PyObject *py_echo_info5_get_v1(PyObject *obj, void *closure)
     427             : {
     428           0 :         struct echo_info5 *object = pytalloc_get_ptr(obj);
     429             :         PyObject *py_v1;
     430           0 :         py_v1 = PyLong_FromLong((uint16_t)(object->v1));
     431           0 :         return py_v1;
     432             : }
     433             : 
     434           0 : static int py_echo_info5_set_v1(PyObject *py_obj, PyObject *value, void *closure)
     435             : {
     436           0 :         struct echo_info5 *object = pytalloc_get_ptr(py_obj);
     437           0 :         if (value == NULL) {
     438           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v1");
     439           0 :                 return -1;
     440             :         }
     441             :         {
     442           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
     443           0 :                 if (PyLong_Check(value)) {
     444             :                         unsigned long long test_var;
     445           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     446           0 :                         if (PyErr_Occurred() != NULL) {
     447           0 :                                 return -1;
     448             :                         }
     449           0 :                         if (test_var > uint_max) {
     450           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     451             :                                   PyLong_Type.tp_name, uint_max, test_var);
     452           0 :                                 return -1;
     453             :                         }
     454           0 :                         object->v1 = test_var;
     455             :                 } else {
     456           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     457             :                           PyLong_Type.tp_name);
     458           0 :                         return -1;
     459             :                 }
     460             :         }
     461           0 :         return 0;
     462             : }
     463             : 
     464           0 : static PyObject *py_echo_info5_get_v2(PyObject *obj, void *closure)
     465             : {
     466           0 :         struct echo_info5 *object = pytalloc_get_ptr(obj);
     467             :         PyObject *py_v2;
     468           0 :         py_v2 = PyLong_FromUnsignedLongLong(object->v2);
     469           0 :         return py_v2;
     470             : }
     471             : 
     472           0 : static int py_echo_info5_set_v2(PyObject *py_obj, PyObject *value, void *closure)
     473             : {
     474           0 :         struct echo_info5 *object = pytalloc_get_ptr(py_obj);
     475           0 :         if (value == NULL) {
     476           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v2");
     477           0 :                 return -1;
     478             :         }
     479             :         {
     480           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v2));
     481           0 :                 if (PyLong_Check(value)) {
     482             :                         unsigned long long test_var;
     483           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     484           0 :                         if (PyErr_Occurred() != NULL) {
     485           0 :                                 return -1;
     486             :                         }
     487           0 :                         if (test_var > uint_max) {
     488           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     489             :                                   PyLong_Type.tp_name, uint_max, test_var);
     490           0 :                                 return -1;
     491             :                         }
     492           0 :                         object->v2 = test_var;
     493             :                 } else {
     494           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     495             :                           PyLong_Type.tp_name);
     496           0 :                         return -1;
     497             :                 }
     498             :         }
     499           0 :         return 0;
     500             : }
     501             : 
     502             : static PyGetSetDef py_echo_info5_getsetters[] = {
     503             :         {
     504             :                 .name = discard_const_p(char, "v1"),
     505             :                 .get = py_echo_info5_get_v1,
     506             :                 .set = py_echo_info5_set_v1,
     507             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     508             :         },
     509             :         {
     510             :                 .name = discard_const_p(char, "v2"),
     511             :                 .get = py_echo_info5_get_v2,
     512             :                 .set = py_echo_info5_set_v2,
     513             :                 .doc = discard_const_p(char, "PIDL-generated element of base type hyper")
     514             :         },
     515             :         { .name = NULL }
     516             : };
     517             : 
     518           0 : static PyObject *py_echo_info5_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     519             : {
     520           0 :         return pytalloc_new(struct echo_info5, type);
     521             : }
     522             : 
     523             : 
     524             : static PyTypeObject echo_info5_Type = {
     525             :         PyVarObject_HEAD_INIT(NULL, 0)
     526             :         .tp_name = "echo.info5",
     527             :         .tp_getset = py_echo_info5_getsetters,
     528             :         .tp_methods = NULL,
     529             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     530             :         .tp_new = py_echo_info5_new,
     531             : };
     532             : 
     533             : 
     534           0 : static PyObject *py_echo_info6_get_v1(PyObject *obj, void *closure)
     535             : {
     536           0 :         struct echo_info6 *object = pytalloc_get_ptr(obj);
     537             :         PyObject *py_v1;
     538           0 :         py_v1 = PyLong_FromLong((uint16_t)(object->v1));
     539           0 :         return py_v1;
     540             : }
     541             : 
     542           0 : static int py_echo_info6_set_v1(PyObject *py_obj, PyObject *value, void *closure)
     543             : {
     544           0 :         struct echo_info6 *object = pytalloc_get_ptr(py_obj);
     545           0 :         if (value == NULL) {
     546           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v1");
     547           0 :                 return -1;
     548             :         }
     549             :         {
     550           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
     551           0 :                 if (PyLong_Check(value)) {
     552             :                         unsigned long long test_var;
     553           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     554           0 :                         if (PyErr_Occurred() != NULL) {
     555           0 :                                 return -1;
     556             :                         }
     557           0 :                         if (test_var > uint_max) {
     558           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     559             :                                   PyLong_Type.tp_name, uint_max, test_var);
     560           0 :                                 return -1;
     561             :                         }
     562           0 :                         object->v1 = test_var;
     563             :                 } else {
     564           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     565             :                           PyLong_Type.tp_name);
     566           0 :                         return -1;
     567             :                 }
     568             :         }
     569           0 :         return 0;
     570             : }
     571             : 
     572           0 : static PyObject *py_echo_info6_get_info1(PyObject *obj, void *closure)
     573             : {
     574           0 :         struct echo_info6 *object = pytalloc_get_ptr(obj);
     575             :         PyObject *py_info1;
     576           0 :         py_info1 = pytalloc_reference_ex(&echo_info1_Type, pytalloc_get_mem_ctx(obj), &object->info1);
     577           0 :         return py_info1;
     578             : }
     579             : 
     580           0 : static int py_echo_info6_set_info1(PyObject *py_obj, PyObject *value, void *closure)
     581             : {
     582           0 :         struct echo_info6 *object = pytalloc_get_ptr(py_obj);
     583           0 :         if (value == NULL) {
     584           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->info1");
     585           0 :                 return -1;
     586             :         }
     587           0 :         PY_CHECK_TYPE(&echo_info1_Type, value, return -1;);
     588           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
     589           0 :                 PyErr_NoMemory();
     590           0 :                 return -1;
     591             :         }
     592           0 :         object->info1 = *(struct echo_info1 *)pytalloc_get_ptr(value);
     593           0 :         return 0;
     594             : }
     595             : 
     596             : static PyGetSetDef py_echo_info6_getsetters[] = {
     597             :         {
     598             :                 .name = discard_const_p(char, "v1"),
     599             :                 .get = py_echo_info6_get_v1,
     600             :                 .set = py_echo_info6_set_v1,
     601             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     602             :         },
     603             :         {
     604             :                 .name = discard_const_p(char, "info1"),
     605             :                 .get = py_echo_info6_get_info1,
     606             :                 .set = py_echo_info6_set_info1,
     607             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_info1")
     608             :         },
     609             :         { .name = NULL }
     610             : };
     611             : 
     612           0 : static PyObject *py_echo_info6_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     613             : {
     614           0 :         return pytalloc_new(struct echo_info6, type);
     615             : }
     616             : 
     617             : 
     618             : static PyTypeObject echo_info6_Type = {
     619             :         PyVarObject_HEAD_INIT(NULL, 0)
     620             :         .tp_name = "echo.info6",
     621             :         .tp_getset = py_echo_info6_getsetters,
     622             :         .tp_methods = NULL,
     623             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     624             :         .tp_new = py_echo_info6_new,
     625             : };
     626             : 
     627             : 
     628           0 : static PyObject *py_echo_info7_get_v1(PyObject *obj, void *closure)
     629             : {
     630           0 :         struct echo_info7 *object = pytalloc_get_ptr(obj);
     631             :         PyObject *py_v1;
     632           0 :         py_v1 = PyLong_FromLong((uint16_t)(object->v1));
     633           0 :         return py_v1;
     634             : }
     635             : 
     636           0 : static int py_echo_info7_set_v1(PyObject *py_obj, PyObject *value, void *closure)
     637             : {
     638           0 :         struct echo_info7 *object = pytalloc_get_ptr(py_obj);
     639           0 :         if (value == NULL) {
     640           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->v1");
     641           0 :                 return -1;
     642             :         }
     643             :         {
     644           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->v1));
     645           0 :                 if (PyLong_Check(value)) {
     646             :                         unsigned long long test_var;
     647           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     648           0 :                         if (PyErr_Occurred() != NULL) {
     649           0 :                                 return -1;
     650             :                         }
     651           0 :                         if (test_var > uint_max) {
     652           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     653             :                                   PyLong_Type.tp_name, uint_max, test_var);
     654           0 :                                 return -1;
     655             :                         }
     656           0 :                         object->v1 = test_var;
     657             :                 } else {
     658           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     659             :                           PyLong_Type.tp_name);
     660           0 :                         return -1;
     661             :                 }
     662             :         }
     663           0 :         return 0;
     664             : }
     665             : 
     666           0 : static PyObject *py_echo_info7_get_info4(PyObject *obj, void *closure)
     667             : {
     668           0 :         struct echo_info7 *object = pytalloc_get_ptr(obj);
     669             :         PyObject *py_info4;
     670           0 :         py_info4 = pytalloc_reference_ex(&echo_info4_Type, pytalloc_get_mem_ctx(obj), &object->info4);
     671           0 :         return py_info4;
     672             : }
     673             : 
     674           0 : static int py_echo_info7_set_info4(PyObject *py_obj, PyObject *value, void *closure)
     675             : {
     676           0 :         struct echo_info7 *object = pytalloc_get_ptr(py_obj);
     677           0 :         if (value == NULL) {
     678           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->info4");
     679           0 :                 return -1;
     680             :         }
     681           0 :         PY_CHECK_TYPE(&echo_info4_Type, value, return -1;);
     682           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
     683           0 :                 PyErr_NoMemory();
     684           0 :                 return -1;
     685             :         }
     686           0 :         object->info4 = *(struct echo_info4 *)pytalloc_get_ptr(value);
     687           0 :         return 0;
     688             : }
     689             : 
     690             : static PyGetSetDef py_echo_info7_getsetters[] = {
     691             :         {
     692             :                 .name = discard_const_p(char, "v1"),
     693             :                 .get = py_echo_info7_get_v1,
     694             :                 .set = py_echo_info7_set_v1,
     695             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     696             :         },
     697             :         {
     698             :                 .name = discard_const_p(char, "info4"),
     699             :                 .get = py_echo_info7_get_info4,
     700             :                 .set = py_echo_info7_set_info4,
     701             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_info4")
     702             :         },
     703             :         { .name = NULL }
     704             : };
     705             : 
     706           0 : static PyObject *py_echo_info7_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     707             : {
     708           0 :         return pytalloc_new(struct echo_info7, type);
     709             : }
     710             : 
     711             : 
     712             : static PyTypeObject echo_info7_Type = {
     713             :         PyVarObject_HEAD_INIT(NULL, 0)
     714             :         .tp_name = "echo.info7",
     715             :         .tp_getset = py_echo_info7_getsetters,
     716             :         .tp_methods = NULL,
     717             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     718             :         .tp_new = py_echo_info7_new,
     719             : };
     720             : 
     721           0 : static PyObject *py_import_echo_Info(TALLOC_CTX *mem_ctx, int level, union echo_Info *in)
     722             : {
     723             :         PyObject *ret;
     724             : 
     725           0 :         switch (level) {
     726           0 :                 case 1:
     727           0 :                         ret = pytalloc_reference_ex(&echo_info1_Type, mem_ctx, &in->info1);
     728           0 :                         return ret;
     729             : 
     730           0 :                 case 2:
     731           0 :                         ret = pytalloc_reference_ex(&echo_info2_Type, mem_ctx, &in->info2);
     732           0 :                         return ret;
     733             : 
     734           0 :                 case 3:
     735           0 :                         ret = pytalloc_reference_ex(&echo_info3_Type, mem_ctx, &in->info3);
     736           0 :                         return ret;
     737             : 
     738           0 :                 case 4:
     739           0 :                         ret = pytalloc_reference_ex(&echo_info4_Type, mem_ctx, &in->info4);
     740           0 :                         return ret;
     741             : 
     742           0 :                 case 5:
     743           0 :                         ret = pytalloc_reference_ex(&echo_info5_Type, mem_ctx, &in->info5);
     744           0 :                         return ret;
     745             : 
     746           0 :                 case 6:
     747           0 :                         ret = pytalloc_reference_ex(&echo_info6_Type, mem_ctx, &in->info6);
     748           0 :                         return ret;
     749             : 
     750           0 :                 case 7:
     751           0 :                         ret = pytalloc_reference_ex(&echo_info7_Type, mem_ctx, &in->info7);
     752           0 :                         return ret;
     753             : 
     754             :         }
     755           0 :         PyErr_SetString(PyExc_TypeError, "unknown union level");
     756           0 :         return NULL;
     757             : }
     758             : 
     759           0 : static union echo_Info *py_export_echo_Info(TALLOC_CTX *mem_ctx, int level, PyObject *in)
     760             : {
     761           0 :         union echo_Info *ret = talloc_zero(mem_ctx, union echo_Info);
     762           0 :         switch (level) {
     763           0 :                 case 1:
     764           0 :                         if (in == NULL) {
     765           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info1");
     766           0 :                                 talloc_free(ret); return NULL;
     767             :                         }
     768           0 :                         PY_CHECK_TYPE(&echo_info1_Type, in, talloc_free(ret); return NULL;);
     769           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     770           0 :                                 PyErr_NoMemory();
     771           0 :                                 talloc_free(ret); return NULL;
     772             :                         }
     773           0 :                         ret->info1 = *(struct echo_info1 *)pytalloc_get_ptr(in);
     774           0 :                         break;
     775             : 
     776           0 :                 case 2:
     777           0 :                         if (in == NULL) {
     778           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info2");
     779           0 :                                 talloc_free(ret); return NULL;
     780             :                         }
     781           0 :                         PY_CHECK_TYPE(&echo_info2_Type, in, talloc_free(ret); return NULL;);
     782           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     783           0 :                                 PyErr_NoMemory();
     784           0 :                                 talloc_free(ret); return NULL;
     785             :                         }
     786           0 :                         ret->info2 = *(struct echo_info2 *)pytalloc_get_ptr(in);
     787           0 :                         break;
     788             : 
     789           0 :                 case 3:
     790           0 :                         if (in == NULL) {
     791           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info3");
     792           0 :                                 talloc_free(ret); return NULL;
     793             :                         }
     794           0 :                         PY_CHECK_TYPE(&echo_info3_Type, in, talloc_free(ret); return NULL;);
     795           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     796           0 :                                 PyErr_NoMemory();
     797           0 :                                 talloc_free(ret); return NULL;
     798             :                         }
     799           0 :                         ret->info3 = *(struct echo_info3 *)pytalloc_get_ptr(in);
     800           0 :                         break;
     801             : 
     802           0 :                 case 4:
     803           0 :                         if (in == NULL) {
     804           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info4");
     805           0 :                                 talloc_free(ret); return NULL;
     806             :                         }
     807           0 :                         PY_CHECK_TYPE(&echo_info4_Type, in, talloc_free(ret); return NULL;);
     808           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     809           0 :                                 PyErr_NoMemory();
     810           0 :                                 talloc_free(ret); return NULL;
     811             :                         }
     812           0 :                         ret->info4 = *(struct echo_info4 *)pytalloc_get_ptr(in);
     813           0 :                         break;
     814             : 
     815           0 :                 case 5:
     816           0 :                         if (in == NULL) {
     817           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info5");
     818           0 :                                 talloc_free(ret); return NULL;
     819             :                         }
     820           0 :                         PY_CHECK_TYPE(&echo_info5_Type, in, talloc_free(ret); return NULL;);
     821           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     822           0 :                                 PyErr_NoMemory();
     823           0 :                                 talloc_free(ret); return NULL;
     824             :                         }
     825           0 :                         ret->info5 = *(struct echo_info5 *)pytalloc_get_ptr(in);
     826           0 :                         break;
     827             : 
     828           0 :                 case 6:
     829           0 :                         if (in == NULL) {
     830           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info6");
     831           0 :                                 talloc_free(ret); return NULL;
     832             :                         }
     833           0 :                         PY_CHECK_TYPE(&echo_info6_Type, in, talloc_free(ret); return NULL;);
     834           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     835           0 :                                 PyErr_NoMemory();
     836           0 :                                 talloc_free(ret); return NULL;
     837             :                         }
     838           0 :                         ret->info6 = *(struct echo_info6 *)pytalloc_get_ptr(in);
     839           0 :                         break;
     840             : 
     841           0 :                 case 7:
     842           0 :                         if (in == NULL) {
     843           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->info7");
     844           0 :                                 talloc_free(ret); return NULL;
     845             :                         }
     846           0 :                         PY_CHECK_TYPE(&echo_info7_Type, in, talloc_free(ret); return NULL;);
     847           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
     848           0 :                                 PyErr_NoMemory();
     849           0 :                                 talloc_free(ret); return NULL;
     850             :                         }
     851           0 :                         ret->info7 = *(struct echo_info7 *)pytalloc_get_ptr(in);
     852           0 :                         break;
     853             : 
     854           0 :                 default:
     855           0 :                         PyErr_SetString(PyExc_TypeError, "invalid union level value");
     856           0 :                         talloc_free(ret);
     857           0 :                         ret = NULL;
     858             :         }
     859             : 
     860           0 :         return ret;
     861             : }
     862             : 
     863           0 : static PyObject *py_echo_Info_import(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     864             : {
     865           0 :         const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
     866           0 :         PyObject *mem_ctx_obj = NULL;
     867           0 :         TALLOC_CTX *mem_ctx = NULL;
     868           0 :         int level = 0;
     869           0 :         PyObject *in_obj = NULL;
     870           0 :         union echo_Info *in = NULL;
     871             : 
     872           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:import",
     873             :                 discard_const_p(char *, kwnames),
     874             :                 &mem_ctx_obj,
     875             :                 &level,
     876             :                 &in_obj)) {
     877           0 :                 return NULL;
     878             :         }
     879           0 :         mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
     880           0 :         if (mem_ctx == NULL) {
     881           0 :                 PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
     882           0 :                 return NULL;
     883             :         }
     884           0 :         in = (union echo_Info *)pytalloc_get_ptr(in_obj);
     885           0 :         if (in == NULL) {
     886           0 :                 PyErr_Format(PyExc_TypeError, "in needs to be a pointer to union echo_Info!");
     887           0 :                 return NULL;
     888             :         }
     889             : 
     890           0 :         return py_import_echo_Info(mem_ctx, level, in);
     891             : }
     892             : 
     893           0 : static PyObject *py_echo_Info_export(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     894             : {
     895           0 :         const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
     896           0 :         PyObject *mem_ctx_obj = NULL;
     897           0 :         TALLOC_CTX *mem_ctx = NULL;
     898           0 :         int level = 0;
     899           0 :         PyObject *in = NULL;
     900           0 :         union echo_Info *out = NULL;
     901             : 
     902           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:export",
     903             :                 discard_const_p(char *, kwnames),
     904             :                 &mem_ctx_obj,
     905             :                 &level,
     906             :                 &in)) {
     907           0 :                 return NULL;
     908             :         }
     909           0 :         mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
     910           0 :         if (mem_ctx == NULL) {
     911           0 :                 PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
     912           0 :                 return NULL;
     913             :         }
     914             : 
     915           0 :         out = py_export_echo_Info(mem_ctx, level, in);
     916           0 :         if (out == NULL) {
     917           0 :                 return NULL;
     918             :         }
     919             : 
     920           0 :         return pytalloc_GenericObject_reference(out);
     921             : }
     922             : 
     923             : static PyMethodDef py_echo_Info_methods[] = {
     924             :         { "__import__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_Info_import),
     925             :                 METH_VARARGS|METH_KEYWORDS|METH_CLASS,
     926             :                 "T.__import__(mem_ctx, level, in) => ret." },
     927             :         { "__export__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_Info_export),
     928             :                 METH_VARARGS|METH_KEYWORDS|METH_CLASS,
     929             :                 "T.__export__(mem_ctx, level, in) => ret." },
     930             :         { NULL, NULL, 0, NULL }
     931             : };
     932             : 
     933           0 : static PyObject *py_echo_Info_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     934             : {
     935           0 :         PyErr_Format(PyExc_TypeError, "New %s Objects are not supported", type->tp_name);
     936           0 :         return NULL;
     937             : }
     938             : 
     939             : 
     940             : static PyTypeObject echo_Info_Type = {
     941             :         PyVarObject_HEAD_INIT(NULL, 0)
     942             :         .tp_name = "echo.Info",
     943             :         .tp_getset = NULL,
     944             :         .tp_methods = py_echo_Info_methods,
     945             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     946             :         .tp_new = py_echo_Info_new,
     947             : };
     948             : 
     949             : 
     950           0 : static PyObject *py_echo_Enum2_get_e1(PyObject *obj, void *closure)
     951             : {
     952           0 :         struct echo_Enum2 *object = pytalloc_get_ptr(obj);
     953             :         PyObject *py_e1;
     954           0 :         py_e1 = PyLong_FromLong((uint16_t)(object->e1));
     955           0 :         return py_e1;
     956             : }
     957             : 
     958           0 : static int py_echo_Enum2_set_e1(PyObject *py_obj, PyObject *value, void *closure)
     959             : {
     960           0 :         struct echo_Enum2 *object = pytalloc_get_ptr(py_obj);
     961           0 :         if (value == NULL) {
     962           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->e1");
     963           0 :                 return -1;
     964             :         }
     965             :         {
     966           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->e1));
     967           0 :                 if (PyLong_Check(value)) {
     968             :                         unsigned long long test_var;
     969           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     970           0 :                         if (PyErr_Occurred() != NULL) {
     971           0 :                                 return -1;
     972             :                         }
     973           0 :                         if (test_var > uint_max) {
     974           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
     975             :                                   PyLong_Type.tp_name, uint_max, test_var);
     976           0 :                                 return -1;
     977             :                         }
     978           0 :                         object->e1 = test_var;
     979             :                 } else {
     980           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
     981             :                           PyLong_Type.tp_name);
     982           0 :                         return -1;
     983             :                 }
     984             :         }
     985           0 :         return 0;
     986             : }
     987             : 
     988           0 : static PyObject *py_echo_Enum2_get_e2(PyObject *obj, void *closure)
     989             : {
     990           0 :         struct echo_Enum2 *object = pytalloc_get_ptr(obj);
     991             :         PyObject *py_e2;
     992           0 :         py_e2 = PyLong_FromUnsignedLongLong((uint32_t)(object->e2));
     993           0 :         return py_e2;
     994             : }
     995             : 
     996           0 : static int py_echo_Enum2_set_e2(PyObject *py_obj, PyObject *value, void *closure)
     997             : {
     998           0 :         struct echo_Enum2 *object = pytalloc_get_ptr(py_obj);
     999           0 :         if (value == NULL) {
    1000           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->e2");
    1001           0 :                 return -1;
    1002             :         }
    1003             :         {
    1004           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->e2));
    1005           0 :                 if (PyLong_Check(value)) {
    1006             :                         unsigned long long test_var;
    1007           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1008           0 :                         if (PyErr_Occurred() != NULL) {
    1009           0 :                                 return -1;
    1010             :                         }
    1011           0 :                         if (test_var > uint_max) {
    1012           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1013             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1014           0 :                                 return -1;
    1015             :                         }
    1016           0 :                         object->e2 = test_var;
    1017             :                 } else {
    1018           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1019             :                           PyLong_Type.tp_name);
    1020           0 :                         return -1;
    1021             :                 }
    1022             :         }
    1023           0 :         return 0;
    1024             : }
    1025             : 
    1026             : static PyGetSetDef py_echo_Enum2_getsetters[] = {
    1027             :         {
    1028             :                 .name = discard_const_p(char, "e1"),
    1029             :                 .get = py_echo_Enum2_get_e1,
    1030             :                 .set = py_echo_Enum2_set_e1,
    1031             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum1")
    1032             :         },
    1033             :         {
    1034             :                 .name = discard_const_p(char, "e2"),
    1035             :                 .get = py_echo_Enum2_get_e2,
    1036             :                 .set = py_echo_Enum2_set_e2,
    1037             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum1_32")
    1038             :         },
    1039             :         { .name = NULL }
    1040             : };
    1041             : 
    1042           0 : static PyObject *py_echo_Enum2_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1043             : {
    1044           0 :         return pytalloc_new(struct echo_Enum2, type);
    1045             : }
    1046             : 
    1047             : 
    1048             : static PyTypeObject echo_Enum2_Type = {
    1049             :         PyVarObject_HEAD_INIT(NULL, 0)
    1050             :         .tp_name = "echo.Enum2",
    1051             :         .tp_getset = py_echo_Enum2_getsetters,
    1052             :         .tp_methods = NULL,
    1053             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1054             :         .tp_new = py_echo_Enum2_new,
    1055             : };
    1056             : 
    1057           0 : static PyObject *py_import_echo_Enum3(TALLOC_CTX *mem_ctx, int level, union echo_Enum3 *in)
    1058             : {
    1059             :         PyObject *ret;
    1060             : 
    1061           0 :         switch (level) {
    1062           0 :                 case ECHO_ENUM1:
    1063           0 :                         ret = PyLong_FromLong((uint16_t)(in->e1));
    1064           0 :                         return ret;
    1065             : 
    1066           0 :                 case ECHO_ENUM2:
    1067           0 :                         ret = pytalloc_reference_ex(&echo_Enum2_Type, mem_ctx, &in->e2);
    1068           0 :                         return ret;
    1069             : 
    1070             :         }
    1071           0 :         PyErr_SetString(PyExc_TypeError, "unknown union level");
    1072           0 :         return NULL;
    1073             : }
    1074             : 
    1075           0 : static union echo_Enum3 *py_export_echo_Enum3(TALLOC_CTX *mem_ctx, int level, PyObject *in)
    1076             : {
    1077           0 :         union echo_Enum3 *ret = talloc_zero(mem_ctx, union echo_Enum3);
    1078           0 :         switch (level) {
    1079           0 :                 case ECHO_ENUM1:
    1080           0 :                         if (in == NULL) {
    1081           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->e1");
    1082           0 :                                 talloc_free(ret); return NULL;
    1083             :                         }
    1084             :                         {
    1085           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(ret->e1));
    1086           0 :                                 if (PyLong_Check(in)) {
    1087             :                                         unsigned long long test_var;
    1088           0 :                                         test_var = PyLong_AsUnsignedLongLong(in);
    1089           0 :                                         if (PyErr_Occurred() != NULL) {
    1090           0 :                                                 talloc_free(ret); return NULL;
    1091             :                                         }
    1092           0 :                                         if (test_var > uint_max) {
    1093           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1094             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    1095           0 :                                                 talloc_free(ret); return NULL;
    1096             :                                         }
    1097           0 :                                         ret->e1 = test_var;
    1098             :                                 } else {
    1099           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1100             :                                           PyLong_Type.tp_name);
    1101           0 :                                         talloc_free(ret); return NULL;
    1102             :                                 }
    1103             :                         }
    1104           0 :                         break;
    1105             : 
    1106           0 :                 case ECHO_ENUM2:
    1107           0 :                         if (in == NULL) {
    1108           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: ret->e2");
    1109           0 :                                 talloc_free(ret); return NULL;
    1110             :                         }
    1111           0 :                         PY_CHECK_TYPE(&echo_Enum2_Type, in, talloc_free(ret); return NULL;);
    1112           0 :                         if (talloc_reference(mem_ctx, pytalloc_get_mem_ctx(in)) == NULL) {
    1113           0 :                                 PyErr_NoMemory();
    1114           0 :                                 talloc_free(ret); return NULL;
    1115             :                         }
    1116           0 :                         ret->e2 = *(struct echo_Enum2 *)pytalloc_get_ptr(in);
    1117           0 :                         break;
    1118             : 
    1119           0 :                 default:
    1120           0 :                         PyErr_SetString(PyExc_TypeError, "invalid union level value");
    1121           0 :                         talloc_free(ret);
    1122           0 :                         ret = NULL;
    1123             :         }
    1124             : 
    1125           0 :         return ret;
    1126             : }
    1127             : 
    1128           0 : static PyObject *py_echo_Enum3_import(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1129             : {
    1130           0 :         const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
    1131           0 :         PyObject *mem_ctx_obj = NULL;
    1132           0 :         TALLOC_CTX *mem_ctx = NULL;
    1133           0 :         int level = 0;
    1134           0 :         PyObject *in_obj = NULL;
    1135           0 :         union echo_Enum3 *in = NULL;
    1136             : 
    1137           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:import",
    1138             :                 discard_const_p(char *, kwnames),
    1139             :                 &mem_ctx_obj,
    1140             :                 &level,
    1141             :                 &in_obj)) {
    1142           0 :                 return NULL;
    1143             :         }
    1144           0 :         mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
    1145           0 :         if (mem_ctx == NULL) {
    1146           0 :                 PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
    1147           0 :                 return NULL;
    1148             :         }
    1149           0 :         in = (union echo_Enum3 *)pytalloc_get_ptr(in_obj);
    1150           0 :         if (in == NULL) {
    1151           0 :                 PyErr_Format(PyExc_TypeError, "in needs to be a pointer to union echo_Enum3!");
    1152           0 :                 return NULL;
    1153             :         }
    1154             : 
    1155           0 :         return py_import_echo_Enum3(mem_ctx, level, in);
    1156             : }
    1157             : 
    1158           0 : static PyObject *py_echo_Enum3_export(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1159             : {
    1160           0 :         const char * const kwnames[] = { "mem_ctx", "level", "in", NULL };
    1161           0 :         PyObject *mem_ctx_obj = NULL;
    1162           0 :         TALLOC_CTX *mem_ctx = NULL;
    1163           0 :         int level = 0;
    1164           0 :         PyObject *in = NULL;
    1165           0 :         union echo_Enum3 *out = NULL;
    1166             : 
    1167           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OiO:export",
    1168             :                 discard_const_p(char *, kwnames),
    1169             :                 &mem_ctx_obj,
    1170             :                 &level,
    1171             :                 &in)) {
    1172           0 :                 return NULL;
    1173             :         }
    1174           0 :         mem_ctx = pytalloc_get_ptr(mem_ctx_obj);
    1175           0 :         if (mem_ctx == NULL) {
    1176           0 :                 PyErr_SetString(PyExc_TypeError, "mem_ctx is NULL)!");
    1177           0 :                 return NULL;
    1178             :         }
    1179             : 
    1180           0 :         out = py_export_echo_Enum3(mem_ctx, level, in);
    1181           0 :         if (out == NULL) {
    1182           0 :                 return NULL;
    1183             :         }
    1184             : 
    1185           0 :         return pytalloc_GenericObject_reference(out);
    1186             : }
    1187             : 
    1188             : static PyMethodDef py_echo_Enum3_methods[] = {
    1189             :         { "__import__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_Enum3_import),
    1190             :                 METH_VARARGS|METH_KEYWORDS|METH_CLASS,
    1191             :                 "T.__import__(mem_ctx, level, in) => ret." },
    1192             :         { "__export__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_Enum3_export),
    1193             :                 METH_VARARGS|METH_KEYWORDS|METH_CLASS,
    1194             :                 "T.__export__(mem_ctx, level, in) => ret." },
    1195             :         { NULL, NULL, 0, NULL }
    1196             : };
    1197             : 
    1198           0 : static PyObject *py_echo_Enum3_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1199             : {
    1200           0 :         PyErr_Format(PyExc_TypeError, "New %s Objects are not supported", type->tp_name);
    1201           0 :         return NULL;
    1202             : }
    1203             : 
    1204             : 
    1205             : static PyTypeObject echo_Enum3_Type = {
    1206             :         PyVarObject_HEAD_INIT(NULL, 0)
    1207             :         .tp_name = "echo.Enum3",
    1208             :         .tp_getset = NULL,
    1209             :         .tp_methods = py_echo_Enum3_methods,
    1210             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1211             :         .tp_new = py_echo_Enum3_new,
    1212             : };
    1213             : 
    1214             : 
    1215           0 : static PyObject *py_echo_Surrounding_get_x(PyObject *obj, void *closure)
    1216             : {
    1217           0 :         struct echo_Surrounding *object = pytalloc_get_ptr(obj);
    1218             :         PyObject *py_x;
    1219           0 :         py_x = PyLong_FromUnsignedLongLong((uint32_t)(object->x));
    1220           0 :         return py_x;
    1221             : }
    1222             : 
    1223           1 : static int py_echo_Surrounding_set_x(PyObject *py_obj, PyObject *value, void *closure)
    1224             : {
    1225           1 :         struct echo_Surrounding *object = pytalloc_get_ptr(py_obj);
    1226           1 :         if (value == NULL) {
    1227           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->x");
    1228           0 :                 return -1;
    1229             :         }
    1230             :         {
    1231           1 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->x));
    1232           1 :                 if (PyLong_Check(value)) {
    1233             :                         unsigned long long test_var;
    1234           1 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1235           1 :                         if (PyErr_Occurred() != NULL) {
    1236           0 :                                 return -1;
    1237             :                         }
    1238           1 :                         if (test_var > uint_max) {
    1239           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1240             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1241           0 :                                 return -1;
    1242             :                         }
    1243           1 :                         object->x = test_var;
    1244             :                 } else {
    1245           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1246             :                           PyLong_Type.tp_name);
    1247           0 :                         return -1;
    1248             :                 }
    1249             :         }
    1250           1 :         return 0;
    1251             : }
    1252             : 
    1253           1 : static PyObject *py_echo_Surrounding_get_surrounding(PyObject *obj, void *closure)
    1254             : {
    1255           1 :         struct echo_Surrounding *object = pytalloc_get_ptr(obj);
    1256             :         PyObject *py_surrounding;
    1257           1 :         py_surrounding = PyList_New(object->x);
    1258           1 :         if (py_surrounding == NULL) {
    1259           0 :                 return NULL;
    1260             :         }
    1261             :         {
    1262             :                 int surrounding_cntr_0;
    1263           9 :                 for (surrounding_cntr_0 = 0; surrounding_cntr_0 < (object->x); surrounding_cntr_0++) {
    1264             :                         PyObject *py_surrounding_0;
    1265           8 :                         py_surrounding_0 = PyLong_FromLong((uint16_t)((object->surrounding)[surrounding_cntr_0]));
    1266           8 :                         PyList_SetItem(py_surrounding, surrounding_cntr_0, py_surrounding_0);
    1267             :                 }
    1268             :         }
    1269           1 :         return py_surrounding;
    1270             : }
    1271             : 
    1272           1 : static int py_echo_Surrounding_set_surrounding(PyObject *py_obj, PyObject *value, void *closure)
    1273             : {
    1274           1 :         struct echo_Surrounding *object = pytalloc_get_ptr(py_obj);
    1275           1 :         if (value == NULL) {
    1276           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->surrounding");
    1277           0 :                 return -1;
    1278             :         }
    1279           1 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    1280             :         {
    1281             :                 int surrounding_cntr_0;
    1282           1 :                 object->surrounding = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->surrounding, PyList_GET_SIZE(value));
    1283           1 :                 if (!object->surrounding) { return -1; }
    1284           1 :                 talloc_set_name_const(object->surrounding, "ARRAY: object->surrounding");
    1285           5 :                 for (surrounding_cntr_0 = 0; surrounding_cntr_0 < PyList_GET_SIZE(value); surrounding_cntr_0++) {
    1286           4 :                         if (PyList_GET_ITEM(value, surrounding_cntr_0) == NULL) {
    1287           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->surrounding)[surrounding_cntr_0]");
    1288           0 :                                 return -1;
    1289             :                         }
    1290             :                         {
    1291           4 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((object->surrounding)[surrounding_cntr_0]));
    1292           4 :                                 if (PyLong_Check(PyList_GET_ITEM(value, surrounding_cntr_0))) {
    1293             :                                         unsigned long long test_var;
    1294           4 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, surrounding_cntr_0));
    1295           4 :                                         if (PyErr_Occurred() != NULL) {
    1296           0 :                                                 return -1;
    1297             :                                         }
    1298           4 :                                         if (test_var > uint_max) {
    1299           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1300             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    1301           0 :                                                 return -1;
    1302             :                                         }
    1303           4 :                                         (object->surrounding)[surrounding_cntr_0] = test_var;
    1304             :                                 } else {
    1305           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1306             :                                           PyLong_Type.tp_name);
    1307           0 :                                         return -1;
    1308             :                                 }
    1309             :                         }
    1310             :                 }
    1311             :         }
    1312           1 :         return 0;
    1313             : }
    1314             : 
    1315             : static PyGetSetDef py_echo_Surrounding_getsetters[] = {
    1316             :         {
    1317             :                 .name = discard_const_p(char, "x"),
    1318             :                 .get = py_echo_Surrounding_get_x,
    1319             :                 .set = py_echo_Surrounding_set_x,
    1320             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1321             :         },
    1322             :         {
    1323             :                 .name = discard_const_p(char, "surrounding"),
    1324             :                 .get = py_echo_Surrounding_get_surrounding,
    1325             :                 .set = py_echo_Surrounding_set_surrounding,
    1326             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    1327             :         },
    1328             :         { .name = NULL }
    1329             : };
    1330             : 
    1331           1 : static PyObject *py_echo_Surrounding_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1332             : {
    1333           1 :         return pytalloc_new(struct echo_Surrounding, type);
    1334             : }
    1335             : 
    1336             : 
    1337             : static PyTypeObject echo_Surrounding_Type = {
    1338             :         PyVarObject_HEAD_INIT(NULL, 0)
    1339             :         .tp_name = "echo.Surrounding",
    1340             :         .tp_getset = py_echo_Surrounding_getsetters,
    1341             :         .tp_methods = NULL,
    1342             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1343             :         .tp_new = py_echo_Surrounding_new,
    1344             : };
    1345             : 
    1346             : 
    1347             : 
    1348           0 : static PyObject *py_echo_AddOne_in_get_in_data(PyObject *obj, void *closure)
    1349             : {
    1350           0 :         struct echo_AddOne *object = pytalloc_get_ptr(obj);
    1351             :         PyObject *py_in_data;
    1352           0 :         py_in_data = PyLong_FromUnsignedLongLong((uint32_t)(object->in.in_data));
    1353           0 :         return py_in_data;
    1354             : }
    1355             : 
    1356           0 : static int py_echo_AddOne_in_set_in_data(PyObject *py_obj, PyObject *value, void *closure)
    1357             : {
    1358           0 :         struct echo_AddOne *object = pytalloc_get_ptr(py_obj);
    1359           0 :         if (value == NULL) {
    1360           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.in_data");
    1361           0 :                 return -1;
    1362             :         }
    1363             :         {
    1364           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.in_data));
    1365           0 :                 if (PyLong_Check(value)) {
    1366             :                         unsigned long long test_var;
    1367           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1368           0 :                         if (PyErr_Occurred() != NULL) {
    1369           0 :                                 return -1;
    1370             :                         }
    1371           0 :                         if (test_var > uint_max) {
    1372           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1373             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1374           0 :                                 return -1;
    1375             :                         }
    1376           0 :                         object->in.in_data = test_var;
    1377             :                 } else {
    1378           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1379             :                           PyLong_Type.tp_name);
    1380           0 :                         return -1;
    1381             :                 }
    1382             :         }
    1383           0 :         return 0;
    1384             : }
    1385             : 
    1386           0 : static PyObject *py_echo_AddOne_out_get_out_data(PyObject *obj, void *closure)
    1387             : {
    1388           0 :         struct echo_AddOne *object = pytalloc_get_ptr(obj);
    1389             :         PyObject *py_out_data;
    1390           0 :         if (object->out.out_data == NULL) {
    1391           0 :                 Py_RETURN_NONE;
    1392             :         }
    1393           0 :         py_out_data = PyLong_FromUnsignedLongLong((uint32_t)(*object->out.out_data));
    1394           0 :         return py_out_data;
    1395             : }
    1396             : 
    1397           0 : static int py_echo_AddOne_out_set_out_data(PyObject *py_obj, PyObject *value, void *closure)
    1398             : {
    1399           0 :         struct echo_AddOne *object = pytalloc_get_ptr(py_obj);
    1400           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.out_data));
    1401           0 :         if (value == NULL) {
    1402           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.out_data");
    1403           0 :                 return -1;
    1404             :         }
    1405           0 :         object->out.out_data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.out_data);
    1406           0 :         if (object->out.out_data == NULL) {
    1407           0 :                 PyErr_NoMemory();
    1408           0 :                 return -1;
    1409             :         }
    1410             :         {
    1411           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.out_data));
    1412           0 :                 if (PyLong_Check(value)) {
    1413             :                         unsigned long long test_var;
    1414           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1415           0 :                         if (PyErr_Occurred() != NULL) {
    1416           0 :                                 return -1;
    1417             :                         }
    1418           0 :                         if (test_var > uint_max) {
    1419           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1420             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1421           0 :                                 return -1;
    1422             :                         }
    1423           0 :                         *object->out.out_data = test_var;
    1424             :                 } else {
    1425           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1426             :                           PyLong_Type.tp_name);
    1427           0 :                         return -1;
    1428             :                 }
    1429             :         }
    1430           0 :         return 0;
    1431             : }
    1432             : 
    1433             : static PyGetSetDef py_echo_AddOne_getsetters[] = {
    1434             :         {
    1435             :                 .name = discard_const_p(char, "in_in_data"),
    1436             :                 .get = py_echo_AddOne_in_get_in_data,
    1437             :                 .set = py_echo_AddOne_in_set_in_data,
    1438             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1439             :         },
    1440             :         {
    1441             :                 .name = discard_const_p(char, "out_out_data"),
    1442             :                 .get = py_echo_AddOne_out_get_out_data,
    1443             :                 .set = py_echo_AddOne_out_set_out_data,
    1444             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1445             :         },
    1446             :         { .name = NULL }
    1447             : };
    1448             : 
    1449           0 : static PyObject *py_echo_AddOne_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1450             : {
    1451           0 :         PyObject *self = pytalloc_new(struct echo_AddOne, type);
    1452           0 :         struct echo_AddOne *_self = (struct echo_AddOne *)pytalloc_get_ptr(self);
    1453           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    1454           0 :         _self->out.out_data = talloc_zero(mem_ctx, uint32_t);
    1455           0 :         return self;
    1456             : }
    1457             : 
    1458           0 : static PyObject *py_echo_AddOne_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    1459             : {
    1460             : 
    1461             : 
    1462           0 :         return PyLong_FromLong(0);
    1463             : }
    1464             : 
    1465           0 : static PyObject *py_echo_AddOne_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    1466             : {
    1467           0 :         const struct ndr_interface_call *call = NULL;
    1468           0 :         struct echo_AddOne *object = pytalloc_get_ptr(py_obj);
    1469           0 :         PyObject *ret = NULL;
    1470           0 :         struct ndr_push *push = NULL;
    1471             :         DATA_BLOB blob;
    1472             :         enum ndr_err_code err;
    1473             : 
    1474           0 :         if (ndr_table_rpcecho.num_calls < 1) {
    1475           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_AddOne_ndr_pack");
    1476           0 :                 return NULL;
    1477             :         }
    1478           0 :         call = &ndr_table_rpcecho.calls[0];
    1479             : 
    1480           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    1481           0 :         if (push == NULL) {
    1482           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1483           0 :                 return NULL;
    1484             :         }
    1485             : 
    1486           0 :         push->flags |= ndr_push_flags;
    1487             : 
    1488           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    1489           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1490           0 :                 TALLOC_FREE(push);
    1491           0 :                 PyErr_SetNdrError(err);
    1492           0 :                 return NULL;
    1493             :         }
    1494           0 :         blob = ndr_push_blob(push);
    1495           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    1496           0 :         TALLOC_FREE(push);
    1497           0 :         return ret;
    1498             : }
    1499             : 
    1500           0 : static PyObject *py_echo_AddOne_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1501             : {
    1502           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    1503           0 :         PyObject *bigendian_obj = NULL;
    1504           0 :         PyObject *ndr64_obj = NULL;
    1505           0 :         libndr_flags ndr_push_flags = 0;
    1506             : 
    1507           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    1508             :                 discard_const_p(char *, kwnames),
    1509             :                 &bigendian_obj,
    1510             :                 &ndr64_obj)) {
    1511           0 :                 return NULL;
    1512             :         }
    1513             : 
    1514           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1515           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    1516             :         }
    1517           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1518           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    1519             :         }
    1520             : 
    1521           0 :         return py_echo_AddOne_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    1522             : }
    1523             : 
    1524           0 : static PyObject *py_echo_AddOne_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1525             : {
    1526           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    1527           0 :         PyObject *bigendian_obj = NULL;
    1528           0 :         PyObject *ndr64_obj = NULL;
    1529           0 :         libndr_flags ndr_push_flags = 0;
    1530             : 
    1531           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    1532             :                 discard_const_p(char *, kwnames),
    1533             :                 &bigendian_obj,
    1534             :                 &ndr64_obj)) {
    1535           0 :                 return NULL;
    1536             :         }
    1537             : 
    1538           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1539           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    1540             :         }
    1541           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1542           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    1543             :         }
    1544             : 
    1545           0 :         return py_echo_AddOne_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    1546             : }
    1547             : 
    1548           0 : static PyObject *py_echo_AddOne_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    1549             : {
    1550           0 :         const struct ndr_interface_call *call = NULL;
    1551           0 :         struct echo_AddOne *object = pytalloc_get_ptr(py_obj);
    1552           0 :         struct ndr_pull *pull = NULL;
    1553             :         enum ndr_err_code err;
    1554             : 
    1555           0 :         if (ndr_table_rpcecho.num_calls < 1) {
    1556           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_AddOne_ndr_unpack");
    1557           0 :                 return NULL;
    1558             :         }
    1559           0 :         call = &ndr_table_rpcecho.calls[0];
    1560             : 
    1561           0 :         pull = ndr_pull_init_blob(blob, object);
    1562           0 :         if (pull == NULL) {
    1563           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1564           0 :                 return NULL;
    1565             :         }
    1566             : 
    1567           0 :         pull->flags |= ndr_pull_flags;
    1568             : 
    1569           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    1570           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1571           0 :                 TALLOC_FREE(pull);
    1572           0 :                 PyErr_SetNdrError(err);
    1573           0 :                 return NULL;
    1574             :         }
    1575           0 :         if (!allow_remaining) {
    1576             :                 uint32_t highest_ofs;
    1577             : 
    1578           0 :                 if (pull->offset > pull->relative_highest_offset) {
    1579           0 :                         highest_ofs = pull->offset;
    1580             :                 } else {
    1581           0 :                         highest_ofs = pull->relative_highest_offset;
    1582             :                 }
    1583           0 :                 if (highest_ofs < pull->data_size) {
    1584           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    1585             :                                 "not all bytes consumed ofs[%u] size[%u]",
    1586             :                                 highest_ofs, pull->data_size);
    1587           0 :                         TALLOC_FREE(pull);
    1588           0 :                         PyErr_SetNdrError(err);
    1589           0 :                         return NULL;
    1590             :                 }
    1591             :         }
    1592             : 
    1593           0 :         TALLOC_FREE(pull);
    1594           0 :         Py_RETURN_NONE;
    1595             : }
    1596             : 
    1597           0 : static PyObject *py_echo_AddOne_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1598             : {
    1599             :         DATA_BLOB blob;
    1600           0 :         Py_ssize_t blob_length = 0;
    1601           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    1602           0 :         PyObject *bigendian_obj = NULL;
    1603           0 :         PyObject *ndr64_obj = NULL;
    1604           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    1605           0 :         PyObject *allow_remaining_obj = NULL;
    1606           0 :         bool allow_remaining = false;
    1607             : 
    1608           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    1609             :                 discard_const_p(char *, kwnames),
    1610             :                 &blob.data, &blob_length,
    1611             :                 &bigendian_obj,
    1612             :                 &ndr64_obj,
    1613             :                 &allow_remaining_obj)) {
    1614           0 :                 return NULL;
    1615             :         }
    1616           0 :         blob.length = blob_length;
    1617             : 
    1618           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1619           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    1620             :         }
    1621           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1622           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    1623             :         }
    1624             : 
    1625           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    1626           0 :                 allow_remaining = true;
    1627             :         }
    1628             : 
    1629           0 :         return py_echo_AddOne_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    1630             : }
    1631             : 
    1632           0 : static PyObject *py_echo_AddOne_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1633             : {
    1634             :         DATA_BLOB blob;
    1635           0 :         Py_ssize_t blob_length = 0;
    1636           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    1637           0 :         PyObject *bigendian_obj = NULL;
    1638           0 :         PyObject *ndr64_obj = NULL;
    1639           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    1640           0 :         PyObject *allow_remaining_obj = NULL;
    1641           0 :         bool allow_remaining = false;
    1642             : 
    1643           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    1644             :                 discard_const_p(char *, kwnames),
    1645             :                 &blob.data, &blob_length,
    1646             :                 &bigendian_obj,
    1647             :                 &ndr64_obj,
    1648             :                 &allow_remaining_obj)) {
    1649           0 :                 return NULL;
    1650             :         }
    1651           0 :         blob.length = blob_length;
    1652             : 
    1653           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1654           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    1655             :         }
    1656           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1657           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    1658             :         }
    1659             : 
    1660           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    1661           0 :                 allow_remaining = true;
    1662             :         }
    1663             : 
    1664           0 :         return py_echo_AddOne_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    1665             : }
    1666             : 
    1667           0 : static PyObject *py_echo_AddOne_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    1668             : {
    1669           0 :         const struct ndr_interface_call *call = NULL;
    1670           0 :         struct echo_AddOne *object = pytalloc_get_ptr(py_obj);
    1671             :         PyObject *ret;
    1672             :         char *retstr;
    1673             : 
    1674           0 :         if (ndr_table_rpcecho.num_calls < 1) {
    1675           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_AddOne_ndr_print");
    1676           0 :                 return NULL;
    1677             :         }
    1678           0 :         call = &ndr_table_rpcecho.calls[0];
    1679             : 
    1680           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    1681           0 :         ret = PyUnicode_FromString(retstr);
    1682           0 :         TALLOC_FREE(retstr);
    1683             : 
    1684           0 :         return ret;
    1685             : }
    1686             : 
    1687           0 : static PyObject *py_echo_AddOne_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    1688             : {
    1689           0 :         return py_echo_AddOne_ndr_print(py_obj, "echo_AddOne_in", NDR_IN);
    1690             : }
    1691             : 
    1692           0 : static PyObject *py_echo_AddOne_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    1693             : {
    1694           0 :         return py_echo_AddOne_ndr_print(py_obj, "echo_AddOne_out", NDR_OUT);
    1695             : }
    1696             : 
    1697             : static PyMethodDef py_echo_AddOne_methods[] = {
    1698             :         { "opnum", (PyCFunction)py_echo_AddOne_ndr_opnum, METH_NOARGS|METH_CLASS,
    1699             :                 "echo.AddOne.opnum() -> 0 (0x00) " },
    1700             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_AddOne_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    1701             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    1702             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_AddOne_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    1703             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    1704             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_AddOne_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    1705             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    1706             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_AddOne_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    1707             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    1708             :         { "__ndr_print_in__", (PyCFunction)py_echo_AddOne_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    1709             :         { "__ndr_print_out__", (PyCFunction)py_echo_AddOne_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    1710             :         { NULL, NULL, 0, NULL }
    1711             : };
    1712             : 
    1713             : 
    1714             : static PyTypeObject echo_AddOne_Type = {
    1715             :         PyVarObject_HEAD_INIT(NULL, 0)
    1716             :         .tp_name = "echo.AddOne",
    1717             :         .tp_getset = py_echo_AddOne_getsetters,
    1718             :         .tp_methods = py_echo_AddOne_methods,
    1719             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1720             :         .tp_new = py_echo_AddOne_new,
    1721             : };
    1722             : 
    1723           2 : static bool pack_py_echo_AddOne_args_in(PyObject *args, PyObject *kwargs, struct echo_AddOne *r)
    1724             : {
    1725             :         PyObject *py_in_data;
    1726           2 :         const char *kwnames[] = {
    1727             :                 "in_data", NULL
    1728             :         };
    1729             : 
    1730           2 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_AddOne", discard_const_p(char *, kwnames), &py_in_data)) {
    1731           0 :                 return false;
    1732             :         }
    1733             : 
    1734           2 :         if (py_in_data == NULL) {
    1735           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.in_data");
    1736           0 :                 return false;
    1737             :         }
    1738             :         {
    1739           2 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.in_data));
    1740           2 :                 if (PyLong_Check(py_in_data)) {
    1741             :                         unsigned long long test_var;
    1742           2 :                         test_var = PyLong_AsUnsignedLongLong(py_in_data);
    1743           2 :                         if (PyErr_Occurred() != NULL) {
    1744           0 :                                 return false;
    1745             :                         }
    1746           2 :                         if (test_var > uint_max) {
    1747           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1748             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1749           0 :                                 return false;
    1750             :                         }
    1751           2 :                         r->in.in_data = test_var;
    1752             :                 } else {
    1753           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1754             :                           PyLong_Type.tp_name);
    1755           0 :                         return false;
    1756             :                 }
    1757             :         }
    1758           2 :         return true;
    1759             : }
    1760             : 
    1761           2 : static PyObject *unpack_py_echo_AddOne_args_out(struct echo_AddOne *r)
    1762             : {
    1763             :         PyObject *result;
    1764             :         PyObject *py_out_data;
    1765           2 :         py_out_data = PyLong_FromUnsignedLongLong((uint32_t)(*r->out.out_data));
    1766           2 :         result = py_out_data;
    1767           2 :         return result;
    1768             : }
    1769             : 
    1770             : 
    1771           0 : static PyObject *py_echo_EchoData_in_get_len(PyObject *obj, void *closure)
    1772             : {
    1773           0 :         struct echo_EchoData *object = pytalloc_get_ptr(obj);
    1774             :         PyObject *py_len;
    1775           0 :         py_len = PyLong_FromUnsignedLongLong((uint32_t)(object->in.len));
    1776           0 :         return py_len;
    1777             : }
    1778             : 
    1779           0 : static int py_echo_EchoData_in_set_len(PyObject *py_obj, PyObject *value, void *closure)
    1780             : {
    1781           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    1782           0 :         if (value == NULL) {
    1783           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.len");
    1784           0 :                 return -1;
    1785             :         }
    1786             :         {
    1787           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.len));
    1788           0 :                 if (PyLong_Check(value)) {
    1789             :                         unsigned long long test_var;
    1790           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1791           0 :                         if (PyErr_Occurred() != NULL) {
    1792           0 :                                 return -1;
    1793             :                         }
    1794           0 :                         if (test_var > uint_max) {
    1795           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1796             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1797           0 :                                 return -1;
    1798             :                         }
    1799           0 :                         object->in.len = test_var;
    1800             :                 } else {
    1801           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1802             :                           PyLong_Type.tp_name);
    1803           0 :                         return -1;
    1804             :                 }
    1805             :         }
    1806           0 :         return 0;
    1807             : }
    1808             : 
    1809           0 : static PyObject *py_echo_EchoData_in_get_in_data(PyObject *obj, void *closure)
    1810             : {
    1811           0 :         struct echo_EchoData *object = pytalloc_get_ptr(obj);
    1812             :         PyObject *py_in_data;
    1813           0 :         py_in_data = PyList_New(object->in.len);
    1814           0 :         if (py_in_data == NULL) {
    1815           0 :                 return NULL;
    1816             :         }
    1817             :         {
    1818             :                 int in_data_cntr_0;
    1819           0 :                 for (in_data_cntr_0 = 0; in_data_cntr_0 < (object->in.len); in_data_cntr_0++) {
    1820             :                         PyObject *py_in_data_0;
    1821           0 :                         py_in_data_0 = PyLong_FromLong((uint16_t)((object->in.in_data)[in_data_cntr_0]));
    1822           0 :                         PyList_SetItem(py_in_data, in_data_cntr_0, py_in_data_0);
    1823             :                 }
    1824             :         }
    1825           0 :         return py_in_data;
    1826             : }
    1827             : 
    1828           0 : static int py_echo_EchoData_in_set_in_data(PyObject *py_obj, PyObject *value, void *closure)
    1829             : {
    1830           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    1831           0 :         if (value == NULL) {
    1832           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.in_data");
    1833           0 :                 return -1;
    1834             :         }
    1835           0 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    1836             :         {
    1837             :                 int in_data_cntr_0;
    1838           0 :                 object->in.in_data = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.in_data, PyList_GET_SIZE(value));
    1839           0 :                 if (!object->in.in_data) { return -1; }
    1840           0 :                 talloc_set_name_const(object->in.in_data, "ARRAY: object->in.in_data");
    1841           0 :                 for (in_data_cntr_0 = 0; in_data_cntr_0 < PyList_GET_SIZE(value); in_data_cntr_0++) {
    1842           0 :                         if (PyList_GET_ITEM(value, in_data_cntr_0) == NULL) {
    1843           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->in.in_data)[in_data_cntr_0]");
    1844           0 :                                 return -1;
    1845             :                         }
    1846             :                         {
    1847           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((object->in.in_data)[in_data_cntr_0]));
    1848           0 :                                 if (PyLong_Check(PyList_GET_ITEM(value, in_data_cntr_0))) {
    1849             :                                         unsigned long long test_var;
    1850           0 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, in_data_cntr_0));
    1851           0 :                                         if (PyErr_Occurred() != NULL) {
    1852           0 :                                                 return -1;
    1853             :                                         }
    1854           0 :                                         if (test_var > uint_max) {
    1855           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1856             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    1857           0 :                                                 return -1;
    1858             :                                         }
    1859           0 :                                         (object->in.in_data)[in_data_cntr_0] = test_var;
    1860             :                                 } else {
    1861           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1862             :                                           PyLong_Type.tp_name);
    1863           0 :                                         return -1;
    1864             :                                 }
    1865             :                         }
    1866             :                 }
    1867             :         }
    1868           0 :         return 0;
    1869             : }
    1870             : 
    1871           0 : static PyObject *py_echo_EchoData_out_get_out_data(PyObject *obj, void *closure)
    1872             : {
    1873           0 :         struct echo_EchoData *object = pytalloc_get_ptr(obj);
    1874             :         PyObject *py_out_data;
    1875           0 :         py_out_data = PyList_New(object->in.len);
    1876           0 :         if (py_out_data == NULL) {
    1877           0 :                 return NULL;
    1878             :         }
    1879             :         {
    1880             :                 int out_data_cntr_0;
    1881           0 :                 for (out_data_cntr_0 = 0; out_data_cntr_0 < (object->in.len); out_data_cntr_0++) {
    1882             :                         PyObject *py_out_data_0;
    1883           0 :                         py_out_data_0 = PyLong_FromLong((uint16_t)((object->out.out_data)[out_data_cntr_0]));
    1884           0 :                         PyList_SetItem(py_out_data, out_data_cntr_0, py_out_data_0);
    1885             :                 }
    1886             :         }
    1887           0 :         return py_out_data;
    1888             : }
    1889             : 
    1890           0 : static int py_echo_EchoData_out_set_out_data(PyObject *py_obj, PyObject *value, void *closure)
    1891             : {
    1892           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    1893           0 :         if (value == NULL) {
    1894           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.out_data");
    1895           0 :                 return -1;
    1896             :         }
    1897           0 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    1898             :         {
    1899             :                 int out_data_cntr_0;
    1900           0 :                 object->out.out_data = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.out_data, PyList_GET_SIZE(value));
    1901           0 :                 if (!object->out.out_data) { return -1; }
    1902           0 :                 talloc_set_name_const(object->out.out_data, "ARRAY: object->out.out_data");
    1903           0 :                 for (out_data_cntr_0 = 0; out_data_cntr_0 < PyList_GET_SIZE(value); out_data_cntr_0++) {
    1904           0 :                         if (PyList_GET_ITEM(value, out_data_cntr_0) == NULL) {
    1905           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->out.out_data)[out_data_cntr_0]");
    1906           0 :                                 return -1;
    1907             :                         }
    1908             :                         {
    1909           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((object->out.out_data)[out_data_cntr_0]));
    1910           0 :                                 if (PyLong_Check(PyList_GET_ITEM(value, out_data_cntr_0))) {
    1911             :                                         unsigned long long test_var;
    1912           0 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, out_data_cntr_0));
    1913           0 :                                         if (PyErr_Occurred() != NULL) {
    1914           0 :                                                 return -1;
    1915             :                                         }
    1916           0 :                                         if (test_var > uint_max) {
    1917           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    1918             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    1919           0 :                                                 return -1;
    1920             :                                         }
    1921           0 :                                         (object->out.out_data)[out_data_cntr_0] = test_var;
    1922             :                                 } else {
    1923           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    1924             :                                           PyLong_Type.tp_name);
    1925           0 :                                         return -1;
    1926             :                                 }
    1927             :                         }
    1928             :                 }
    1929             :         }
    1930           0 :         return 0;
    1931             : }
    1932             : 
    1933             : static PyGetSetDef py_echo_EchoData_getsetters[] = {
    1934             :         {
    1935             :                 .name = discard_const_p(char, "in_len"),
    1936             :                 .get = py_echo_EchoData_in_get_len,
    1937             :                 .set = py_echo_EchoData_in_set_len,
    1938             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1939             :         },
    1940             :         {
    1941             :                 .name = discard_const_p(char, "in_in_data"),
    1942             :                 .get = py_echo_EchoData_in_get_in_data,
    1943             :                 .set = py_echo_EchoData_in_set_in_data,
    1944             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    1945             :         },
    1946             :         {
    1947             :                 .name = discard_const_p(char, "out_out_data"),
    1948             :                 .get = py_echo_EchoData_out_get_out_data,
    1949             :                 .set = py_echo_EchoData_out_set_out_data,
    1950             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    1951             :         },
    1952             :         { .name = NULL }
    1953             : };
    1954             : 
    1955           0 : static PyObject *py_echo_EchoData_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1956             : {
    1957           0 :         PyObject *self = pytalloc_new(struct echo_EchoData, type);
    1958           0 :         return self;
    1959             : }
    1960             : 
    1961           0 : static PyObject *py_echo_EchoData_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    1962             : {
    1963             : 
    1964             : 
    1965           0 :         return PyLong_FromLong(1);
    1966             : }
    1967             : 
    1968           0 : static PyObject *py_echo_EchoData_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    1969             : {
    1970           0 :         const struct ndr_interface_call *call = NULL;
    1971           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    1972           0 :         PyObject *ret = NULL;
    1973           0 :         struct ndr_push *push = NULL;
    1974             :         DATA_BLOB blob;
    1975             :         enum ndr_err_code err;
    1976             : 
    1977           0 :         if (ndr_table_rpcecho.num_calls < 2) {
    1978           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_EchoData_ndr_pack");
    1979           0 :                 return NULL;
    1980             :         }
    1981           0 :         call = &ndr_table_rpcecho.calls[1];
    1982             : 
    1983           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    1984           0 :         if (push == NULL) {
    1985           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1986           0 :                 return NULL;
    1987             :         }
    1988             : 
    1989           0 :         push->flags |= ndr_push_flags;
    1990             : 
    1991           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    1992           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1993           0 :                 TALLOC_FREE(push);
    1994           0 :                 PyErr_SetNdrError(err);
    1995           0 :                 return NULL;
    1996             :         }
    1997           0 :         blob = ndr_push_blob(push);
    1998           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    1999           0 :         TALLOC_FREE(push);
    2000           0 :         return ret;
    2001             : }
    2002             : 
    2003           0 : static PyObject *py_echo_EchoData_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2004             : {
    2005           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2006           0 :         PyObject *bigendian_obj = NULL;
    2007           0 :         PyObject *ndr64_obj = NULL;
    2008           0 :         libndr_flags ndr_push_flags = 0;
    2009             : 
    2010           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    2011             :                 discard_const_p(char *, kwnames),
    2012             :                 &bigendian_obj,
    2013             :                 &ndr64_obj)) {
    2014           0 :                 return NULL;
    2015             :         }
    2016             : 
    2017           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2018           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2019             :         }
    2020           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2021           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2022             :         }
    2023             : 
    2024           0 :         return py_echo_EchoData_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    2025             : }
    2026             : 
    2027           0 : static PyObject *py_echo_EchoData_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2028             : {
    2029           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2030           0 :         PyObject *bigendian_obj = NULL;
    2031           0 :         PyObject *ndr64_obj = NULL;
    2032           0 :         libndr_flags ndr_push_flags = 0;
    2033             : 
    2034           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    2035             :                 discard_const_p(char *, kwnames),
    2036             :                 &bigendian_obj,
    2037             :                 &ndr64_obj)) {
    2038           0 :                 return NULL;
    2039             :         }
    2040             : 
    2041           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2042           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2043             :         }
    2044           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2045           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2046             :         }
    2047             : 
    2048           0 :         return py_echo_EchoData_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    2049             : }
    2050             : 
    2051           0 : static PyObject *py_echo_EchoData_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    2052             : {
    2053           0 :         const struct ndr_interface_call *call = NULL;
    2054           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    2055           0 :         struct ndr_pull *pull = NULL;
    2056             :         enum ndr_err_code err;
    2057             : 
    2058           0 :         if (ndr_table_rpcecho.num_calls < 2) {
    2059           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_EchoData_ndr_unpack");
    2060           0 :                 return NULL;
    2061             :         }
    2062           0 :         call = &ndr_table_rpcecho.calls[1];
    2063             : 
    2064           0 :         pull = ndr_pull_init_blob(blob, object);
    2065           0 :         if (pull == NULL) {
    2066           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2067           0 :                 return NULL;
    2068             :         }
    2069             : 
    2070           0 :         pull->flags |= ndr_pull_flags;
    2071             : 
    2072           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    2073           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2074           0 :                 TALLOC_FREE(pull);
    2075           0 :                 PyErr_SetNdrError(err);
    2076           0 :                 return NULL;
    2077             :         }
    2078           0 :         if (!allow_remaining) {
    2079             :                 uint32_t highest_ofs;
    2080             : 
    2081           0 :                 if (pull->offset > pull->relative_highest_offset) {
    2082           0 :                         highest_ofs = pull->offset;
    2083             :                 } else {
    2084           0 :                         highest_ofs = pull->relative_highest_offset;
    2085             :                 }
    2086           0 :                 if (highest_ofs < pull->data_size) {
    2087           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    2088             :                                 "not all bytes consumed ofs[%u] size[%u]",
    2089             :                                 highest_ofs, pull->data_size);
    2090           0 :                         TALLOC_FREE(pull);
    2091           0 :                         PyErr_SetNdrError(err);
    2092           0 :                         return NULL;
    2093             :                 }
    2094             :         }
    2095             : 
    2096           0 :         TALLOC_FREE(pull);
    2097           0 :         Py_RETURN_NONE;
    2098             : }
    2099             : 
    2100           0 : static PyObject *py_echo_EchoData_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2101             : {
    2102             :         DATA_BLOB blob;
    2103           0 :         Py_ssize_t blob_length = 0;
    2104           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2105           0 :         PyObject *bigendian_obj = NULL;
    2106           0 :         PyObject *ndr64_obj = NULL;
    2107           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2108           0 :         PyObject *allow_remaining_obj = NULL;
    2109           0 :         bool allow_remaining = false;
    2110             : 
    2111           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    2112             :                 discard_const_p(char *, kwnames),
    2113             :                 &blob.data, &blob_length,
    2114             :                 &bigendian_obj,
    2115             :                 &ndr64_obj,
    2116             :                 &allow_remaining_obj)) {
    2117           0 :                 return NULL;
    2118             :         }
    2119           0 :         blob.length = blob_length;
    2120             : 
    2121           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2122           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2123             :         }
    2124           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2125           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2126             :         }
    2127             : 
    2128           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2129           0 :                 allow_remaining = true;
    2130             :         }
    2131             : 
    2132           0 :         return py_echo_EchoData_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    2133             : }
    2134             : 
    2135           0 : static PyObject *py_echo_EchoData_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2136             : {
    2137             :         DATA_BLOB blob;
    2138           0 :         Py_ssize_t blob_length = 0;
    2139           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2140           0 :         PyObject *bigendian_obj = NULL;
    2141           0 :         PyObject *ndr64_obj = NULL;
    2142           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2143           0 :         PyObject *allow_remaining_obj = NULL;
    2144           0 :         bool allow_remaining = false;
    2145             : 
    2146           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    2147             :                 discard_const_p(char *, kwnames),
    2148             :                 &blob.data, &blob_length,
    2149             :                 &bigendian_obj,
    2150             :                 &ndr64_obj,
    2151             :                 &allow_remaining_obj)) {
    2152           0 :                 return NULL;
    2153             :         }
    2154           0 :         blob.length = blob_length;
    2155             : 
    2156           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2157           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2158             :         }
    2159           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2160           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2161             :         }
    2162             : 
    2163           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2164           0 :                 allow_remaining = true;
    2165             :         }
    2166             : 
    2167           0 :         return py_echo_EchoData_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    2168             : }
    2169             : 
    2170           0 : static PyObject *py_echo_EchoData_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    2171             : {
    2172           0 :         const struct ndr_interface_call *call = NULL;
    2173           0 :         struct echo_EchoData *object = pytalloc_get_ptr(py_obj);
    2174             :         PyObject *ret;
    2175             :         char *retstr;
    2176             : 
    2177           0 :         if (ndr_table_rpcecho.num_calls < 2) {
    2178           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_EchoData_ndr_print");
    2179           0 :                 return NULL;
    2180             :         }
    2181           0 :         call = &ndr_table_rpcecho.calls[1];
    2182             : 
    2183           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    2184           0 :         ret = PyUnicode_FromString(retstr);
    2185           0 :         TALLOC_FREE(retstr);
    2186             : 
    2187           0 :         return ret;
    2188             : }
    2189             : 
    2190           0 : static PyObject *py_echo_EchoData_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2191             : {
    2192           0 :         return py_echo_EchoData_ndr_print(py_obj, "echo_EchoData_in", NDR_IN);
    2193             : }
    2194             : 
    2195           0 : static PyObject *py_echo_EchoData_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2196             : {
    2197           0 :         return py_echo_EchoData_ndr_print(py_obj, "echo_EchoData_out", NDR_OUT);
    2198             : }
    2199             : 
    2200             : static PyMethodDef py_echo_EchoData_methods[] = {
    2201             :         { "opnum", (PyCFunction)py_echo_EchoData_ndr_opnum, METH_NOARGS|METH_CLASS,
    2202             :                 "echo.EchoData.opnum() -> 1 (0x01) " },
    2203             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_EchoData_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    2204             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    2205             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_EchoData_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    2206             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    2207             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_EchoData_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    2208             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    2209             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_EchoData_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    2210             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    2211             :         { "__ndr_print_in__", (PyCFunction)py_echo_EchoData_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    2212             :         { "__ndr_print_out__", (PyCFunction)py_echo_EchoData_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    2213             :         { NULL, NULL, 0, NULL }
    2214             : };
    2215             : 
    2216             : 
    2217             : static PyTypeObject echo_EchoData_Type = {
    2218             :         PyVarObject_HEAD_INIT(NULL, 0)
    2219             :         .tp_name = "echo.EchoData",
    2220             :         .tp_getset = py_echo_EchoData_getsetters,
    2221             :         .tp_methods = py_echo_EchoData_methods,
    2222             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    2223             :         .tp_new = py_echo_EchoData_new,
    2224             : };
    2225             : 
    2226           7 : static bool pack_py_echo_EchoData_args_in(PyObject *args, PyObject *kwargs, struct echo_EchoData *r)
    2227             : {
    2228             :         PyObject *py_in_data;
    2229           7 :         const char *kwnames[] = {
    2230             :                 "in_data", NULL
    2231             :         };
    2232             : 
    2233           7 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_EchoData", discard_const_p(char *, kwnames), &py_in_data)) {
    2234           0 :                 return false;
    2235             :         }
    2236             : 
    2237           7 :         PY_CHECK_TYPE(&PyList_Type, py_in_data, return false;);
    2238           7 :         r->in.len = PyList_GET_SIZE(py_in_data);
    2239           7 :         if (py_in_data == NULL) {
    2240           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.in_data");
    2241           0 :                 return false;
    2242             :         }
    2243           7 :         PY_CHECK_TYPE(&PyList_Type, py_in_data, return false;);
    2244             :         {
    2245             :                 int in_data_cntr_0;
    2246           7 :                 r->in.in_data = talloc_array_ptrtype(r, r->in.in_data, PyList_GET_SIZE(py_in_data));
    2247           7 :                 if (!r->in.in_data) { return false; }
    2248           7 :                 talloc_set_name_const(r->in.in_data, "ARRAY: r->in.in_data");
    2249          28 :                 for (in_data_cntr_0 = 0; in_data_cntr_0 < PyList_GET_SIZE(py_in_data); in_data_cntr_0++) {
    2250          21 :                         if (PyList_GET_ITEM(py_in_data, in_data_cntr_0) == NULL) {
    2251           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (r->in.in_data)[in_data_cntr_0]");
    2252           0 :                                 return false;
    2253             :                         }
    2254             :                         {
    2255          21 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((r->in.in_data)[in_data_cntr_0]));
    2256          21 :                                 if (PyLong_Check(PyList_GET_ITEM(py_in_data, in_data_cntr_0))) {
    2257             :                                         unsigned long long test_var;
    2258          21 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(py_in_data, in_data_cntr_0));
    2259          21 :                                         if (PyErr_Occurred() != NULL) {
    2260           0 :                                                 return false;
    2261             :                                         }
    2262          21 :                                         if (test_var > uint_max) {
    2263           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2264             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    2265           0 :                                                 return false;
    2266             :                                         }
    2267          21 :                                         (r->in.in_data)[in_data_cntr_0] = test_var;
    2268             :                                 } else {
    2269           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2270             :                                           PyLong_Type.tp_name);
    2271           0 :                                         return false;
    2272             :                                 }
    2273             :                         }
    2274             :                 }
    2275             :         }
    2276           7 :         return true;
    2277             : }
    2278             : 
    2279           7 : static PyObject *unpack_py_echo_EchoData_args_out(struct echo_EchoData *r)
    2280             : {
    2281             :         PyObject *result;
    2282             :         PyObject *py_out_data;
    2283           7 :         py_out_data = PyList_New(r->in.len);
    2284           7 :         if (py_out_data == NULL) {
    2285           0 :                 return NULL;
    2286             :         }
    2287             :         {
    2288             :                 int out_data_cntr_0;
    2289          28 :                 for (out_data_cntr_0 = 0; out_data_cntr_0 < (r->in.len); out_data_cntr_0++) {
    2290             :                         PyObject *py_out_data_0;
    2291          21 :                         py_out_data_0 = PyLong_FromLong((uint16_t)((r->out.out_data)[out_data_cntr_0]));
    2292          21 :                         PyList_SetItem(py_out_data, out_data_cntr_0, py_out_data_0);
    2293             :                 }
    2294             :         }
    2295           7 :         result = py_out_data;
    2296           7 :         return result;
    2297             : }
    2298             : 
    2299             : 
    2300           0 : static PyObject *py_echo_SinkData_in_get_len(PyObject *obj, void *closure)
    2301             : {
    2302           0 :         struct echo_SinkData *object = pytalloc_get_ptr(obj);
    2303             :         PyObject *py_len;
    2304           0 :         py_len = PyLong_FromUnsignedLongLong((uint32_t)(object->in.len));
    2305           0 :         return py_len;
    2306             : }
    2307             : 
    2308           0 : static int py_echo_SinkData_in_set_len(PyObject *py_obj, PyObject *value, void *closure)
    2309             : {
    2310           0 :         struct echo_SinkData *object = pytalloc_get_ptr(py_obj);
    2311           0 :         if (value == NULL) {
    2312           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.len");
    2313           0 :                 return -1;
    2314             :         }
    2315             :         {
    2316           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.len));
    2317           0 :                 if (PyLong_Check(value)) {
    2318             :                         unsigned long long test_var;
    2319           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    2320           0 :                         if (PyErr_Occurred() != NULL) {
    2321           0 :                                 return -1;
    2322             :                         }
    2323           0 :                         if (test_var > uint_max) {
    2324           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2325             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2326           0 :                                 return -1;
    2327             :                         }
    2328           0 :                         object->in.len = test_var;
    2329             :                 } else {
    2330           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2331             :                           PyLong_Type.tp_name);
    2332           0 :                         return -1;
    2333             :                 }
    2334             :         }
    2335           0 :         return 0;
    2336             : }
    2337             : 
    2338           0 : static PyObject *py_echo_SinkData_in_get_data(PyObject *obj, void *closure)
    2339             : {
    2340           0 :         struct echo_SinkData *object = pytalloc_get_ptr(obj);
    2341             :         PyObject *py_data;
    2342           0 :         py_data = PyList_New(object->in.len);
    2343           0 :         if (py_data == NULL) {
    2344           0 :                 return NULL;
    2345             :         }
    2346             :         {
    2347             :                 int data_cntr_0;
    2348           0 :                 for (data_cntr_0 = 0; data_cntr_0 < (object->in.len); data_cntr_0++) {
    2349             :                         PyObject *py_data_0;
    2350           0 :                         py_data_0 = PyLong_FromLong((uint16_t)((object->in.data)[data_cntr_0]));
    2351           0 :                         PyList_SetItem(py_data, data_cntr_0, py_data_0);
    2352             :                 }
    2353             :         }
    2354           0 :         return py_data;
    2355             : }
    2356             : 
    2357           0 : static int py_echo_SinkData_in_set_data(PyObject *py_obj, PyObject *value, void *closure)
    2358             : {
    2359           0 :         struct echo_SinkData *object = pytalloc_get_ptr(py_obj);
    2360           0 :         if (value == NULL) {
    2361           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.data");
    2362           0 :                 return -1;
    2363             :         }
    2364           0 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    2365             :         {
    2366             :                 int data_cntr_0;
    2367           0 :                 object->in.data = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.data, PyList_GET_SIZE(value));
    2368           0 :                 if (!object->in.data) { return -1; }
    2369           0 :                 talloc_set_name_const(object->in.data, "ARRAY: object->in.data");
    2370           0 :                 for (data_cntr_0 = 0; data_cntr_0 < PyList_GET_SIZE(value); data_cntr_0++) {
    2371           0 :                         if (PyList_GET_ITEM(value, data_cntr_0) == NULL) {
    2372           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->in.data)[data_cntr_0]");
    2373           0 :                                 return -1;
    2374             :                         }
    2375             :                         {
    2376           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((object->in.data)[data_cntr_0]));
    2377           0 :                                 if (PyLong_Check(PyList_GET_ITEM(value, data_cntr_0))) {
    2378             :                                         unsigned long long test_var;
    2379           0 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, data_cntr_0));
    2380           0 :                                         if (PyErr_Occurred() != NULL) {
    2381           0 :                                                 return -1;
    2382             :                                         }
    2383           0 :                                         if (test_var > uint_max) {
    2384           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2385             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    2386           0 :                                                 return -1;
    2387             :                                         }
    2388           0 :                                         (object->in.data)[data_cntr_0] = test_var;
    2389             :                                 } else {
    2390           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2391             :                                           PyLong_Type.tp_name);
    2392           0 :                                         return -1;
    2393             :                                 }
    2394             :                         }
    2395             :                 }
    2396             :         }
    2397           0 :         return 0;
    2398             : }
    2399             : 
    2400             : static PyGetSetDef py_echo_SinkData_getsetters[] = {
    2401             :         {
    2402             :                 .name = discard_const_p(char, "in_len"),
    2403             :                 .get = py_echo_SinkData_in_get_len,
    2404             :                 .set = py_echo_SinkData_in_set_len,
    2405             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    2406             :         },
    2407             :         {
    2408             :                 .name = discard_const_p(char, "in_data"),
    2409             :                 .get = py_echo_SinkData_in_get_data,
    2410             :                 .set = py_echo_SinkData_in_set_data,
    2411             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    2412             :         },
    2413             :         { .name = NULL }
    2414             : };
    2415             : 
    2416           0 : static PyObject *py_echo_SinkData_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    2417             : {
    2418           0 :         PyObject *self = pytalloc_new(struct echo_SinkData, type);
    2419           0 :         return self;
    2420             : }
    2421             : 
    2422           0 : static PyObject *py_echo_SinkData_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    2423             : {
    2424             : 
    2425             : 
    2426           0 :         return PyLong_FromLong(2);
    2427             : }
    2428             : 
    2429           0 : static PyObject *py_echo_SinkData_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    2430             : {
    2431           0 :         const struct ndr_interface_call *call = NULL;
    2432           0 :         struct echo_SinkData *object = pytalloc_get_ptr(py_obj);
    2433           0 :         PyObject *ret = NULL;
    2434           0 :         struct ndr_push *push = NULL;
    2435             :         DATA_BLOB blob;
    2436             :         enum ndr_err_code err;
    2437             : 
    2438           0 :         if (ndr_table_rpcecho.num_calls < 3) {
    2439           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SinkData_ndr_pack");
    2440           0 :                 return NULL;
    2441             :         }
    2442           0 :         call = &ndr_table_rpcecho.calls[2];
    2443             : 
    2444           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    2445           0 :         if (push == NULL) {
    2446           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2447           0 :                 return NULL;
    2448             :         }
    2449             : 
    2450           0 :         push->flags |= ndr_push_flags;
    2451             : 
    2452           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    2453           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2454           0 :                 TALLOC_FREE(push);
    2455           0 :                 PyErr_SetNdrError(err);
    2456           0 :                 return NULL;
    2457             :         }
    2458           0 :         blob = ndr_push_blob(push);
    2459           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    2460           0 :         TALLOC_FREE(push);
    2461           0 :         return ret;
    2462             : }
    2463             : 
    2464           0 : static PyObject *py_echo_SinkData_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2465             : {
    2466           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2467           0 :         PyObject *bigendian_obj = NULL;
    2468           0 :         PyObject *ndr64_obj = NULL;
    2469           0 :         libndr_flags ndr_push_flags = 0;
    2470             : 
    2471           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    2472             :                 discard_const_p(char *, kwnames),
    2473             :                 &bigendian_obj,
    2474             :                 &ndr64_obj)) {
    2475           0 :                 return NULL;
    2476             :         }
    2477             : 
    2478           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2479           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2480             :         }
    2481           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2482           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2483             :         }
    2484             : 
    2485           0 :         return py_echo_SinkData_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    2486             : }
    2487             : 
    2488           0 : static PyObject *py_echo_SinkData_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2489             : {
    2490           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2491           0 :         PyObject *bigendian_obj = NULL;
    2492           0 :         PyObject *ndr64_obj = NULL;
    2493           0 :         libndr_flags ndr_push_flags = 0;
    2494             : 
    2495           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    2496             :                 discard_const_p(char *, kwnames),
    2497             :                 &bigendian_obj,
    2498             :                 &ndr64_obj)) {
    2499           0 :                 return NULL;
    2500             :         }
    2501             : 
    2502           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2503           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2504             :         }
    2505           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2506           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2507             :         }
    2508             : 
    2509           0 :         return py_echo_SinkData_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    2510             : }
    2511             : 
    2512           0 : static PyObject *py_echo_SinkData_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    2513             : {
    2514           0 :         const struct ndr_interface_call *call = NULL;
    2515           0 :         struct echo_SinkData *object = pytalloc_get_ptr(py_obj);
    2516           0 :         struct ndr_pull *pull = NULL;
    2517             :         enum ndr_err_code err;
    2518             : 
    2519           0 :         if (ndr_table_rpcecho.num_calls < 3) {
    2520           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SinkData_ndr_unpack");
    2521           0 :                 return NULL;
    2522             :         }
    2523           0 :         call = &ndr_table_rpcecho.calls[2];
    2524             : 
    2525           0 :         pull = ndr_pull_init_blob(blob, object);
    2526           0 :         if (pull == NULL) {
    2527           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2528           0 :                 return NULL;
    2529             :         }
    2530             : 
    2531           0 :         pull->flags |= ndr_pull_flags;
    2532             : 
    2533           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    2534           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2535           0 :                 TALLOC_FREE(pull);
    2536           0 :                 PyErr_SetNdrError(err);
    2537           0 :                 return NULL;
    2538             :         }
    2539           0 :         if (!allow_remaining) {
    2540             :                 uint32_t highest_ofs;
    2541             : 
    2542           0 :                 if (pull->offset > pull->relative_highest_offset) {
    2543           0 :                         highest_ofs = pull->offset;
    2544             :                 } else {
    2545           0 :                         highest_ofs = pull->relative_highest_offset;
    2546             :                 }
    2547           0 :                 if (highest_ofs < pull->data_size) {
    2548           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    2549             :                                 "not all bytes consumed ofs[%u] size[%u]",
    2550             :                                 highest_ofs, pull->data_size);
    2551           0 :                         TALLOC_FREE(pull);
    2552           0 :                         PyErr_SetNdrError(err);
    2553           0 :                         return NULL;
    2554             :                 }
    2555             :         }
    2556             : 
    2557           0 :         TALLOC_FREE(pull);
    2558           0 :         Py_RETURN_NONE;
    2559             : }
    2560             : 
    2561           0 : static PyObject *py_echo_SinkData_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2562             : {
    2563             :         DATA_BLOB blob;
    2564           0 :         Py_ssize_t blob_length = 0;
    2565           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2566           0 :         PyObject *bigendian_obj = NULL;
    2567           0 :         PyObject *ndr64_obj = NULL;
    2568           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2569           0 :         PyObject *allow_remaining_obj = NULL;
    2570           0 :         bool allow_remaining = false;
    2571             : 
    2572           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    2573             :                 discard_const_p(char *, kwnames),
    2574             :                 &blob.data, &blob_length,
    2575             :                 &bigendian_obj,
    2576             :                 &ndr64_obj,
    2577             :                 &allow_remaining_obj)) {
    2578           0 :                 return NULL;
    2579             :         }
    2580           0 :         blob.length = blob_length;
    2581             : 
    2582           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2583           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2584             :         }
    2585           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2586           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2587             :         }
    2588             : 
    2589           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2590           0 :                 allow_remaining = true;
    2591             :         }
    2592             : 
    2593           0 :         return py_echo_SinkData_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    2594             : }
    2595             : 
    2596           0 : static PyObject *py_echo_SinkData_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2597             : {
    2598             :         DATA_BLOB blob;
    2599           0 :         Py_ssize_t blob_length = 0;
    2600           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2601           0 :         PyObject *bigendian_obj = NULL;
    2602           0 :         PyObject *ndr64_obj = NULL;
    2603           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2604           0 :         PyObject *allow_remaining_obj = NULL;
    2605           0 :         bool allow_remaining = false;
    2606             : 
    2607           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    2608             :                 discard_const_p(char *, kwnames),
    2609             :                 &blob.data, &blob_length,
    2610             :                 &bigendian_obj,
    2611             :                 &ndr64_obj,
    2612             :                 &allow_remaining_obj)) {
    2613           0 :                 return NULL;
    2614             :         }
    2615           0 :         blob.length = blob_length;
    2616             : 
    2617           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2618           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2619             :         }
    2620           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2621           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2622             :         }
    2623             : 
    2624           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2625           0 :                 allow_remaining = true;
    2626             :         }
    2627             : 
    2628           0 :         return py_echo_SinkData_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    2629             : }
    2630             : 
    2631           0 : static PyObject *py_echo_SinkData_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    2632             : {
    2633           0 :         const struct ndr_interface_call *call = NULL;
    2634           0 :         struct echo_SinkData *object = pytalloc_get_ptr(py_obj);
    2635             :         PyObject *ret;
    2636             :         char *retstr;
    2637             : 
    2638           0 :         if (ndr_table_rpcecho.num_calls < 3) {
    2639           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SinkData_ndr_print");
    2640           0 :                 return NULL;
    2641             :         }
    2642           0 :         call = &ndr_table_rpcecho.calls[2];
    2643             : 
    2644           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    2645           0 :         ret = PyUnicode_FromString(retstr);
    2646           0 :         TALLOC_FREE(retstr);
    2647             : 
    2648           0 :         return ret;
    2649             : }
    2650             : 
    2651           0 : static PyObject *py_echo_SinkData_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2652             : {
    2653           0 :         return py_echo_SinkData_ndr_print(py_obj, "echo_SinkData_in", NDR_IN);
    2654             : }
    2655             : 
    2656           0 : static PyObject *py_echo_SinkData_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2657             : {
    2658           0 :         return py_echo_SinkData_ndr_print(py_obj, "echo_SinkData_out", NDR_OUT);
    2659             : }
    2660             : 
    2661             : static PyMethodDef py_echo_SinkData_methods[] = {
    2662             :         { "opnum", (PyCFunction)py_echo_SinkData_ndr_opnum, METH_NOARGS|METH_CLASS,
    2663             :                 "echo.SinkData.opnum() -> 2 (0x02) " },
    2664             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SinkData_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    2665             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    2666             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SinkData_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    2667             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    2668             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SinkData_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    2669             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    2670             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SinkData_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    2671             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    2672             :         { "__ndr_print_in__", (PyCFunction)py_echo_SinkData_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    2673             :         { "__ndr_print_out__", (PyCFunction)py_echo_SinkData_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    2674             :         { NULL, NULL, 0, NULL }
    2675             : };
    2676             : 
    2677             : 
    2678             : static PyTypeObject echo_SinkData_Type = {
    2679             :         PyVarObject_HEAD_INIT(NULL, 0)
    2680             :         .tp_name = "echo.SinkData",
    2681             :         .tp_getset = py_echo_SinkData_getsetters,
    2682             :         .tp_methods = py_echo_SinkData_methods,
    2683             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    2684             :         .tp_new = py_echo_SinkData_new,
    2685             : };
    2686             : 
    2687           0 : static bool pack_py_echo_SinkData_args_in(PyObject *args, PyObject *kwargs, struct echo_SinkData *r)
    2688             : {
    2689             :         PyObject *py_data;
    2690           0 :         const char *kwnames[] = {
    2691             :                 "data", NULL
    2692             :         };
    2693             : 
    2694           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_SinkData", discard_const_p(char *, kwnames), &py_data)) {
    2695           0 :                 return false;
    2696             :         }
    2697             : 
    2698           0 :         PY_CHECK_TYPE(&PyList_Type, py_data, return false;);
    2699           0 :         r->in.len = PyList_GET_SIZE(py_data);
    2700           0 :         if (py_data == NULL) {
    2701           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.data");
    2702           0 :                 return false;
    2703             :         }
    2704           0 :         PY_CHECK_TYPE(&PyList_Type, py_data, return false;);
    2705             :         {
    2706             :                 int data_cntr_0;
    2707           0 :                 r->in.data = talloc_array_ptrtype(r, r->in.data, PyList_GET_SIZE(py_data));
    2708           0 :                 if (!r->in.data) { return false; }
    2709           0 :                 talloc_set_name_const(r->in.data, "ARRAY: r->in.data");
    2710           0 :                 for (data_cntr_0 = 0; data_cntr_0 < PyList_GET_SIZE(py_data); data_cntr_0++) {
    2711           0 :                         if (PyList_GET_ITEM(py_data, data_cntr_0) == NULL) {
    2712           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (r->in.data)[data_cntr_0]");
    2713           0 :                                 return false;
    2714             :                         }
    2715             :                         {
    2716           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((r->in.data)[data_cntr_0]));
    2717           0 :                                 if (PyLong_Check(PyList_GET_ITEM(py_data, data_cntr_0))) {
    2718             :                                         unsigned long long test_var;
    2719           0 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(py_data, data_cntr_0));
    2720           0 :                                         if (PyErr_Occurred() != NULL) {
    2721           0 :                                                 return false;
    2722             :                                         }
    2723           0 :                                         if (test_var > uint_max) {
    2724           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2725             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    2726           0 :                                                 return false;
    2727             :                                         }
    2728           0 :                                         (r->in.data)[data_cntr_0] = test_var;
    2729             :                                 } else {
    2730           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2731             :                                           PyLong_Type.tp_name);
    2732           0 :                                         return false;
    2733             :                                 }
    2734             :                         }
    2735             :                 }
    2736             :         }
    2737           0 :         return true;
    2738             : }
    2739             : 
    2740           0 : static PyObject *unpack_py_echo_SinkData_args_out(struct echo_SinkData *r)
    2741             : {
    2742             :         PyObject *result;
    2743           0 :         result = Py_None;
    2744           0 :         Py_INCREF(result);
    2745           0 :         return result;
    2746             : }
    2747             : 
    2748             : 
    2749           0 : static PyObject *py_echo_SourceData_in_get_len(PyObject *obj, void *closure)
    2750             : {
    2751           0 :         struct echo_SourceData *object = pytalloc_get_ptr(obj);
    2752             :         PyObject *py_len;
    2753           0 :         py_len = PyLong_FromUnsignedLongLong((uint32_t)(object->in.len));
    2754           0 :         return py_len;
    2755             : }
    2756             : 
    2757           0 : static int py_echo_SourceData_in_set_len(PyObject *py_obj, PyObject *value, void *closure)
    2758             : {
    2759           0 :         struct echo_SourceData *object = pytalloc_get_ptr(py_obj);
    2760           0 :         if (value == NULL) {
    2761           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.len");
    2762           0 :                 return -1;
    2763             :         }
    2764             :         {
    2765           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.len));
    2766           0 :                 if (PyLong_Check(value)) {
    2767             :                         unsigned long long test_var;
    2768           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    2769           0 :                         if (PyErr_Occurred() != NULL) {
    2770           0 :                                 return -1;
    2771             :                         }
    2772           0 :                         if (test_var > uint_max) {
    2773           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2774             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2775           0 :                                 return -1;
    2776             :                         }
    2777           0 :                         object->in.len = test_var;
    2778             :                 } else {
    2779           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2780             :                           PyLong_Type.tp_name);
    2781           0 :                         return -1;
    2782             :                 }
    2783             :         }
    2784           0 :         return 0;
    2785             : }
    2786             : 
    2787           0 : static PyObject *py_echo_SourceData_out_get_data(PyObject *obj, void *closure)
    2788             : {
    2789           0 :         struct echo_SourceData *object = pytalloc_get_ptr(obj);
    2790             :         PyObject *py_data;
    2791           0 :         py_data = PyList_New(object->in.len);
    2792           0 :         if (py_data == NULL) {
    2793           0 :                 return NULL;
    2794             :         }
    2795             :         {
    2796             :                 int data_cntr_0;
    2797           0 :                 for (data_cntr_0 = 0; data_cntr_0 < (object->in.len); data_cntr_0++) {
    2798             :                         PyObject *py_data_0;
    2799           0 :                         py_data_0 = PyLong_FromLong((uint16_t)((object->out.data)[data_cntr_0]));
    2800           0 :                         PyList_SetItem(py_data, data_cntr_0, py_data_0);
    2801             :                 }
    2802             :         }
    2803           0 :         return py_data;
    2804             : }
    2805             : 
    2806           0 : static int py_echo_SourceData_out_set_data(PyObject *py_obj, PyObject *value, void *closure)
    2807             : {
    2808           0 :         struct echo_SourceData *object = pytalloc_get_ptr(py_obj);
    2809           0 :         if (value == NULL) {
    2810           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.data");
    2811           0 :                 return -1;
    2812             :         }
    2813           0 :         PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    2814             :         {
    2815             :                 int data_cntr_0;
    2816           0 :                 object->out.data = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.data, PyList_GET_SIZE(value));
    2817           0 :                 if (!object->out.data) { return -1; }
    2818           0 :                 talloc_set_name_const(object->out.data, "ARRAY: object->out.data");
    2819           0 :                 for (data_cntr_0 = 0; data_cntr_0 < PyList_GET_SIZE(value); data_cntr_0++) {
    2820           0 :                         if (PyList_GET_ITEM(value, data_cntr_0) == NULL) {
    2821           0 :                                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: (object->out.data)[data_cntr_0]");
    2822           0 :                                 return -1;
    2823             :                         }
    2824             :                         {
    2825           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof((object->out.data)[data_cntr_0]));
    2826           0 :                                 if (PyLong_Check(PyList_GET_ITEM(value, data_cntr_0))) {
    2827             :                                         unsigned long long test_var;
    2828           0 :                                         test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, data_cntr_0));
    2829           0 :                                         if (PyErr_Occurred() != NULL) {
    2830           0 :                                                 return -1;
    2831             :                                         }
    2832           0 :                                         if (test_var > uint_max) {
    2833           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    2834             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    2835           0 :                                                 return -1;
    2836             :                                         }
    2837           0 :                                         (object->out.data)[data_cntr_0] = test_var;
    2838             :                                 } else {
    2839           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    2840             :                                           PyLong_Type.tp_name);
    2841           0 :                                         return -1;
    2842             :                                 }
    2843             :                         }
    2844             :                 }
    2845             :         }
    2846           0 :         return 0;
    2847             : }
    2848             : 
    2849             : static PyGetSetDef py_echo_SourceData_getsetters[] = {
    2850             :         {
    2851             :                 .name = discard_const_p(char, "in_len"),
    2852             :                 .get = py_echo_SourceData_in_get_len,
    2853             :                 .set = py_echo_SourceData_in_set_len,
    2854             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    2855             :         },
    2856             :         {
    2857             :                 .name = discard_const_p(char, "out_data"),
    2858             :                 .get = py_echo_SourceData_out_get_data,
    2859             :                 .set = py_echo_SourceData_out_set_data,
    2860             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    2861             :         },
    2862             :         { .name = NULL }
    2863             : };
    2864             : 
    2865           0 : static PyObject *py_echo_SourceData_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    2866             : {
    2867           0 :         PyObject *self = pytalloc_new(struct echo_SourceData, type);
    2868           0 :         return self;
    2869             : }
    2870             : 
    2871           0 : static PyObject *py_echo_SourceData_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    2872             : {
    2873             : 
    2874             : 
    2875           0 :         return PyLong_FromLong(3);
    2876             : }
    2877             : 
    2878           0 : static PyObject *py_echo_SourceData_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    2879             : {
    2880           0 :         const struct ndr_interface_call *call = NULL;
    2881           0 :         struct echo_SourceData *object = pytalloc_get_ptr(py_obj);
    2882           0 :         PyObject *ret = NULL;
    2883           0 :         struct ndr_push *push = NULL;
    2884             :         DATA_BLOB blob;
    2885             :         enum ndr_err_code err;
    2886             : 
    2887           0 :         if (ndr_table_rpcecho.num_calls < 4) {
    2888           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SourceData_ndr_pack");
    2889           0 :                 return NULL;
    2890             :         }
    2891           0 :         call = &ndr_table_rpcecho.calls[3];
    2892             : 
    2893           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    2894           0 :         if (push == NULL) {
    2895           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2896           0 :                 return NULL;
    2897             :         }
    2898             : 
    2899           0 :         push->flags |= ndr_push_flags;
    2900             : 
    2901           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    2902           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2903           0 :                 TALLOC_FREE(push);
    2904           0 :                 PyErr_SetNdrError(err);
    2905           0 :                 return NULL;
    2906             :         }
    2907           0 :         blob = ndr_push_blob(push);
    2908           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    2909           0 :         TALLOC_FREE(push);
    2910           0 :         return ret;
    2911             : }
    2912             : 
    2913           0 : static PyObject *py_echo_SourceData_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2914             : {
    2915           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2916           0 :         PyObject *bigendian_obj = NULL;
    2917           0 :         PyObject *ndr64_obj = NULL;
    2918           0 :         libndr_flags ndr_push_flags = 0;
    2919             : 
    2920           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    2921             :                 discard_const_p(char *, kwnames),
    2922             :                 &bigendian_obj,
    2923             :                 &ndr64_obj)) {
    2924           0 :                 return NULL;
    2925             :         }
    2926             : 
    2927           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2928           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2929             :         }
    2930           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2931           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2932             :         }
    2933             : 
    2934           0 :         return py_echo_SourceData_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    2935             : }
    2936             : 
    2937           0 : static PyObject *py_echo_SourceData_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2938             : {
    2939           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2940           0 :         PyObject *bigendian_obj = NULL;
    2941           0 :         PyObject *ndr64_obj = NULL;
    2942           0 :         libndr_flags ndr_push_flags = 0;
    2943             : 
    2944           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    2945             :                 discard_const_p(char *, kwnames),
    2946             :                 &bigendian_obj,
    2947             :                 &ndr64_obj)) {
    2948           0 :                 return NULL;
    2949             :         }
    2950             : 
    2951           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2952           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2953             :         }
    2954           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2955           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2956             :         }
    2957             : 
    2958           0 :         return py_echo_SourceData_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    2959             : }
    2960             : 
    2961           0 : static PyObject *py_echo_SourceData_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    2962             : {
    2963           0 :         const struct ndr_interface_call *call = NULL;
    2964           0 :         struct echo_SourceData *object = pytalloc_get_ptr(py_obj);
    2965           0 :         struct ndr_pull *pull = NULL;
    2966             :         enum ndr_err_code err;
    2967             : 
    2968           0 :         if (ndr_table_rpcecho.num_calls < 4) {
    2969           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SourceData_ndr_unpack");
    2970           0 :                 return NULL;
    2971             :         }
    2972           0 :         call = &ndr_table_rpcecho.calls[3];
    2973             : 
    2974           0 :         pull = ndr_pull_init_blob(blob, object);
    2975           0 :         if (pull == NULL) {
    2976           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2977           0 :                 return NULL;
    2978             :         }
    2979             : 
    2980           0 :         pull->flags |= ndr_pull_flags;
    2981             : 
    2982           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    2983           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2984           0 :                 TALLOC_FREE(pull);
    2985           0 :                 PyErr_SetNdrError(err);
    2986           0 :                 return NULL;
    2987             :         }
    2988           0 :         if (!allow_remaining) {
    2989             :                 uint32_t highest_ofs;
    2990             : 
    2991           0 :                 if (pull->offset > pull->relative_highest_offset) {
    2992           0 :                         highest_ofs = pull->offset;
    2993             :                 } else {
    2994           0 :                         highest_ofs = pull->relative_highest_offset;
    2995             :                 }
    2996           0 :                 if (highest_ofs < pull->data_size) {
    2997           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    2998             :                                 "not all bytes consumed ofs[%u] size[%u]",
    2999             :                                 highest_ofs, pull->data_size);
    3000           0 :                         TALLOC_FREE(pull);
    3001           0 :                         PyErr_SetNdrError(err);
    3002           0 :                         return NULL;
    3003             :                 }
    3004             :         }
    3005             : 
    3006           0 :         TALLOC_FREE(pull);
    3007           0 :         Py_RETURN_NONE;
    3008             : }
    3009             : 
    3010           0 : static PyObject *py_echo_SourceData_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3011             : {
    3012             :         DATA_BLOB blob;
    3013           0 :         Py_ssize_t blob_length = 0;
    3014           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3015           0 :         PyObject *bigendian_obj = NULL;
    3016           0 :         PyObject *ndr64_obj = NULL;
    3017           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3018           0 :         PyObject *allow_remaining_obj = NULL;
    3019           0 :         bool allow_remaining = false;
    3020             : 
    3021           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    3022             :                 discard_const_p(char *, kwnames),
    3023             :                 &blob.data, &blob_length,
    3024             :                 &bigendian_obj,
    3025             :                 &ndr64_obj,
    3026             :                 &allow_remaining_obj)) {
    3027           0 :                 return NULL;
    3028             :         }
    3029           0 :         blob.length = blob_length;
    3030             : 
    3031           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3032           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3033             :         }
    3034           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3035           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3036             :         }
    3037             : 
    3038           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3039           0 :                 allow_remaining = true;
    3040             :         }
    3041             : 
    3042           0 :         return py_echo_SourceData_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    3043             : }
    3044             : 
    3045           0 : static PyObject *py_echo_SourceData_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3046             : {
    3047             :         DATA_BLOB blob;
    3048           0 :         Py_ssize_t blob_length = 0;
    3049           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3050           0 :         PyObject *bigendian_obj = NULL;
    3051           0 :         PyObject *ndr64_obj = NULL;
    3052           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3053           0 :         PyObject *allow_remaining_obj = NULL;
    3054           0 :         bool allow_remaining = false;
    3055             : 
    3056           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    3057             :                 discard_const_p(char *, kwnames),
    3058             :                 &blob.data, &blob_length,
    3059             :                 &bigendian_obj,
    3060             :                 &ndr64_obj,
    3061             :                 &allow_remaining_obj)) {
    3062           0 :                 return NULL;
    3063             :         }
    3064           0 :         blob.length = blob_length;
    3065             : 
    3066           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3067           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3068             :         }
    3069           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3070           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3071             :         }
    3072             : 
    3073           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3074           0 :                 allow_remaining = true;
    3075             :         }
    3076             : 
    3077           0 :         return py_echo_SourceData_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    3078             : }
    3079             : 
    3080           0 : static PyObject *py_echo_SourceData_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    3081             : {
    3082           0 :         const struct ndr_interface_call *call = NULL;
    3083           0 :         struct echo_SourceData *object = pytalloc_get_ptr(py_obj);
    3084             :         PyObject *ret;
    3085             :         char *retstr;
    3086             : 
    3087           0 :         if (ndr_table_rpcecho.num_calls < 4) {
    3088           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_SourceData_ndr_print");
    3089           0 :                 return NULL;
    3090             :         }
    3091           0 :         call = &ndr_table_rpcecho.calls[3];
    3092             : 
    3093           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    3094           0 :         ret = PyUnicode_FromString(retstr);
    3095           0 :         TALLOC_FREE(retstr);
    3096             : 
    3097           0 :         return ret;
    3098             : }
    3099             : 
    3100           0 : static PyObject *py_echo_SourceData_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3101             : {
    3102           0 :         return py_echo_SourceData_ndr_print(py_obj, "echo_SourceData_in", NDR_IN);
    3103             : }
    3104             : 
    3105           0 : static PyObject *py_echo_SourceData_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3106             : {
    3107           0 :         return py_echo_SourceData_ndr_print(py_obj, "echo_SourceData_out", NDR_OUT);
    3108             : }
    3109             : 
    3110             : static PyMethodDef py_echo_SourceData_methods[] = {
    3111             :         { "opnum", (PyCFunction)py_echo_SourceData_ndr_opnum, METH_NOARGS|METH_CLASS,
    3112             :                 "echo.SourceData.opnum() -> 3 (0x03) " },
    3113             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SourceData_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    3114             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    3115             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SourceData_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    3116             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    3117             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SourceData_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    3118             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    3119             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_SourceData_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    3120             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    3121             :         { "__ndr_print_in__", (PyCFunction)py_echo_SourceData_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    3122             :         { "__ndr_print_out__", (PyCFunction)py_echo_SourceData_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    3123             :         { NULL, NULL, 0, NULL }
    3124             : };
    3125             : 
    3126             : 
    3127             : static PyTypeObject echo_SourceData_Type = {
    3128             :         PyVarObject_HEAD_INIT(NULL, 0)
    3129             :         .tp_name = "echo.SourceData",
    3130             :         .tp_getset = py_echo_SourceData_getsetters,
    3131             :         .tp_methods = py_echo_SourceData_methods,
    3132             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    3133             :         .tp_new = py_echo_SourceData_new,
    3134             : };
    3135             : 
    3136           0 : static bool pack_py_echo_SourceData_args_in(PyObject *args, PyObject *kwargs, struct echo_SourceData *r)
    3137             : {
    3138             :         PyObject *py_len;
    3139           0 :         const char *kwnames[] = {
    3140             :                 "len", NULL
    3141             :         };
    3142             : 
    3143           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_SourceData", discard_const_p(char *, kwnames), &py_len)) {
    3144           0 :                 return false;
    3145             :         }
    3146             : 
    3147           0 :         if (py_len == NULL) {
    3148           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.len");
    3149           0 :                 return false;
    3150             :         }
    3151             :         {
    3152           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.len));
    3153           0 :                 if (PyLong_Check(py_len)) {
    3154             :                         unsigned long long test_var;
    3155           0 :                         test_var = PyLong_AsUnsignedLongLong(py_len);
    3156           0 :                         if (PyErr_Occurred() != NULL) {
    3157           0 :                                 return false;
    3158             :                         }
    3159           0 :                         if (test_var > uint_max) {
    3160           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    3161             :                                   PyLong_Type.tp_name, uint_max, test_var);
    3162           0 :                                 return false;
    3163             :                         }
    3164           0 :                         r->in.len = test_var;
    3165             :                 } else {
    3166           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    3167             :                           PyLong_Type.tp_name);
    3168           0 :                         return false;
    3169             :                 }
    3170             :         }
    3171           0 :         return true;
    3172             : }
    3173             : 
    3174           0 : static PyObject *unpack_py_echo_SourceData_args_out(struct echo_SourceData *r)
    3175             : {
    3176             :         PyObject *result;
    3177             :         PyObject *py_data;
    3178           0 :         py_data = PyList_New(r->in.len);
    3179           0 :         if (py_data == NULL) {
    3180           0 :                 return NULL;
    3181             :         }
    3182             :         {
    3183             :                 int data_cntr_0;
    3184           0 :                 for (data_cntr_0 = 0; data_cntr_0 < (r->in.len); data_cntr_0++) {
    3185             :                         PyObject *py_data_0;
    3186           0 :                         py_data_0 = PyLong_FromLong((uint16_t)((r->out.data)[data_cntr_0]));
    3187           0 :                         PyList_SetItem(py_data, data_cntr_0, py_data_0);
    3188             :                 }
    3189             :         }
    3190           0 :         result = py_data;
    3191           0 :         return result;
    3192             : }
    3193             : 
    3194             : 
    3195           0 : static PyObject *py_echo_TestCall_in_get_s1(PyObject *obj, void *closure)
    3196             : {
    3197           0 :         struct echo_TestCall *object = pytalloc_get_ptr(obj);
    3198             :         PyObject *py_s1;
    3199           0 :         if (object->in.s1 == NULL) {
    3200           0 :                 Py_RETURN_NONE;
    3201             :         }
    3202           0 :         if (object->in.s1 == NULL) {
    3203           0 :                 py_s1 = Py_None;
    3204           0 :                 Py_INCREF(py_s1);
    3205             :         } else {
    3206           0 :                 py_s1 = PyUnicode_Decode(object->in.s1, strlen(object->in.s1), "utf-8", "ignore");
    3207             :         }
    3208           0 :         return py_s1;
    3209             : }
    3210             : 
    3211           0 : static int py_echo_TestCall_in_set_s1(PyObject *py_obj, PyObject *value, void *closure)
    3212             : {
    3213           0 :         struct echo_TestCall *object = pytalloc_get_ptr(py_obj);
    3214           0 :         if (value == NULL) {
    3215           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.s1");
    3216           0 :                 return -1;
    3217             :         }
    3218           0 :         object->in.s1 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.s1);
    3219           0 :         if (object->in.s1 == NULL) {
    3220           0 :                 PyErr_NoMemory();
    3221           0 :                 return -1;
    3222             :         }
    3223             :         {
    3224             :                 const char *test_str;
    3225             :                 const char *talloc_str;
    3226           0 :                 PyObject *unicode = NULL;
    3227           0 :                 if (PyUnicode_Check(value)) {
    3228           0 :                         unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
    3229           0 :                         if (unicode == NULL) {
    3230           0 :                                 return -1;
    3231             :                         }
    3232           0 :                         test_str = PyBytes_AS_STRING(unicode);
    3233           0 :                 } else if (PyBytes_Check(value)) {
    3234           0 :                         test_str = PyBytes_AS_STRING(value);
    3235             :                 } else {
    3236           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
    3237           0 :                         return -1;
    3238             :                 }
    3239           0 :                 talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
    3240           0 :                 if (unicode != NULL) {
    3241           0 :                         Py_DECREF(unicode);
    3242             :                 }
    3243           0 :                 if (talloc_str == NULL) {
    3244           0 :                         PyErr_NoMemory();
    3245           0 :                         return -1;
    3246             :                 }
    3247           0 :                 object->in.s1 = talloc_str;
    3248             :         }
    3249           0 :         return 0;
    3250             : }
    3251             : 
    3252           0 : static PyObject *py_echo_TestCall_out_get_s2(PyObject *obj, void *closure)
    3253             : {
    3254           0 :         struct echo_TestCall *object = pytalloc_get_ptr(obj);
    3255             :         PyObject *py_s2;
    3256           0 :         if (object->out.s2 == NULL) {
    3257           0 :                 Py_RETURN_NONE;
    3258             :         }
    3259           0 :         if (*object->out.s2 == NULL) {
    3260           0 :                 py_s2 = Py_None;
    3261           0 :                 Py_INCREF(py_s2);
    3262             :         } else {
    3263           0 :                 if (*object->out.s2 == NULL) {
    3264           0 :                         py_s2 = Py_None;
    3265           0 :                         Py_INCREF(py_s2);
    3266             :                 } else {
    3267           0 :                         py_s2 = PyUnicode_Decode(*object->out.s2, strlen(*object->out.s2), "utf-8", "ignore");
    3268             :                 }
    3269             :         }
    3270           0 :         return py_s2;
    3271             : }
    3272             : 
    3273           0 : static int py_echo_TestCall_out_set_s2(PyObject *py_obj, PyObject *value, void *closure)
    3274             : {
    3275           0 :         struct echo_TestCall *object = pytalloc_get_ptr(py_obj);
    3276           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.s2));
    3277           0 :         if (value == NULL) {
    3278           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.s2");
    3279           0 :                 return -1;
    3280             :         }
    3281           0 :         object->out.s2 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.s2);
    3282           0 :         if (object->out.s2 == NULL) {
    3283           0 :                 PyErr_NoMemory();
    3284           0 :                 return -1;
    3285             :         }
    3286           0 :         if (value == Py_None) {
    3287           0 :                 *object->out.s2 = NULL;
    3288             :         } else {
    3289           0 :                 *object->out.s2 = NULL;
    3290             :                 {
    3291             :                         const char *test_str;
    3292             :                         const char *talloc_str;
    3293           0 :                         PyObject *unicode = NULL;
    3294           0 :                         if (PyUnicode_Check(value)) {
    3295           0 :                                 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
    3296           0 :                                 if (unicode == NULL) {
    3297           0 :                                         return -1;
    3298             :                                 }
    3299           0 :                                 test_str = PyBytes_AS_STRING(unicode);
    3300           0 :                         } else if (PyBytes_Check(value)) {
    3301           0 :                                 test_str = PyBytes_AS_STRING(value);
    3302             :                         } else {
    3303           0 :                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
    3304           0 :                                 return -1;
    3305             :                         }
    3306           0 :                         talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
    3307           0 :                         if (unicode != NULL) {
    3308           0 :                                 Py_DECREF(unicode);
    3309             :                         }
    3310           0 :                         if (talloc_str == NULL) {
    3311           0 :                                 PyErr_NoMemory();
    3312           0 :                                 return -1;
    3313             :                         }
    3314           0 :                         *object->out.s2 = talloc_str;
    3315             :                 }
    3316             :         }
    3317           0 :         return 0;
    3318             : }
    3319             : 
    3320             : static PyGetSetDef py_echo_TestCall_getsetters[] = {
    3321             :         {
    3322             :                 .name = discard_const_p(char, "in_s1"),
    3323             :                 .get = py_echo_TestCall_in_get_s1,
    3324             :                 .set = py_echo_TestCall_in_set_s1,
    3325             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    3326             :         },
    3327             :         {
    3328             :                 .name = discard_const_p(char, "out_s2"),
    3329             :                 .get = py_echo_TestCall_out_get_s2,
    3330             :                 .set = py_echo_TestCall_out_set_s2,
    3331             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    3332             :         },
    3333             :         { .name = NULL }
    3334             : };
    3335             : 
    3336           0 : static PyObject *py_echo_TestCall_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    3337             : {
    3338           0 :         PyObject *self = pytalloc_new(struct echo_TestCall, type);
    3339           0 :         return self;
    3340             : }
    3341             : 
    3342           0 : static PyObject *py_echo_TestCall_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    3343             : {
    3344             : 
    3345             : 
    3346           0 :         return PyLong_FromLong(4);
    3347             : }
    3348             : 
    3349           0 : static PyObject *py_echo_TestCall_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    3350             : {
    3351           0 :         const struct ndr_interface_call *call = NULL;
    3352           0 :         struct echo_TestCall *object = pytalloc_get_ptr(py_obj);
    3353           0 :         PyObject *ret = NULL;
    3354           0 :         struct ndr_push *push = NULL;
    3355             :         DATA_BLOB blob;
    3356             :         enum ndr_err_code err;
    3357             : 
    3358           0 :         if (ndr_table_rpcecho.num_calls < 5) {
    3359           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall_ndr_pack");
    3360           0 :                 return NULL;
    3361             :         }
    3362           0 :         call = &ndr_table_rpcecho.calls[4];
    3363             : 
    3364           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    3365           0 :         if (push == NULL) {
    3366           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3367           0 :                 return NULL;
    3368             :         }
    3369             : 
    3370           0 :         push->flags |= ndr_push_flags;
    3371             : 
    3372           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    3373           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3374           0 :                 TALLOC_FREE(push);
    3375           0 :                 PyErr_SetNdrError(err);
    3376           0 :                 return NULL;
    3377             :         }
    3378           0 :         blob = ndr_push_blob(push);
    3379           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    3380           0 :         TALLOC_FREE(push);
    3381           0 :         return ret;
    3382             : }
    3383             : 
    3384           0 : static PyObject *py_echo_TestCall_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3385             : {
    3386           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3387           0 :         PyObject *bigendian_obj = NULL;
    3388           0 :         PyObject *ndr64_obj = NULL;
    3389           0 :         libndr_flags ndr_push_flags = 0;
    3390             : 
    3391           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    3392             :                 discard_const_p(char *, kwnames),
    3393             :                 &bigendian_obj,
    3394             :                 &ndr64_obj)) {
    3395           0 :                 return NULL;
    3396             :         }
    3397             : 
    3398           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3399           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3400             :         }
    3401           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3402           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3403             :         }
    3404             : 
    3405           0 :         return py_echo_TestCall_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    3406             : }
    3407             : 
    3408           0 : static PyObject *py_echo_TestCall_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3409             : {
    3410           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3411           0 :         PyObject *bigendian_obj = NULL;
    3412           0 :         PyObject *ndr64_obj = NULL;
    3413           0 :         libndr_flags ndr_push_flags = 0;
    3414             : 
    3415           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    3416             :                 discard_const_p(char *, kwnames),
    3417             :                 &bigendian_obj,
    3418             :                 &ndr64_obj)) {
    3419           0 :                 return NULL;
    3420             :         }
    3421             : 
    3422           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3423           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3424             :         }
    3425           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3426           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3427             :         }
    3428             : 
    3429           0 :         return py_echo_TestCall_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    3430             : }
    3431             : 
    3432           0 : static PyObject *py_echo_TestCall_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    3433             : {
    3434           0 :         const struct ndr_interface_call *call = NULL;
    3435           0 :         struct echo_TestCall *object = pytalloc_get_ptr(py_obj);
    3436           0 :         struct ndr_pull *pull = NULL;
    3437             :         enum ndr_err_code err;
    3438             : 
    3439           0 :         if (ndr_table_rpcecho.num_calls < 5) {
    3440           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall_ndr_unpack");
    3441           0 :                 return NULL;
    3442             :         }
    3443           0 :         call = &ndr_table_rpcecho.calls[4];
    3444             : 
    3445           0 :         pull = ndr_pull_init_blob(blob, object);
    3446           0 :         if (pull == NULL) {
    3447           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3448           0 :                 return NULL;
    3449             :         }
    3450             : 
    3451           0 :         pull->flags |= ndr_pull_flags;
    3452             : 
    3453           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    3454           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3455           0 :                 TALLOC_FREE(pull);
    3456           0 :                 PyErr_SetNdrError(err);
    3457           0 :                 return NULL;
    3458             :         }
    3459           0 :         if (!allow_remaining) {
    3460             :                 uint32_t highest_ofs;
    3461             : 
    3462           0 :                 if (pull->offset > pull->relative_highest_offset) {
    3463           0 :                         highest_ofs = pull->offset;
    3464             :                 } else {
    3465           0 :                         highest_ofs = pull->relative_highest_offset;
    3466             :                 }
    3467           0 :                 if (highest_ofs < pull->data_size) {
    3468           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    3469             :                                 "not all bytes consumed ofs[%u] size[%u]",
    3470             :                                 highest_ofs, pull->data_size);
    3471           0 :                         TALLOC_FREE(pull);
    3472           0 :                         PyErr_SetNdrError(err);
    3473           0 :                         return NULL;
    3474             :                 }
    3475             :         }
    3476             : 
    3477           0 :         TALLOC_FREE(pull);
    3478           0 :         Py_RETURN_NONE;
    3479             : }
    3480             : 
    3481           0 : static PyObject *py_echo_TestCall_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3482             : {
    3483             :         DATA_BLOB blob;
    3484           0 :         Py_ssize_t blob_length = 0;
    3485           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3486           0 :         PyObject *bigendian_obj = NULL;
    3487           0 :         PyObject *ndr64_obj = NULL;
    3488           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3489           0 :         PyObject *allow_remaining_obj = NULL;
    3490           0 :         bool allow_remaining = false;
    3491             : 
    3492           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    3493             :                 discard_const_p(char *, kwnames),
    3494             :                 &blob.data, &blob_length,
    3495             :                 &bigendian_obj,
    3496             :                 &ndr64_obj,
    3497             :                 &allow_remaining_obj)) {
    3498           0 :                 return NULL;
    3499             :         }
    3500           0 :         blob.length = blob_length;
    3501             : 
    3502           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3503           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3504             :         }
    3505           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3506           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3507             :         }
    3508             : 
    3509           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3510           0 :                 allow_remaining = true;
    3511             :         }
    3512             : 
    3513           0 :         return py_echo_TestCall_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    3514             : }
    3515             : 
    3516           0 : static PyObject *py_echo_TestCall_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3517             : {
    3518             :         DATA_BLOB blob;
    3519           0 :         Py_ssize_t blob_length = 0;
    3520           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3521           0 :         PyObject *bigendian_obj = NULL;
    3522           0 :         PyObject *ndr64_obj = NULL;
    3523           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3524           0 :         PyObject *allow_remaining_obj = NULL;
    3525           0 :         bool allow_remaining = false;
    3526             : 
    3527           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    3528             :                 discard_const_p(char *, kwnames),
    3529             :                 &blob.data, &blob_length,
    3530             :                 &bigendian_obj,
    3531             :                 &ndr64_obj,
    3532             :                 &allow_remaining_obj)) {
    3533           0 :                 return NULL;
    3534             :         }
    3535           0 :         blob.length = blob_length;
    3536             : 
    3537           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3538           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3539             :         }
    3540           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3541           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3542             :         }
    3543             : 
    3544           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3545           0 :                 allow_remaining = true;
    3546             :         }
    3547             : 
    3548           0 :         return py_echo_TestCall_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    3549             : }
    3550             : 
    3551           0 : static PyObject *py_echo_TestCall_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    3552             : {
    3553           0 :         const struct ndr_interface_call *call = NULL;
    3554           0 :         struct echo_TestCall *object = pytalloc_get_ptr(py_obj);
    3555             :         PyObject *ret;
    3556             :         char *retstr;
    3557             : 
    3558           0 :         if (ndr_table_rpcecho.num_calls < 5) {
    3559           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall_ndr_print");
    3560           0 :                 return NULL;
    3561             :         }
    3562           0 :         call = &ndr_table_rpcecho.calls[4];
    3563             : 
    3564           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    3565           0 :         ret = PyUnicode_FromString(retstr);
    3566           0 :         TALLOC_FREE(retstr);
    3567             : 
    3568           0 :         return ret;
    3569             : }
    3570             : 
    3571           0 : static PyObject *py_echo_TestCall_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3572             : {
    3573           0 :         return py_echo_TestCall_ndr_print(py_obj, "echo_TestCall_in", NDR_IN);
    3574             : }
    3575             : 
    3576           0 : static PyObject *py_echo_TestCall_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3577             : {
    3578           0 :         return py_echo_TestCall_ndr_print(py_obj, "echo_TestCall_out", NDR_OUT);
    3579             : }
    3580             : 
    3581             : static PyMethodDef py_echo_TestCall_methods[] = {
    3582             :         { "opnum", (PyCFunction)py_echo_TestCall_ndr_opnum, METH_NOARGS|METH_CLASS,
    3583             :                 "echo.TestCall.opnum() -> 4 (0x04) " },
    3584             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    3585             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    3586             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    3587             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    3588             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    3589             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    3590             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    3591             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    3592             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestCall_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    3593             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestCall_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    3594             :         { NULL, NULL, 0, NULL }
    3595             : };
    3596             : 
    3597             : 
    3598             : static PyTypeObject echo_TestCall_Type = {
    3599             :         PyVarObject_HEAD_INIT(NULL, 0)
    3600             :         .tp_name = "echo.TestCall",
    3601             :         .tp_getset = py_echo_TestCall_getsetters,
    3602             :         .tp_methods = py_echo_TestCall_methods,
    3603             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    3604             :         .tp_new = py_echo_TestCall_new,
    3605             : };
    3606             : 
    3607           1 : static bool pack_py_echo_TestCall_args_in(PyObject *args, PyObject *kwargs, struct echo_TestCall *r)
    3608             : {
    3609             :         PyObject *py_s1;
    3610           1 :         const char *kwnames[] = {
    3611             :                 "s1", NULL
    3612             :         };
    3613             : 
    3614           1 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_TestCall", discard_const_p(char *, kwnames), &py_s1)) {
    3615           0 :                 return false;
    3616             :         }
    3617             : 
    3618           1 :         if (py_s1 == NULL) {
    3619           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.s1");
    3620           0 :                 return false;
    3621             :         }
    3622           1 :         r->in.s1 = talloc_ptrtype(r, r->in.s1);
    3623           1 :         if (r->in.s1 == NULL) {
    3624           0 :                 PyErr_NoMemory();
    3625           0 :                 return false;
    3626             :         }
    3627             :         {
    3628             :                 const char *test_str;
    3629             :                 const char *talloc_str;
    3630           1 :                 PyObject *unicode = NULL;
    3631           1 :                 if (PyUnicode_Check(py_s1)) {
    3632           1 :                         unicode = PyUnicode_AsEncodedString(py_s1, "utf-8", "ignore");
    3633           1 :                         if (unicode == NULL) {
    3634           0 :                                 return false;
    3635             :                         }
    3636           1 :                         test_str = PyBytes_AS_STRING(unicode);
    3637           0 :                 } else if (PyBytes_Check(py_s1)) {
    3638           0 :                         test_str = PyBytes_AS_STRING(py_s1);
    3639             :                 } else {
    3640           0 :                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_s1)->tp_name);
    3641           0 :                         return false;
    3642             :                 }
    3643           1 :                 talloc_str = talloc_strdup(r, test_str);
    3644           1 :                 if (unicode != NULL) {
    3645           1 :                         Py_DECREF(unicode);
    3646             :                 }
    3647           1 :                 if (talloc_str == NULL) {
    3648           0 :                         PyErr_NoMemory();
    3649           0 :                         return false;
    3650             :                 }
    3651           1 :                 r->in.s1 = talloc_str;
    3652             :         }
    3653           1 :         return true;
    3654             : }
    3655             : 
    3656           1 : static PyObject *unpack_py_echo_TestCall_args_out(struct echo_TestCall *r)
    3657             : {
    3658             :         PyObject *result;
    3659             :         PyObject *py_s2;
    3660           1 :         if (*r->out.s2 == NULL) {
    3661           0 :                 py_s2 = Py_None;
    3662           0 :                 Py_INCREF(py_s2);
    3663             :         } else {
    3664           1 :                 if (*r->out.s2 == NULL) {
    3665           0 :                         py_s2 = Py_None;
    3666           0 :                         Py_INCREF(py_s2);
    3667             :                 } else {
    3668           1 :                         py_s2 = PyUnicode_Decode(*r->out.s2, strlen(*r->out.s2), "utf-8", "ignore");
    3669             :                 }
    3670             :         }
    3671           1 :         result = py_s2;
    3672           1 :         return result;
    3673             : }
    3674             : 
    3675             : 
    3676           0 : static PyObject *py_echo_TestCall2_in_get_level(PyObject *obj, void *closure)
    3677             : {
    3678           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(obj);
    3679             :         PyObject *py_level;
    3680           0 :         py_level = PyLong_FromLong((uint16_t)(object->in.level));
    3681           0 :         return py_level;
    3682             : }
    3683             : 
    3684           0 : static int py_echo_TestCall2_in_set_level(PyObject *py_obj, PyObject *value, void *closure)
    3685             : {
    3686           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    3687           0 :         if (value == NULL) {
    3688           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.level");
    3689           0 :                 return -1;
    3690             :         }
    3691             :         {
    3692           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.level));
    3693           0 :                 if (PyLong_Check(value)) {
    3694             :                         unsigned long long test_var;
    3695           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    3696           0 :                         if (PyErr_Occurred() != NULL) {
    3697           0 :                                 return -1;
    3698             :                         }
    3699           0 :                         if (test_var > uint_max) {
    3700           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    3701             :                                   PyLong_Type.tp_name, uint_max, test_var);
    3702           0 :                                 return -1;
    3703             :                         }
    3704           0 :                         object->in.level = test_var;
    3705             :                 } else {
    3706           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    3707             :                           PyLong_Type.tp_name);
    3708           0 :                         return -1;
    3709             :                 }
    3710             :         }
    3711           0 :         return 0;
    3712             : }
    3713             : 
    3714           0 : static PyObject *py_echo_TestCall2_out_get_info(PyObject *obj, void *closure)
    3715             : {
    3716           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(obj);
    3717             :         PyObject *py_info;
    3718           0 :         if (object->out.info == NULL) {
    3719           0 :                 Py_RETURN_NONE;
    3720             :         }
    3721           0 :         py_info = pyrpc_import_union(&echo_Info_Type, object->out.info, object->in.level, object->out.info, "union echo_Info");
    3722           0 :         if (py_info == NULL) {
    3723           0 :                 return NULL;
    3724             :         }
    3725           0 :         return py_info;
    3726             : }
    3727             : 
    3728           0 : static int py_echo_TestCall2_out_set_info(PyObject *py_obj, PyObject *value, void *closure)
    3729             : {
    3730           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    3731           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.info));
    3732           0 :         if (value == NULL) {
    3733           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.info");
    3734           0 :                 return -1;
    3735             :         }
    3736           0 :         object->out.info = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.info);
    3737           0 :         if (object->out.info == NULL) {
    3738           0 :                 PyErr_NoMemory();
    3739           0 :                 return -1;
    3740             :         }
    3741             :         {
    3742             :                 union echo_Info *info_switch_1;
    3743           0 :                 info_switch_1 = (union echo_Info *)pyrpc_export_union(&echo_Info_Type, pytalloc_get_mem_ctx(py_obj), object->in.level, value, "union echo_Info");
    3744           0 :                 if (info_switch_1 == NULL) {
    3745           0 :                         return -1;
    3746             :                 }
    3747           0 :                 object->out.info = info_switch_1;
    3748             :         }
    3749           0 :         return 0;
    3750             : }
    3751             : 
    3752           0 : static PyObject *py_echo_TestCall2_get_result(PyObject *obj, void *closure)
    3753             : {
    3754           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(obj);
    3755             :         PyObject *py_result;
    3756           0 :         py_result = PyErr_FromNTSTATUS(object->out.result);
    3757           0 :         return py_result;
    3758             : }
    3759             : 
    3760           0 : static int py_echo_TestCall2_set_result(PyObject *py_obj, PyObject *value, void *closure)
    3761             : {
    3762           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    3763           0 :         if (value == NULL) {
    3764           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.result");
    3765           0 :                 return -1;
    3766             :         }
    3767           0 :         object->out.result = NT_STATUS(PyLong_AsLong(value));
    3768           0 :         return 0;
    3769             : }
    3770             : 
    3771             : static PyGetSetDef py_echo_TestCall2_getsetters[] = {
    3772             :         {
    3773             :                 .name = discard_const_p(char, "in_level"),
    3774             :                 .get = py_echo_TestCall2_in_get_level,
    3775             :                 .set = py_echo_TestCall2_in_set_level,
    3776             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    3777             :         },
    3778             :         {
    3779             :                 .name = discard_const_p(char, "out_info"),
    3780             :                 .get = py_echo_TestCall2_out_get_info,
    3781             :                 .set = py_echo_TestCall2_out_set_info,
    3782             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Info")
    3783             :         },
    3784             :         {
    3785             :                 .name = discard_const_p(char, "result"),
    3786             :                 .get = py_echo_TestCall2_get_result,
    3787             :                 .set = py_echo_TestCall2_set_result,
    3788             :                 .doc = discard_const_p(char, "PIDL-generated element of type NTSTATUS")
    3789             :         },
    3790             :         { .name = NULL }
    3791             : };
    3792             : 
    3793           0 : static PyObject *py_echo_TestCall2_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    3794             : {
    3795           0 :         PyObject *self = pytalloc_new(struct echo_TestCall2, type);
    3796           0 :         struct echo_TestCall2 *_self = (struct echo_TestCall2 *)pytalloc_get_ptr(self);
    3797           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    3798           0 :         _self->out.info = talloc_zero(mem_ctx, union echo_Info);
    3799           0 :         return self;
    3800             : }
    3801             : 
    3802           0 : static PyObject *py_echo_TestCall2_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    3803             : {
    3804             : 
    3805             : 
    3806           0 :         return PyLong_FromLong(5);
    3807             : }
    3808             : 
    3809           0 : static PyObject *py_echo_TestCall2_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    3810             : {
    3811           0 :         const struct ndr_interface_call *call = NULL;
    3812           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    3813           0 :         PyObject *ret = NULL;
    3814           0 :         struct ndr_push *push = NULL;
    3815             :         DATA_BLOB blob;
    3816             :         enum ndr_err_code err;
    3817             : 
    3818           0 :         if (ndr_table_rpcecho.num_calls < 6) {
    3819           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall2_ndr_pack");
    3820           0 :                 return NULL;
    3821             :         }
    3822           0 :         call = &ndr_table_rpcecho.calls[5];
    3823             : 
    3824           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    3825           0 :         if (push == NULL) {
    3826           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3827           0 :                 return NULL;
    3828             :         }
    3829             : 
    3830           0 :         push->flags |= ndr_push_flags;
    3831             : 
    3832           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    3833           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3834           0 :                 TALLOC_FREE(push);
    3835           0 :                 PyErr_SetNdrError(err);
    3836           0 :                 return NULL;
    3837             :         }
    3838           0 :         blob = ndr_push_blob(push);
    3839           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    3840           0 :         TALLOC_FREE(push);
    3841           0 :         return ret;
    3842             : }
    3843             : 
    3844           0 : static PyObject *py_echo_TestCall2_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3845             : {
    3846           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3847           0 :         PyObject *bigendian_obj = NULL;
    3848           0 :         PyObject *ndr64_obj = NULL;
    3849           0 :         libndr_flags ndr_push_flags = 0;
    3850             : 
    3851           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    3852             :                 discard_const_p(char *, kwnames),
    3853             :                 &bigendian_obj,
    3854             :                 &ndr64_obj)) {
    3855           0 :                 return NULL;
    3856             :         }
    3857             : 
    3858           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3859           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3860             :         }
    3861           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3862           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3863             :         }
    3864             : 
    3865           0 :         return py_echo_TestCall2_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    3866             : }
    3867             : 
    3868           0 : static PyObject *py_echo_TestCall2_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3869             : {
    3870           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3871           0 :         PyObject *bigendian_obj = NULL;
    3872           0 :         PyObject *ndr64_obj = NULL;
    3873           0 :         libndr_flags ndr_push_flags = 0;
    3874             : 
    3875           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    3876             :                 discard_const_p(char *, kwnames),
    3877             :                 &bigendian_obj,
    3878             :                 &ndr64_obj)) {
    3879           0 :                 return NULL;
    3880             :         }
    3881             : 
    3882           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3883           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3884             :         }
    3885           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3886           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3887             :         }
    3888             : 
    3889           0 :         return py_echo_TestCall2_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    3890             : }
    3891             : 
    3892           0 : static PyObject *py_echo_TestCall2_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    3893             : {
    3894           0 :         const struct ndr_interface_call *call = NULL;
    3895           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    3896           0 :         struct ndr_pull *pull = NULL;
    3897             :         enum ndr_err_code err;
    3898             : 
    3899           0 :         if (ndr_table_rpcecho.num_calls < 6) {
    3900           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall2_ndr_unpack");
    3901           0 :                 return NULL;
    3902             :         }
    3903           0 :         call = &ndr_table_rpcecho.calls[5];
    3904             : 
    3905           0 :         pull = ndr_pull_init_blob(blob, object);
    3906           0 :         if (pull == NULL) {
    3907           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3908           0 :                 return NULL;
    3909             :         }
    3910             : 
    3911           0 :         pull->flags |= ndr_pull_flags;
    3912             : 
    3913           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    3914           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3915           0 :                 TALLOC_FREE(pull);
    3916           0 :                 PyErr_SetNdrError(err);
    3917           0 :                 return NULL;
    3918             :         }
    3919           0 :         if (!allow_remaining) {
    3920             :                 uint32_t highest_ofs;
    3921             : 
    3922           0 :                 if (pull->offset > pull->relative_highest_offset) {
    3923           0 :                         highest_ofs = pull->offset;
    3924             :                 } else {
    3925           0 :                         highest_ofs = pull->relative_highest_offset;
    3926             :                 }
    3927           0 :                 if (highest_ofs < pull->data_size) {
    3928           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    3929             :                                 "not all bytes consumed ofs[%u] size[%u]",
    3930             :                                 highest_ofs, pull->data_size);
    3931           0 :                         TALLOC_FREE(pull);
    3932           0 :                         PyErr_SetNdrError(err);
    3933           0 :                         return NULL;
    3934             :                 }
    3935             :         }
    3936             : 
    3937           0 :         TALLOC_FREE(pull);
    3938           0 :         Py_RETURN_NONE;
    3939             : }
    3940             : 
    3941           0 : static PyObject *py_echo_TestCall2_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3942             : {
    3943             :         DATA_BLOB blob;
    3944           0 :         Py_ssize_t blob_length = 0;
    3945           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3946           0 :         PyObject *bigendian_obj = NULL;
    3947           0 :         PyObject *ndr64_obj = NULL;
    3948           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3949           0 :         PyObject *allow_remaining_obj = NULL;
    3950           0 :         bool allow_remaining = false;
    3951             : 
    3952           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    3953             :                 discard_const_p(char *, kwnames),
    3954             :                 &blob.data, &blob_length,
    3955             :                 &bigendian_obj,
    3956             :                 &ndr64_obj,
    3957             :                 &allow_remaining_obj)) {
    3958           0 :                 return NULL;
    3959             :         }
    3960           0 :         blob.length = blob_length;
    3961             : 
    3962           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3963           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3964             :         }
    3965           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3966           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3967             :         }
    3968             : 
    3969           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3970           0 :                 allow_remaining = true;
    3971             :         }
    3972             : 
    3973           0 :         return py_echo_TestCall2_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    3974             : }
    3975             : 
    3976           0 : static PyObject *py_echo_TestCall2_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3977             : {
    3978             :         DATA_BLOB blob;
    3979           0 :         Py_ssize_t blob_length = 0;
    3980           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3981           0 :         PyObject *bigendian_obj = NULL;
    3982           0 :         PyObject *ndr64_obj = NULL;
    3983           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3984           0 :         PyObject *allow_remaining_obj = NULL;
    3985           0 :         bool allow_remaining = false;
    3986             : 
    3987           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    3988             :                 discard_const_p(char *, kwnames),
    3989             :                 &blob.data, &blob_length,
    3990             :                 &bigendian_obj,
    3991             :                 &ndr64_obj,
    3992             :                 &allow_remaining_obj)) {
    3993           0 :                 return NULL;
    3994             :         }
    3995           0 :         blob.length = blob_length;
    3996             : 
    3997           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3998           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3999             :         }
    4000           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4001           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4002             :         }
    4003             : 
    4004           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4005           0 :                 allow_remaining = true;
    4006             :         }
    4007             : 
    4008           0 :         return py_echo_TestCall2_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    4009             : }
    4010             : 
    4011           0 : static PyObject *py_echo_TestCall2_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    4012             : {
    4013           0 :         const struct ndr_interface_call *call = NULL;
    4014           0 :         struct echo_TestCall2 *object = pytalloc_get_ptr(py_obj);
    4015             :         PyObject *ret;
    4016             :         char *retstr;
    4017             : 
    4018           0 :         if (ndr_table_rpcecho.num_calls < 6) {
    4019           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestCall2_ndr_print");
    4020           0 :                 return NULL;
    4021             :         }
    4022           0 :         call = &ndr_table_rpcecho.calls[5];
    4023             : 
    4024           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    4025           0 :         ret = PyUnicode_FromString(retstr);
    4026           0 :         TALLOC_FREE(retstr);
    4027             : 
    4028           0 :         return ret;
    4029             : }
    4030             : 
    4031           0 : static PyObject *py_echo_TestCall2_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4032             : {
    4033           0 :         return py_echo_TestCall2_ndr_print(py_obj, "echo_TestCall2_in", NDR_IN);
    4034             : }
    4035             : 
    4036           0 : static PyObject *py_echo_TestCall2_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4037             : {
    4038           0 :         return py_echo_TestCall2_ndr_print(py_obj, "echo_TestCall2_out", NDR_OUT);
    4039             : }
    4040             : 
    4041             : static PyMethodDef py_echo_TestCall2_methods[] = {
    4042             :         { "opnum", (PyCFunction)py_echo_TestCall2_ndr_opnum, METH_NOARGS|METH_CLASS,
    4043             :                 "echo.TestCall2.opnum() -> 5 (0x05) " },
    4044             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall2_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    4045             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    4046             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall2_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    4047             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    4048             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall2_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    4049             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    4050             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestCall2_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    4051             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    4052             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestCall2_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    4053             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestCall2_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    4054             :         { NULL, NULL, 0, NULL }
    4055             : };
    4056             : 
    4057             : 
    4058             : static PyTypeObject echo_TestCall2_Type = {
    4059             :         PyVarObject_HEAD_INIT(NULL, 0)
    4060             :         .tp_name = "echo.TestCall2",
    4061             :         .tp_getset = py_echo_TestCall2_getsetters,
    4062             :         .tp_methods = py_echo_TestCall2_methods,
    4063             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    4064             :         .tp_new = py_echo_TestCall2_new,
    4065             : };
    4066             : 
    4067           0 : static bool pack_py_echo_TestCall2_args_in(PyObject *args, PyObject *kwargs, struct echo_TestCall2 *r)
    4068             : {
    4069             :         PyObject *py_level;
    4070           0 :         const char *kwnames[] = {
    4071             :                 "level", NULL
    4072             :         };
    4073             : 
    4074           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_TestCall2", discard_const_p(char *, kwnames), &py_level)) {
    4075           0 :                 return false;
    4076             :         }
    4077             : 
    4078           0 :         if (py_level == NULL) {
    4079           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.level");
    4080           0 :                 return false;
    4081             :         }
    4082             :         {
    4083           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.level));
    4084           0 :                 if (PyLong_Check(py_level)) {
    4085             :                         unsigned long long test_var;
    4086           0 :                         test_var = PyLong_AsUnsignedLongLong(py_level);
    4087           0 :                         if (PyErr_Occurred() != NULL) {
    4088           0 :                                 return false;
    4089             :                         }
    4090           0 :                         if (test_var > uint_max) {
    4091           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4092             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4093           0 :                                 return false;
    4094             :                         }
    4095           0 :                         r->in.level = test_var;
    4096             :                 } else {
    4097           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4098             :                           PyLong_Type.tp_name);
    4099           0 :                         return false;
    4100             :                 }
    4101             :         }
    4102           0 :         return true;
    4103             : }
    4104             : 
    4105           0 : static PyObject *unpack_py_echo_TestCall2_args_out(struct echo_TestCall2 *r)
    4106             : {
    4107             :         PyObject *result;
    4108             :         PyObject *py_info;
    4109           0 :         py_info = pyrpc_import_union(&echo_Info_Type, r->out.info, r->in.level, r->out.info, "union echo_Info");
    4110           0 :         if (py_info == NULL) {
    4111           0 :                 return NULL;
    4112             :         }
    4113           0 :         result = py_info;
    4114           0 :         if (NT_STATUS_IS_ERR(r->out.result)) {
    4115           0 :                 PyErr_SetNTSTATUS(r->out.result);
    4116           0 :                 return NULL;
    4117             :         }
    4118             : 
    4119           0 :         return result;
    4120             : }
    4121             : 
    4122             : 
    4123           0 : static PyObject *py_echo_TestSleep_in_get_seconds(PyObject *obj, void *closure)
    4124             : {
    4125           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(obj);
    4126             :         PyObject *py_seconds;
    4127           0 :         py_seconds = PyLong_FromUnsignedLongLong((uint32_t)(object->in.seconds));
    4128           0 :         return py_seconds;
    4129             : }
    4130             : 
    4131           0 : static int py_echo_TestSleep_in_set_seconds(PyObject *py_obj, PyObject *value, void *closure)
    4132             : {
    4133           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(py_obj);
    4134           0 :         if (value == NULL) {
    4135           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.seconds");
    4136           0 :                 return -1;
    4137             :         }
    4138             :         {
    4139           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.seconds));
    4140           0 :                 if (PyLong_Check(value)) {
    4141             :                         unsigned long long test_var;
    4142           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4143           0 :                         if (PyErr_Occurred() != NULL) {
    4144           0 :                                 return -1;
    4145             :                         }
    4146           0 :                         if (test_var > uint_max) {
    4147           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4148             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4149           0 :                                 return -1;
    4150             :                         }
    4151           0 :                         object->in.seconds = test_var;
    4152             :                 } else {
    4153           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4154             :                           PyLong_Type.tp_name);
    4155           0 :                         return -1;
    4156             :                 }
    4157             :         }
    4158           0 :         return 0;
    4159             : }
    4160             : 
    4161           0 : static PyObject *py_echo_TestSleep_get_result(PyObject *obj, void *closure)
    4162             : {
    4163           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(obj);
    4164             :         PyObject *py_result;
    4165           0 :         py_result = PyLong_FromUnsignedLongLong((uint32_t)(object->out.result));
    4166           0 :         return py_result;
    4167             : }
    4168             : 
    4169           0 : static int py_echo_TestSleep_set_result(PyObject *py_obj, PyObject *value, void *closure)
    4170             : {
    4171           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(py_obj);
    4172           0 :         if (value == NULL) {
    4173           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.result");
    4174           0 :                 return -1;
    4175             :         }
    4176             :         {
    4177           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->out.result));
    4178           0 :                 if (PyLong_Check(value)) {
    4179             :                         unsigned long long test_var;
    4180           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4181           0 :                         if (PyErr_Occurred() != NULL) {
    4182           0 :                                 return -1;
    4183             :                         }
    4184           0 :                         if (test_var > uint_max) {
    4185           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4186             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4187           0 :                                 return -1;
    4188             :                         }
    4189           0 :                         object->out.result = test_var;
    4190             :                 } else {
    4191           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4192             :                           PyLong_Type.tp_name);
    4193           0 :                         return -1;
    4194             :                 }
    4195             :         }
    4196           0 :         return 0;
    4197             : }
    4198             : 
    4199             : static PyGetSetDef py_echo_TestSleep_getsetters[] = {
    4200             :         {
    4201             :                 .name = discard_const_p(char, "in_seconds"),
    4202             :                 .get = py_echo_TestSleep_in_get_seconds,
    4203             :                 .set = py_echo_TestSleep_in_set_seconds,
    4204             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    4205             :         },
    4206             :         {
    4207             :                 .name = discard_const_p(char, "result"),
    4208             :                 .get = py_echo_TestSleep_get_result,
    4209             :                 .set = py_echo_TestSleep_set_result,
    4210             :                 .doc = discard_const_p(char, "PIDL-generated element of type uint32")
    4211             :         },
    4212             :         { .name = NULL }
    4213             : };
    4214             : 
    4215           0 : static PyObject *py_echo_TestSleep_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    4216             : {
    4217           0 :         PyObject *self = pytalloc_new(struct echo_TestSleep, type);
    4218           0 :         return self;
    4219             : }
    4220             : 
    4221           0 : static PyObject *py_echo_TestSleep_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    4222             : {
    4223             : 
    4224             : 
    4225           0 :         return PyLong_FromLong(6);
    4226             : }
    4227             : 
    4228           0 : static PyObject *py_echo_TestSleep_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    4229             : {
    4230           0 :         const struct ndr_interface_call *call = NULL;
    4231           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(py_obj);
    4232           0 :         PyObject *ret = NULL;
    4233           0 :         struct ndr_push *push = NULL;
    4234             :         DATA_BLOB blob;
    4235             :         enum ndr_err_code err;
    4236             : 
    4237           0 :         if (ndr_table_rpcecho.num_calls < 7) {
    4238           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSleep_ndr_pack");
    4239           0 :                 return NULL;
    4240             :         }
    4241           0 :         call = &ndr_table_rpcecho.calls[6];
    4242             : 
    4243           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    4244           0 :         if (push == NULL) {
    4245           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4246           0 :                 return NULL;
    4247             :         }
    4248             : 
    4249           0 :         push->flags |= ndr_push_flags;
    4250             : 
    4251           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    4252           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4253           0 :                 TALLOC_FREE(push);
    4254           0 :                 PyErr_SetNdrError(err);
    4255           0 :                 return NULL;
    4256             :         }
    4257           0 :         blob = ndr_push_blob(push);
    4258           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    4259           0 :         TALLOC_FREE(push);
    4260           0 :         return ret;
    4261             : }
    4262             : 
    4263           0 : static PyObject *py_echo_TestSleep_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4264             : {
    4265           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4266           0 :         PyObject *bigendian_obj = NULL;
    4267           0 :         PyObject *ndr64_obj = NULL;
    4268           0 :         libndr_flags ndr_push_flags = 0;
    4269             : 
    4270           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    4271             :                 discard_const_p(char *, kwnames),
    4272             :                 &bigendian_obj,
    4273             :                 &ndr64_obj)) {
    4274           0 :                 return NULL;
    4275             :         }
    4276             : 
    4277           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4278           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4279             :         }
    4280           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4281           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4282             :         }
    4283             : 
    4284           0 :         return py_echo_TestSleep_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    4285             : }
    4286             : 
    4287           0 : static PyObject *py_echo_TestSleep_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4288             : {
    4289           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4290           0 :         PyObject *bigendian_obj = NULL;
    4291           0 :         PyObject *ndr64_obj = NULL;
    4292           0 :         libndr_flags ndr_push_flags = 0;
    4293             : 
    4294           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    4295             :                 discard_const_p(char *, kwnames),
    4296             :                 &bigendian_obj,
    4297             :                 &ndr64_obj)) {
    4298           0 :                 return NULL;
    4299             :         }
    4300             : 
    4301           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4302           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4303             :         }
    4304           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4305           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4306             :         }
    4307             : 
    4308           0 :         return py_echo_TestSleep_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    4309             : }
    4310             : 
    4311           0 : static PyObject *py_echo_TestSleep_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    4312             : {
    4313           0 :         const struct ndr_interface_call *call = NULL;
    4314           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(py_obj);
    4315           0 :         struct ndr_pull *pull = NULL;
    4316             :         enum ndr_err_code err;
    4317             : 
    4318           0 :         if (ndr_table_rpcecho.num_calls < 7) {
    4319           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSleep_ndr_unpack");
    4320           0 :                 return NULL;
    4321             :         }
    4322           0 :         call = &ndr_table_rpcecho.calls[6];
    4323             : 
    4324           0 :         pull = ndr_pull_init_blob(blob, object);
    4325           0 :         if (pull == NULL) {
    4326           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4327           0 :                 return NULL;
    4328             :         }
    4329             : 
    4330           0 :         pull->flags |= ndr_pull_flags;
    4331             : 
    4332           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    4333           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4334           0 :                 TALLOC_FREE(pull);
    4335           0 :                 PyErr_SetNdrError(err);
    4336           0 :                 return NULL;
    4337             :         }
    4338           0 :         if (!allow_remaining) {
    4339             :                 uint32_t highest_ofs;
    4340             : 
    4341           0 :                 if (pull->offset > pull->relative_highest_offset) {
    4342           0 :                         highest_ofs = pull->offset;
    4343             :                 } else {
    4344           0 :                         highest_ofs = pull->relative_highest_offset;
    4345             :                 }
    4346           0 :                 if (highest_ofs < pull->data_size) {
    4347           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    4348             :                                 "not all bytes consumed ofs[%u] size[%u]",
    4349             :                                 highest_ofs, pull->data_size);
    4350           0 :                         TALLOC_FREE(pull);
    4351           0 :                         PyErr_SetNdrError(err);
    4352           0 :                         return NULL;
    4353             :                 }
    4354             :         }
    4355             : 
    4356           0 :         TALLOC_FREE(pull);
    4357           0 :         Py_RETURN_NONE;
    4358             : }
    4359             : 
    4360           0 : static PyObject *py_echo_TestSleep_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4361             : {
    4362             :         DATA_BLOB blob;
    4363           0 :         Py_ssize_t blob_length = 0;
    4364           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    4365           0 :         PyObject *bigendian_obj = NULL;
    4366           0 :         PyObject *ndr64_obj = NULL;
    4367           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    4368           0 :         PyObject *allow_remaining_obj = NULL;
    4369           0 :         bool allow_remaining = false;
    4370             : 
    4371           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    4372             :                 discard_const_p(char *, kwnames),
    4373             :                 &blob.data, &blob_length,
    4374             :                 &bigendian_obj,
    4375             :                 &ndr64_obj,
    4376             :                 &allow_remaining_obj)) {
    4377           0 :                 return NULL;
    4378             :         }
    4379           0 :         blob.length = blob_length;
    4380             : 
    4381           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4382           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    4383             :         }
    4384           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4385           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4386             :         }
    4387             : 
    4388           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4389           0 :                 allow_remaining = true;
    4390             :         }
    4391             : 
    4392           0 :         return py_echo_TestSleep_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    4393             : }
    4394             : 
    4395           0 : static PyObject *py_echo_TestSleep_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4396             : {
    4397             :         DATA_BLOB blob;
    4398           0 :         Py_ssize_t blob_length = 0;
    4399           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    4400           0 :         PyObject *bigendian_obj = NULL;
    4401           0 :         PyObject *ndr64_obj = NULL;
    4402           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    4403           0 :         PyObject *allow_remaining_obj = NULL;
    4404           0 :         bool allow_remaining = false;
    4405             : 
    4406           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    4407             :                 discard_const_p(char *, kwnames),
    4408             :                 &blob.data, &blob_length,
    4409             :                 &bigendian_obj,
    4410             :                 &ndr64_obj,
    4411             :                 &allow_remaining_obj)) {
    4412           0 :                 return NULL;
    4413             :         }
    4414           0 :         blob.length = blob_length;
    4415             : 
    4416           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4417           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    4418             :         }
    4419           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4420           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4421             :         }
    4422             : 
    4423           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4424           0 :                 allow_remaining = true;
    4425             :         }
    4426             : 
    4427           0 :         return py_echo_TestSleep_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    4428             : }
    4429             : 
    4430           0 : static PyObject *py_echo_TestSleep_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    4431             : {
    4432           0 :         const struct ndr_interface_call *call = NULL;
    4433           0 :         struct echo_TestSleep *object = pytalloc_get_ptr(py_obj);
    4434             :         PyObject *ret;
    4435             :         char *retstr;
    4436             : 
    4437           0 :         if (ndr_table_rpcecho.num_calls < 7) {
    4438           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSleep_ndr_print");
    4439           0 :                 return NULL;
    4440             :         }
    4441           0 :         call = &ndr_table_rpcecho.calls[6];
    4442             : 
    4443           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    4444           0 :         ret = PyUnicode_FromString(retstr);
    4445           0 :         TALLOC_FREE(retstr);
    4446             : 
    4447           0 :         return ret;
    4448             : }
    4449             : 
    4450           0 : static PyObject *py_echo_TestSleep_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4451             : {
    4452           0 :         return py_echo_TestSleep_ndr_print(py_obj, "echo_TestSleep_in", NDR_IN);
    4453             : }
    4454             : 
    4455           0 : static PyObject *py_echo_TestSleep_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4456             : {
    4457           0 :         return py_echo_TestSleep_ndr_print(py_obj, "echo_TestSleep_out", NDR_OUT);
    4458             : }
    4459             : 
    4460             : static PyMethodDef py_echo_TestSleep_methods[] = {
    4461             :         { "opnum", (PyCFunction)py_echo_TestSleep_ndr_opnum, METH_NOARGS|METH_CLASS,
    4462             :                 "echo.TestSleep.opnum() -> 6 (0x06) " },
    4463             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSleep_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    4464             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    4465             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSleep_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    4466             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    4467             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSleep_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    4468             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    4469             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSleep_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    4470             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    4471             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestSleep_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    4472             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestSleep_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    4473             :         { NULL, NULL, 0, NULL }
    4474             : };
    4475             : 
    4476             : 
    4477             : static PyTypeObject echo_TestSleep_Type = {
    4478             :         PyVarObject_HEAD_INIT(NULL, 0)
    4479             :         .tp_name = "echo.TestSleep",
    4480             :         .tp_getset = py_echo_TestSleep_getsetters,
    4481             :         .tp_methods = py_echo_TestSleep_methods,
    4482             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    4483             :         .tp_new = py_echo_TestSleep_new,
    4484             : };
    4485             : 
    4486           0 : static bool pack_py_echo_TestSleep_args_in(PyObject *args, PyObject *kwargs, struct echo_TestSleep *r)
    4487             : {
    4488             :         PyObject *py_seconds;
    4489           0 :         const char *kwnames[] = {
    4490             :                 "seconds", NULL
    4491             :         };
    4492             : 
    4493           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_TestSleep", discard_const_p(char *, kwnames), &py_seconds)) {
    4494           0 :                 return false;
    4495             :         }
    4496             : 
    4497           0 :         if (py_seconds == NULL) {
    4498           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.seconds");
    4499           0 :                 return false;
    4500             :         }
    4501             :         {
    4502           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.seconds));
    4503           0 :                 if (PyLong_Check(py_seconds)) {
    4504             :                         unsigned long long test_var;
    4505           0 :                         test_var = PyLong_AsUnsignedLongLong(py_seconds);
    4506           0 :                         if (PyErr_Occurred() != NULL) {
    4507           0 :                                 return false;
    4508             :                         }
    4509           0 :                         if (test_var > uint_max) {
    4510           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4511             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4512           0 :                                 return false;
    4513             :                         }
    4514           0 :                         r->in.seconds = test_var;
    4515             :                 } else {
    4516           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4517             :                           PyLong_Type.tp_name);
    4518           0 :                         return false;
    4519             :                 }
    4520             :         }
    4521           0 :         return true;
    4522             : }
    4523             : 
    4524           0 : static PyObject *unpack_py_echo_TestSleep_args_out(struct echo_TestSleep *r)
    4525             : {
    4526             :         PyObject *result;
    4527           0 :         result = PyLong_FromUnsignedLongLong((uint32_t)(r->out.result));
    4528           0 :         return result;
    4529             : }
    4530             : 
    4531             : 
    4532           0 : static PyObject *py_echo_TestEnum_in_get_foo1(PyObject *obj, void *closure)
    4533             : {
    4534           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4535             :         PyObject *py_foo1;
    4536           0 :         if (object->in.foo1 == NULL) {
    4537           0 :                 Py_RETURN_NONE;
    4538             :         }
    4539           0 :         py_foo1 = PyLong_FromLong((uint16_t)(*object->in.foo1));
    4540           0 :         return py_foo1;
    4541             : }
    4542             : 
    4543           0 : static int py_echo_TestEnum_in_set_foo1(PyObject *py_obj, PyObject *value, void *closure)
    4544             : {
    4545           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4546           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.foo1));
    4547           0 :         if (value == NULL) {
    4548           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.foo1");
    4549           0 :                 return -1;
    4550             :         }
    4551           0 :         object->in.foo1 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.foo1);
    4552           0 :         if (object->in.foo1 == NULL) {
    4553           0 :                 PyErr_NoMemory();
    4554           0 :                 return -1;
    4555             :         }
    4556             :         {
    4557           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.foo1));
    4558           0 :                 if (PyLong_Check(value)) {
    4559             :                         unsigned long long test_var;
    4560           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4561           0 :                         if (PyErr_Occurred() != NULL) {
    4562           0 :                                 return -1;
    4563             :                         }
    4564           0 :                         if (test_var > uint_max) {
    4565           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4566             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4567           0 :                                 return -1;
    4568             :                         }
    4569           0 :                         *object->in.foo1 = test_var;
    4570             :                 } else {
    4571           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4572             :                           PyLong_Type.tp_name);
    4573           0 :                         return -1;
    4574             :                 }
    4575             :         }
    4576           0 :         return 0;
    4577             : }
    4578             : 
    4579           0 : static PyObject *py_echo_TestEnum_out_get_foo1(PyObject *obj, void *closure)
    4580             : {
    4581           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4582             :         PyObject *py_foo1;
    4583           0 :         if (object->out.foo1 == NULL) {
    4584           0 :                 Py_RETURN_NONE;
    4585             :         }
    4586           0 :         py_foo1 = PyLong_FromLong((uint16_t)(*object->out.foo1));
    4587           0 :         return py_foo1;
    4588             : }
    4589             : 
    4590           0 : static int py_echo_TestEnum_out_set_foo1(PyObject *py_obj, PyObject *value, void *closure)
    4591             : {
    4592           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4593           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.foo1));
    4594           0 :         if (value == NULL) {
    4595           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.foo1");
    4596           0 :                 return -1;
    4597             :         }
    4598           0 :         object->out.foo1 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.foo1);
    4599           0 :         if (object->out.foo1 == NULL) {
    4600           0 :                 PyErr_NoMemory();
    4601           0 :                 return -1;
    4602             :         }
    4603             :         {
    4604           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.foo1));
    4605           0 :                 if (PyLong_Check(value)) {
    4606             :                         unsigned long long test_var;
    4607           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4608           0 :                         if (PyErr_Occurred() != NULL) {
    4609           0 :                                 return -1;
    4610             :                         }
    4611           0 :                         if (test_var > uint_max) {
    4612           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    4613             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4614           0 :                                 return -1;
    4615             :                         }
    4616           0 :                         *object->out.foo1 = test_var;
    4617             :                 } else {
    4618           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    4619             :                           PyLong_Type.tp_name);
    4620           0 :                         return -1;
    4621             :                 }
    4622             :         }
    4623           0 :         return 0;
    4624             : }
    4625             : 
    4626           0 : static PyObject *py_echo_TestEnum_in_get_foo2(PyObject *obj, void *closure)
    4627             : {
    4628           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4629             :         PyObject *py_foo2;
    4630           0 :         if (object->in.foo2 == NULL) {
    4631           0 :                 Py_RETURN_NONE;
    4632             :         }
    4633           0 :         py_foo2 = pytalloc_reference_ex(&echo_Enum2_Type, object->in.foo2, object->in.foo2);
    4634           0 :         return py_foo2;
    4635             : }
    4636             : 
    4637           0 : static int py_echo_TestEnum_in_set_foo2(PyObject *py_obj, PyObject *value, void *closure)
    4638             : {
    4639           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4640           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.foo2));
    4641           0 :         if (value == NULL) {
    4642           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.foo2");
    4643           0 :                 return -1;
    4644             :         }
    4645           0 :         object->in.foo2 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.foo2);
    4646           0 :         if (object->in.foo2 == NULL) {
    4647           0 :                 PyErr_NoMemory();
    4648           0 :                 return -1;
    4649             :         }
    4650           0 :         PY_CHECK_TYPE(&echo_Enum2_Type, value, return -1;);
    4651           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4652           0 :                 PyErr_NoMemory();
    4653           0 :                 return -1;
    4654             :         }
    4655           0 :         object->in.foo2 = (struct echo_Enum2 *)pytalloc_get_ptr(value);
    4656           0 :         return 0;
    4657             : }
    4658             : 
    4659           0 : static PyObject *py_echo_TestEnum_out_get_foo2(PyObject *obj, void *closure)
    4660             : {
    4661           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4662             :         PyObject *py_foo2;
    4663           0 :         if (object->out.foo2 == NULL) {
    4664           0 :                 Py_RETURN_NONE;
    4665             :         }
    4666           0 :         py_foo2 = pytalloc_reference_ex(&echo_Enum2_Type, object->out.foo2, object->out.foo2);
    4667           0 :         return py_foo2;
    4668             : }
    4669             : 
    4670           0 : static int py_echo_TestEnum_out_set_foo2(PyObject *py_obj, PyObject *value, void *closure)
    4671             : {
    4672           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4673           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.foo2));
    4674           0 :         if (value == NULL) {
    4675           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.foo2");
    4676           0 :                 return -1;
    4677             :         }
    4678           0 :         object->out.foo2 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.foo2);
    4679           0 :         if (object->out.foo2 == NULL) {
    4680           0 :                 PyErr_NoMemory();
    4681           0 :                 return -1;
    4682             :         }
    4683           0 :         PY_CHECK_TYPE(&echo_Enum2_Type, value, return -1;);
    4684           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4685           0 :                 PyErr_NoMemory();
    4686           0 :                 return -1;
    4687             :         }
    4688           0 :         object->out.foo2 = (struct echo_Enum2 *)pytalloc_get_ptr(value);
    4689           0 :         return 0;
    4690             : }
    4691             : 
    4692           0 : static PyObject *py_echo_TestEnum_in_get_foo3(PyObject *obj, void *closure)
    4693             : {
    4694           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4695             :         PyObject *py_foo3;
    4696           0 :         if (object->in.foo3 == NULL) {
    4697           0 :                 Py_RETURN_NONE;
    4698             :         }
    4699           0 :         py_foo3 = pyrpc_import_union(&echo_Enum3_Type, object->in.foo3, *object->in.foo1, object->in.foo3, "union echo_Enum3");
    4700           0 :         if (py_foo3 == NULL) {
    4701           0 :                 return NULL;
    4702             :         }
    4703           0 :         return py_foo3;
    4704             : }
    4705             : 
    4706           0 : static int py_echo_TestEnum_in_set_foo3(PyObject *py_obj, PyObject *value, void *closure)
    4707             : {
    4708           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4709           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.foo3));
    4710           0 :         if (value == NULL) {
    4711           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.foo3");
    4712           0 :                 return -1;
    4713             :         }
    4714           0 :         object->in.foo3 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.foo3);
    4715           0 :         if (object->in.foo3 == NULL) {
    4716           0 :                 PyErr_NoMemory();
    4717           0 :                 return -1;
    4718             :         }
    4719             :         {
    4720             :                 union echo_Enum3 *foo3_switch_1;
    4721           0 :                 foo3_switch_1 = (union echo_Enum3 *)pyrpc_export_union(&echo_Enum3_Type, pytalloc_get_mem_ctx(py_obj), *object->in.foo1, value, "union echo_Enum3");
    4722           0 :                 if (foo3_switch_1 == NULL) {
    4723           0 :                         return -1;
    4724             :                 }
    4725           0 :                 object->in.foo3 = foo3_switch_1;
    4726             :         }
    4727           0 :         return 0;
    4728             : }
    4729             : 
    4730           0 : static PyObject *py_echo_TestEnum_out_get_foo3(PyObject *obj, void *closure)
    4731             : {
    4732           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(obj);
    4733             :         PyObject *py_foo3;
    4734           0 :         if (object->out.foo3 == NULL) {
    4735           0 :                 Py_RETURN_NONE;
    4736             :         }
    4737           0 :         py_foo3 = pyrpc_import_union(&echo_Enum3_Type, object->out.foo3, *object->out.foo1, object->out.foo3, "union echo_Enum3");
    4738           0 :         if (py_foo3 == NULL) {
    4739           0 :                 return NULL;
    4740             :         }
    4741           0 :         return py_foo3;
    4742             : }
    4743             : 
    4744           0 : static int py_echo_TestEnum_out_set_foo3(PyObject *py_obj, PyObject *value, void *closure)
    4745             : {
    4746           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4747           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.foo3));
    4748           0 :         if (value == NULL) {
    4749           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.foo3");
    4750           0 :                 return -1;
    4751             :         }
    4752           0 :         object->out.foo3 = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.foo3);
    4753           0 :         if (object->out.foo3 == NULL) {
    4754           0 :                 PyErr_NoMemory();
    4755           0 :                 return -1;
    4756             :         }
    4757             :         {
    4758             :                 union echo_Enum3 *foo3_switch_1;
    4759           0 :                 foo3_switch_1 = (union echo_Enum3 *)pyrpc_export_union(&echo_Enum3_Type, pytalloc_get_mem_ctx(py_obj), *object->out.foo1, value, "union echo_Enum3");
    4760           0 :                 if (foo3_switch_1 == NULL) {
    4761           0 :                         return -1;
    4762             :                 }
    4763           0 :                 object->out.foo3 = foo3_switch_1;
    4764             :         }
    4765           0 :         return 0;
    4766             : }
    4767             : 
    4768             : static PyGetSetDef py_echo_TestEnum_getsetters[] = {
    4769             :         {
    4770             :                 .name = discard_const_p(char, "in_foo1"),
    4771             :                 .get = py_echo_TestEnum_in_get_foo1,
    4772             :                 .set = py_echo_TestEnum_in_set_foo1,
    4773             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum1")
    4774             :         },
    4775             :         {
    4776             :                 .name = discard_const_p(char, "out_foo1"),
    4777             :                 .get = py_echo_TestEnum_out_get_foo1,
    4778             :                 .set = py_echo_TestEnum_out_set_foo1,
    4779             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum1")
    4780             :         },
    4781             :         {
    4782             :                 .name = discard_const_p(char, "in_foo2"),
    4783             :                 .get = py_echo_TestEnum_in_get_foo2,
    4784             :                 .set = py_echo_TestEnum_in_set_foo2,
    4785             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum2")
    4786             :         },
    4787             :         {
    4788             :                 .name = discard_const_p(char, "out_foo2"),
    4789             :                 .get = py_echo_TestEnum_out_get_foo2,
    4790             :                 .set = py_echo_TestEnum_out_set_foo2,
    4791             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum2")
    4792             :         },
    4793             :         {
    4794             :                 .name = discard_const_p(char, "in_foo3"),
    4795             :                 .get = py_echo_TestEnum_in_get_foo3,
    4796             :                 .set = py_echo_TestEnum_in_set_foo3,
    4797             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum3")
    4798             :         },
    4799             :         {
    4800             :                 .name = discard_const_p(char, "out_foo3"),
    4801             :                 .get = py_echo_TestEnum_out_get_foo3,
    4802             :                 .set = py_echo_TestEnum_out_set_foo3,
    4803             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Enum3")
    4804             :         },
    4805             :         { .name = NULL }
    4806             : };
    4807             : 
    4808           0 : static PyObject *py_echo_TestEnum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    4809             : {
    4810           0 :         PyObject *self = pytalloc_new(struct echo_TestEnum, type);
    4811           0 :         struct echo_TestEnum *_self = (struct echo_TestEnum *)pytalloc_get_ptr(self);
    4812           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    4813           0 :         _self->in.foo1 = talloc_zero(mem_ctx, enum echo_Enum1);
    4814           0 :         _self->out.foo1 = talloc_zero(mem_ctx, enum echo_Enum1);
    4815           0 :         _self->in.foo2 = talloc_zero(mem_ctx, struct echo_Enum2);
    4816           0 :         _self->out.foo2 = talloc_zero(mem_ctx, struct echo_Enum2);
    4817           0 :         _self->in.foo3 = talloc_zero(mem_ctx, union echo_Enum3);
    4818           0 :         _self->out.foo3 = talloc_zero(mem_ctx, union echo_Enum3);
    4819           0 :         return self;
    4820             : }
    4821             : 
    4822           0 : static PyObject *py_echo_TestEnum_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    4823             : {
    4824             : 
    4825             : 
    4826           0 :         return PyLong_FromLong(7);
    4827             : }
    4828             : 
    4829           0 : static PyObject *py_echo_TestEnum_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    4830             : {
    4831           0 :         const struct ndr_interface_call *call = NULL;
    4832           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4833           0 :         PyObject *ret = NULL;
    4834           0 :         struct ndr_push *push = NULL;
    4835             :         DATA_BLOB blob;
    4836             :         enum ndr_err_code err;
    4837             : 
    4838           0 :         if (ndr_table_rpcecho.num_calls < 8) {
    4839           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestEnum_ndr_pack");
    4840           0 :                 return NULL;
    4841             :         }
    4842           0 :         call = &ndr_table_rpcecho.calls[7];
    4843             : 
    4844           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    4845           0 :         if (push == NULL) {
    4846           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4847           0 :                 return NULL;
    4848             :         }
    4849             : 
    4850           0 :         push->flags |= ndr_push_flags;
    4851             : 
    4852           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    4853           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4854           0 :                 TALLOC_FREE(push);
    4855           0 :                 PyErr_SetNdrError(err);
    4856           0 :                 return NULL;
    4857             :         }
    4858           0 :         blob = ndr_push_blob(push);
    4859           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    4860           0 :         TALLOC_FREE(push);
    4861           0 :         return ret;
    4862             : }
    4863             : 
    4864           0 : static PyObject *py_echo_TestEnum_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4865             : {
    4866           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4867           0 :         PyObject *bigendian_obj = NULL;
    4868           0 :         PyObject *ndr64_obj = NULL;
    4869           0 :         libndr_flags ndr_push_flags = 0;
    4870             : 
    4871           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    4872             :                 discard_const_p(char *, kwnames),
    4873             :                 &bigendian_obj,
    4874             :                 &ndr64_obj)) {
    4875           0 :                 return NULL;
    4876             :         }
    4877             : 
    4878           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4879           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4880             :         }
    4881           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4882           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4883             :         }
    4884             : 
    4885           0 :         return py_echo_TestEnum_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    4886             : }
    4887             : 
    4888           0 : static PyObject *py_echo_TestEnum_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4889             : {
    4890           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4891           0 :         PyObject *bigendian_obj = NULL;
    4892           0 :         PyObject *ndr64_obj = NULL;
    4893           0 :         libndr_flags ndr_push_flags = 0;
    4894             : 
    4895           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    4896             :                 discard_const_p(char *, kwnames),
    4897             :                 &bigendian_obj,
    4898             :                 &ndr64_obj)) {
    4899           0 :                 return NULL;
    4900             :         }
    4901             : 
    4902           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4903           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4904             :         }
    4905           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4906           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4907             :         }
    4908             : 
    4909           0 :         return py_echo_TestEnum_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    4910             : }
    4911             : 
    4912           0 : static PyObject *py_echo_TestEnum_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    4913             : {
    4914           0 :         const struct ndr_interface_call *call = NULL;
    4915           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    4916           0 :         struct ndr_pull *pull = NULL;
    4917             :         enum ndr_err_code err;
    4918             : 
    4919           0 :         if (ndr_table_rpcecho.num_calls < 8) {
    4920           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestEnum_ndr_unpack");
    4921           0 :                 return NULL;
    4922             :         }
    4923           0 :         call = &ndr_table_rpcecho.calls[7];
    4924             : 
    4925           0 :         pull = ndr_pull_init_blob(blob, object);
    4926           0 :         if (pull == NULL) {
    4927           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4928           0 :                 return NULL;
    4929             :         }
    4930             : 
    4931           0 :         pull->flags |= ndr_pull_flags;
    4932             : 
    4933           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    4934           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4935           0 :                 TALLOC_FREE(pull);
    4936           0 :                 PyErr_SetNdrError(err);
    4937           0 :                 return NULL;
    4938             :         }
    4939           0 :         if (!allow_remaining) {
    4940             :                 uint32_t highest_ofs;
    4941             : 
    4942           0 :                 if (pull->offset > pull->relative_highest_offset) {
    4943           0 :                         highest_ofs = pull->offset;
    4944             :                 } else {
    4945           0 :                         highest_ofs = pull->relative_highest_offset;
    4946             :                 }
    4947           0 :                 if (highest_ofs < pull->data_size) {
    4948           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    4949             :                                 "not all bytes consumed ofs[%u] size[%u]",
    4950             :                                 highest_ofs, pull->data_size);
    4951           0 :                         TALLOC_FREE(pull);
    4952           0 :                         PyErr_SetNdrError(err);
    4953           0 :                         return NULL;
    4954             :                 }
    4955             :         }
    4956             : 
    4957           0 :         TALLOC_FREE(pull);
    4958           0 :         Py_RETURN_NONE;
    4959             : }
    4960             : 
    4961           0 : static PyObject *py_echo_TestEnum_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4962             : {
    4963             :         DATA_BLOB blob;
    4964           0 :         Py_ssize_t blob_length = 0;
    4965           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    4966           0 :         PyObject *bigendian_obj = NULL;
    4967           0 :         PyObject *ndr64_obj = NULL;
    4968           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    4969           0 :         PyObject *allow_remaining_obj = NULL;
    4970           0 :         bool allow_remaining = false;
    4971             : 
    4972           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    4973             :                 discard_const_p(char *, kwnames),
    4974             :                 &blob.data, &blob_length,
    4975             :                 &bigendian_obj,
    4976             :                 &ndr64_obj,
    4977             :                 &allow_remaining_obj)) {
    4978           0 :                 return NULL;
    4979             :         }
    4980           0 :         blob.length = blob_length;
    4981             : 
    4982           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4983           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    4984             :         }
    4985           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4986           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4987             :         }
    4988             : 
    4989           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4990           0 :                 allow_remaining = true;
    4991             :         }
    4992             : 
    4993           0 :         return py_echo_TestEnum_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    4994             : }
    4995             : 
    4996           0 : static PyObject *py_echo_TestEnum_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4997             : {
    4998             :         DATA_BLOB blob;
    4999           0 :         Py_ssize_t blob_length = 0;
    5000           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5001           0 :         PyObject *bigendian_obj = NULL;
    5002           0 :         PyObject *ndr64_obj = NULL;
    5003           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5004           0 :         PyObject *allow_remaining_obj = NULL;
    5005           0 :         bool allow_remaining = false;
    5006             : 
    5007           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    5008             :                 discard_const_p(char *, kwnames),
    5009             :                 &blob.data, &blob_length,
    5010             :                 &bigendian_obj,
    5011             :                 &ndr64_obj,
    5012             :                 &allow_remaining_obj)) {
    5013           0 :                 return NULL;
    5014             :         }
    5015           0 :         blob.length = blob_length;
    5016             : 
    5017           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5018           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5019             :         }
    5020           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5021           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5022             :         }
    5023             : 
    5024           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5025           0 :                 allow_remaining = true;
    5026             :         }
    5027             : 
    5028           0 :         return py_echo_TestEnum_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    5029             : }
    5030             : 
    5031           0 : static PyObject *py_echo_TestEnum_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    5032             : {
    5033           0 :         const struct ndr_interface_call *call = NULL;
    5034           0 :         struct echo_TestEnum *object = pytalloc_get_ptr(py_obj);
    5035             :         PyObject *ret;
    5036             :         char *retstr;
    5037             : 
    5038           0 :         if (ndr_table_rpcecho.num_calls < 8) {
    5039           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestEnum_ndr_print");
    5040           0 :                 return NULL;
    5041             :         }
    5042           0 :         call = &ndr_table_rpcecho.calls[7];
    5043             : 
    5044           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    5045           0 :         ret = PyUnicode_FromString(retstr);
    5046           0 :         TALLOC_FREE(retstr);
    5047             : 
    5048           0 :         return ret;
    5049             : }
    5050             : 
    5051           0 : static PyObject *py_echo_TestEnum_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5052             : {
    5053           0 :         return py_echo_TestEnum_ndr_print(py_obj, "echo_TestEnum_in", NDR_IN);
    5054             : }
    5055             : 
    5056           0 : static PyObject *py_echo_TestEnum_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5057             : {
    5058           0 :         return py_echo_TestEnum_ndr_print(py_obj, "echo_TestEnum_out", NDR_OUT);
    5059             : }
    5060             : 
    5061             : static PyMethodDef py_echo_TestEnum_methods[] = {
    5062             :         { "opnum", (PyCFunction)py_echo_TestEnum_ndr_opnum, METH_NOARGS|METH_CLASS,
    5063             :                 "echo.TestEnum.opnum() -> 7 (0x07) " },
    5064             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestEnum_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    5065             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    5066             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestEnum_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    5067             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    5068             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestEnum_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    5069             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    5070             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestEnum_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    5071             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    5072             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestEnum_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    5073             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestEnum_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    5074             :         { NULL, NULL, 0, NULL }
    5075             : };
    5076             : 
    5077             : 
    5078             : static PyTypeObject echo_TestEnum_Type = {
    5079             :         PyVarObject_HEAD_INIT(NULL, 0)
    5080             :         .tp_name = "echo.TestEnum",
    5081             :         .tp_getset = py_echo_TestEnum_getsetters,
    5082             :         .tp_methods = py_echo_TestEnum_methods,
    5083             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    5084             :         .tp_new = py_echo_TestEnum_new,
    5085             : };
    5086             : 
    5087           0 : static bool pack_py_echo_TestEnum_args_in(PyObject *args, PyObject *kwargs, struct echo_TestEnum *r)
    5088             : {
    5089             :         PyObject *py_foo1;
    5090             :         PyObject *py_foo2;
    5091             :         PyObject *py_foo3;
    5092           0 :         const char *kwnames[] = {
    5093             :                 "foo1", "foo2", "foo3", NULL
    5094             :         };
    5095             : 
    5096           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:echo_TestEnum", discard_const_p(char *, kwnames), &py_foo1, &py_foo2, &py_foo3)) {
    5097           0 :                 return false;
    5098             :         }
    5099             : 
    5100           0 :         if (py_foo1 == NULL) {
    5101           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.foo1");
    5102           0 :                 return false;
    5103             :         }
    5104           0 :         r->in.foo1 = talloc_ptrtype(r, r->in.foo1);
    5105           0 :         if (r->in.foo1 == NULL) {
    5106           0 :                 PyErr_NoMemory();
    5107           0 :                 return false;
    5108             :         }
    5109             :         {
    5110           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.foo1));
    5111           0 :                 if (PyLong_Check(py_foo1)) {
    5112             :                         unsigned long long test_var;
    5113           0 :                         test_var = PyLong_AsUnsignedLongLong(py_foo1);
    5114           0 :                         if (PyErr_Occurred() != NULL) {
    5115           0 :                                 return false;
    5116             :                         }
    5117           0 :                         if (test_var > uint_max) {
    5118           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    5119             :                                   PyLong_Type.tp_name, uint_max, test_var);
    5120           0 :                                 return false;
    5121             :                         }
    5122           0 :                         *r->in.foo1 = test_var;
    5123             :                 } else {
    5124           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    5125             :                           PyLong_Type.tp_name);
    5126           0 :                         return false;
    5127             :                 }
    5128             :         }
    5129           0 :         if (py_foo2 == NULL) {
    5130           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.foo2");
    5131           0 :                 return false;
    5132             :         }
    5133           0 :         r->in.foo2 = talloc_ptrtype(r, r->in.foo2);
    5134           0 :         if (r->in.foo2 == NULL) {
    5135           0 :                 PyErr_NoMemory();
    5136           0 :                 return false;
    5137             :         }
    5138           0 :         PY_CHECK_TYPE(&echo_Enum2_Type, py_foo2, return false;);
    5139           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_foo2)) == NULL) {
    5140           0 :                 PyErr_NoMemory();
    5141           0 :                 return false;
    5142             :         }
    5143           0 :         r->in.foo2 = (struct echo_Enum2 *)pytalloc_get_ptr(py_foo2);
    5144           0 :         if (py_foo3 == NULL) {
    5145           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.foo3");
    5146           0 :                 return false;
    5147             :         }
    5148           0 :         r->in.foo3 = talloc_ptrtype(r, r->in.foo3);
    5149           0 :         if (r->in.foo3 == NULL) {
    5150           0 :                 PyErr_NoMemory();
    5151           0 :                 return false;
    5152             :         }
    5153             :         {
    5154             :                 union echo_Enum3 *foo3_switch_1;
    5155           0 :                 foo3_switch_1 = (union echo_Enum3 *)pyrpc_export_union(&echo_Enum3_Type, r, *r->in.foo1, py_foo3, "union echo_Enum3");
    5156           0 :                 if (foo3_switch_1 == NULL) {
    5157           0 :                         return false;
    5158             :                 }
    5159           0 :                 r->in.foo3 = foo3_switch_1;
    5160             :         }
    5161           0 :         return true;
    5162             : }
    5163             : 
    5164           0 : static PyObject *unpack_py_echo_TestEnum_args_out(struct echo_TestEnum *r)
    5165             : {
    5166             :         PyObject *result;
    5167             :         PyObject *py_foo1;
    5168             :         PyObject *py_foo2;
    5169             :         PyObject *py_foo3;
    5170           0 :         result = PyTuple_New(3);
    5171           0 :         py_foo1 = PyLong_FromLong((uint16_t)(*r->out.foo1));
    5172           0 :         PyTuple_SetItem(result, 0, py_foo1);
    5173           0 :         py_foo2 = pytalloc_reference_ex(&echo_Enum2_Type, r->out.foo2, r->out.foo2);
    5174           0 :         PyTuple_SetItem(result, 1, py_foo2);
    5175           0 :         py_foo3 = pyrpc_import_union(&echo_Enum3_Type, r->out.foo3, *r->out.foo1, r->out.foo3, "union echo_Enum3");
    5176           0 :         if (py_foo3 == NULL) {
    5177           0 :                 return NULL;
    5178             :         }
    5179           0 :         PyTuple_SetItem(result, 2, py_foo3);
    5180           0 :         return result;
    5181             : }
    5182             : 
    5183             : 
    5184           0 : static PyObject *py_echo_TestSurrounding_in_get_data(PyObject *obj, void *closure)
    5185             : {
    5186           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(obj);
    5187             :         PyObject *py_data;
    5188           0 :         if (object->in.data == NULL) {
    5189           0 :                 Py_RETURN_NONE;
    5190             :         }
    5191           0 :         py_data = pytalloc_reference_ex(&echo_Surrounding_Type, object->in.data, object->in.data);
    5192           0 :         return py_data;
    5193             : }
    5194             : 
    5195           0 : static int py_echo_TestSurrounding_in_set_data(PyObject *py_obj, PyObject *value, void *closure)
    5196             : {
    5197           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(py_obj);
    5198           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.data));
    5199           0 :         if (value == NULL) {
    5200           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.data");
    5201           0 :                 return -1;
    5202             :         }
    5203           0 :         object->in.data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.data);
    5204           0 :         if (object->in.data == NULL) {
    5205           0 :                 PyErr_NoMemory();
    5206           0 :                 return -1;
    5207             :         }
    5208           0 :         PY_CHECK_TYPE(&echo_Surrounding_Type, value, return -1;);
    5209           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5210           0 :                 PyErr_NoMemory();
    5211           0 :                 return -1;
    5212             :         }
    5213           0 :         object->in.data = (struct echo_Surrounding *)pytalloc_get_ptr(value);
    5214           0 :         return 0;
    5215             : }
    5216             : 
    5217           0 : static PyObject *py_echo_TestSurrounding_out_get_data(PyObject *obj, void *closure)
    5218             : {
    5219           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(obj);
    5220             :         PyObject *py_data;
    5221           0 :         if (object->out.data == NULL) {
    5222           0 :                 Py_RETURN_NONE;
    5223             :         }
    5224           0 :         py_data = pytalloc_reference_ex(&echo_Surrounding_Type, object->out.data, object->out.data);
    5225           0 :         return py_data;
    5226             : }
    5227             : 
    5228           0 : static int py_echo_TestSurrounding_out_set_data(PyObject *py_obj, PyObject *value, void *closure)
    5229             : {
    5230           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(py_obj);
    5231           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.data));
    5232           0 :         if (value == NULL) {
    5233           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.data");
    5234           0 :                 return -1;
    5235             :         }
    5236           0 :         object->out.data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.data);
    5237           0 :         if (object->out.data == NULL) {
    5238           0 :                 PyErr_NoMemory();
    5239           0 :                 return -1;
    5240             :         }
    5241           0 :         PY_CHECK_TYPE(&echo_Surrounding_Type, value, return -1;);
    5242           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5243           0 :                 PyErr_NoMemory();
    5244           0 :                 return -1;
    5245             :         }
    5246           0 :         object->out.data = (struct echo_Surrounding *)pytalloc_get_ptr(value);
    5247           0 :         return 0;
    5248             : }
    5249             : 
    5250             : static PyGetSetDef py_echo_TestSurrounding_getsetters[] = {
    5251             :         {
    5252             :                 .name = discard_const_p(char, "in_data"),
    5253             :                 .get = py_echo_TestSurrounding_in_get_data,
    5254             :                 .set = py_echo_TestSurrounding_in_set_data,
    5255             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Surrounding")
    5256             :         },
    5257             :         {
    5258             :                 .name = discard_const_p(char, "out_data"),
    5259             :                 .get = py_echo_TestSurrounding_out_get_data,
    5260             :                 .set = py_echo_TestSurrounding_out_set_data,
    5261             :                 .doc = discard_const_p(char, "PIDL-generated element of base type echo_Surrounding")
    5262             :         },
    5263             :         { .name = NULL }
    5264             : };
    5265             : 
    5266           0 : static PyObject *py_echo_TestSurrounding_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    5267             : {
    5268           0 :         PyObject *self = pytalloc_new(struct echo_TestSurrounding, type);
    5269           0 :         struct echo_TestSurrounding *_self = (struct echo_TestSurrounding *)pytalloc_get_ptr(self);
    5270           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    5271           0 :         _self->in.data = talloc_zero(mem_ctx, struct echo_Surrounding);
    5272           0 :         _self->out.data = talloc_zero(mem_ctx, struct echo_Surrounding);
    5273           0 :         return self;
    5274             : }
    5275             : 
    5276           0 : static PyObject *py_echo_TestSurrounding_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    5277             : {
    5278             : 
    5279             : 
    5280           0 :         return PyLong_FromLong(8);
    5281             : }
    5282             : 
    5283           0 : static PyObject *py_echo_TestSurrounding_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    5284             : {
    5285           0 :         const struct ndr_interface_call *call = NULL;
    5286           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(py_obj);
    5287           0 :         PyObject *ret = NULL;
    5288           0 :         struct ndr_push *push = NULL;
    5289             :         DATA_BLOB blob;
    5290             :         enum ndr_err_code err;
    5291             : 
    5292           0 :         if (ndr_table_rpcecho.num_calls < 9) {
    5293           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSurrounding_ndr_pack");
    5294           0 :                 return NULL;
    5295             :         }
    5296           0 :         call = &ndr_table_rpcecho.calls[8];
    5297             : 
    5298           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    5299           0 :         if (push == NULL) {
    5300           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5301           0 :                 return NULL;
    5302             :         }
    5303             : 
    5304           0 :         push->flags |= ndr_push_flags;
    5305             : 
    5306           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    5307           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5308           0 :                 TALLOC_FREE(push);
    5309           0 :                 PyErr_SetNdrError(err);
    5310           0 :                 return NULL;
    5311             :         }
    5312           0 :         blob = ndr_push_blob(push);
    5313           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    5314           0 :         TALLOC_FREE(push);
    5315           0 :         return ret;
    5316             : }
    5317             : 
    5318           0 : static PyObject *py_echo_TestSurrounding_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5319             : {
    5320           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5321           0 :         PyObject *bigendian_obj = NULL;
    5322           0 :         PyObject *ndr64_obj = NULL;
    5323           0 :         libndr_flags ndr_push_flags = 0;
    5324             : 
    5325           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    5326             :                 discard_const_p(char *, kwnames),
    5327             :                 &bigendian_obj,
    5328             :                 &ndr64_obj)) {
    5329           0 :                 return NULL;
    5330             :         }
    5331             : 
    5332           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5333           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5334             :         }
    5335           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5336           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5337             :         }
    5338             : 
    5339           0 :         return py_echo_TestSurrounding_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    5340             : }
    5341             : 
    5342           0 : static PyObject *py_echo_TestSurrounding_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5343             : {
    5344           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5345           0 :         PyObject *bigendian_obj = NULL;
    5346           0 :         PyObject *ndr64_obj = NULL;
    5347           0 :         libndr_flags ndr_push_flags = 0;
    5348             : 
    5349           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    5350             :                 discard_const_p(char *, kwnames),
    5351             :                 &bigendian_obj,
    5352             :                 &ndr64_obj)) {
    5353           0 :                 return NULL;
    5354             :         }
    5355             : 
    5356           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5357           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5358             :         }
    5359           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5360           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5361             :         }
    5362             : 
    5363           0 :         return py_echo_TestSurrounding_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    5364             : }
    5365             : 
    5366           0 : static PyObject *py_echo_TestSurrounding_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    5367             : {
    5368           0 :         const struct ndr_interface_call *call = NULL;
    5369           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(py_obj);
    5370           0 :         struct ndr_pull *pull = NULL;
    5371             :         enum ndr_err_code err;
    5372             : 
    5373           0 :         if (ndr_table_rpcecho.num_calls < 9) {
    5374           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSurrounding_ndr_unpack");
    5375           0 :                 return NULL;
    5376             :         }
    5377           0 :         call = &ndr_table_rpcecho.calls[8];
    5378             : 
    5379           0 :         pull = ndr_pull_init_blob(blob, object);
    5380           0 :         if (pull == NULL) {
    5381           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5382           0 :                 return NULL;
    5383             :         }
    5384             : 
    5385           0 :         pull->flags |= ndr_pull_flags;
    5386             : 
    5387           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    5388           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5389           0 :                 TALLOC_FREE(pull);
    5390           0 :                 PyErr_SetNdrError(err);
    5391           0 :                 return NULL;
    5392             :         }
    5393           0 :         if (!allow_remaining) {
    5394             :                 uint32_t highest_ofs;
    5395             : 
    5396           0 :                 if (pull->offset > pull->relative_highest_offset) {
    5397           0 :                         highest_ofs = pull->offset;
    5398             :                 } else {
    5399           0 :                         highest_ofs = pull->relative_highest_offset;
    5400             :                 }
    5401           0 :                 if (highest_ofs < pull->data_size) {
    5402           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    5403             :                                 "not all bytes consumed ofs[%u] size[%u]",
    5404             :                                 highest_ofs, pull->data_size);
    5405           0 :                         TALLOC_FREE(pull);
    5406           0 :                         PyErr_SetNdrError(err);
    5407           0 :                         return NULL;
    5408             :                 }
    5409             :         }
    5410             : 
    5411           0 :         TALLOC_FREE(pull);
    5412           0 :         Py_RETURN_NONE;
    5413             : }
    5414             : 
    5415           0 : static PyObject *py_echo_TestSurrounding_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5416             : {
    5417             :         DATA_BLOB blob;
    5418           0 :         Py_ssize_t blob_length = 0;
    5419           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5420           0 :         PyObject *bigendian_obj = NULL;
    5421           0 :         PyObject *ndr64_obj = NULL;
    5422           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5423           0 :         PyObject *allow_remaining_obj = NULL;
    5424           0 :         bool allow_remaining = false;
    5425             : 
    5426           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    5427             :                 discard_const_p(char *, kwnames),
    5428             :                 &blob.data, &blob_length,
    5429             :                 &bigendian_obj,
    5430             :                 &ndr64_obj,
    5431             :                 &allow_remaining_obj)) {
    5432           0 :                 return NULL;
    5433             :         }
    5434           0 :         blob.length = blob_length;
    5435             : 
    5436           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5437           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5438             :         }
    5439           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5440           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5441             :         }
    5442             : 
    5443           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5444           0 :                 allow_remaining = true;
    5445             :         }
    5446             : 
    5447           0 :         return py_echo_TestSurrounding_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    5448             : }
    5449             : 
    5450           0 : static PyObject *py_echo_TestSurrounding_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5451             : {
    5452             :         DATA_BLOB blob;
    5453           0 :         Py_ssize_t blob_length = 0;
    5454           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5455           0 :         PyObject *bigendian_obj = NULL;
    5456           0 :         PyObject *ndr64_obj = NULL;
    5457           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5458           0 :         PyObject *allow_remaining_obj = NULL;
    5459           0 :         bool allow_remaining = false;
    5460             : 
    5461           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    5462             :                 discard_const_p(char *, kwnames),
    5463             :                 &blob.data, &blob_length,
    5464             :                 &bigendian_obj,
    5465             :                 &ndr64_obj,
    5466             :                 &allow_remaining_obj)) {
    5467           0 :                 return NULL;
    5468             :         }
    5469           0 :         blob.length = blob_length;
    5470             : 
    5471           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5472           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5473             :         }
    5474           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5475           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5476             :         }
    5477             : 
    5478           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5479           0 :                 allow_remaining = true;
    5480             :         }
    5481             : 
    5482           0 :         return py_echo_TestSurrounding_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    5483             : }
    5484             : 
    5485           0 : static PyObject *py_echo_TestSurrounding_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    5486             : {
    5487           0 :         const struct ndr_interface_call *call = NULL;
    5488           0 :         struct echo_TestSurrounding *object = pytalloc_get_ptr(py_obj);
    5489             :         PyObject *ret;
    5490             :         char *retstr;
    5491             : 
    5492           0 :         if (ndr_table_rpcecho.num_calls < 9) {
    5493           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestSurrounding_ndr_print");
    5494           0 :                 return NULL;
    5495             :         }
    5496           0 :         call = &ndr_table_rpcecho.calls[8];
    5497             : 
    5498           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    5499           0 :         ret = PyUnicode_FromString(retstr);
    5500           0 :         TALLOC_FREE(retstr);
    5501             : 
    5502           0 :         return ret;
    5503             : }
    5504             : 
    5505           0 : static PyObject *py_echo_TestSurrounding_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5506             : {
    5507           0 :         return py_echo_TestSurrounding_ndr_print(py_obj, "echo_TestSurrounding_in", NDR_IN);
    5508             : }
    5509             : 
    5510           0 : static PyObject *py_echo_TestSurrounding_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5511             : {
    5512           0 :         return py_echo_TestSurrounding_ndr_print(py_obj, "echo_TestSurrounding_out", NDR_OUT);
    5513             : }
    5514             : 
    5515             : static PyMethodDef py_echo_TestSurrounding_methods[] = {
    5516             :         { "opnum", (PyCFunction)py_echo_TestSurrounding_ndr_opnum, METH_NOARGS|METH_CLASS,
    5517             :                 "echo.TestSurrounding.opnum() -> 8 (0x08) " },
    5518             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSurrounding_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    5519             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    5520             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSurrounding_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    5521             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    5522             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSurrounding_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    5523             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    5524             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestSurrounding_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    5525             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    5526             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestSurrounding_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    5527             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestSurrounding_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    5528             :         { NULL, NULL, 0, NULL }
    5529             : };
    5530             : 
    5531             : 
    5532             : static PyTypeObject echo_TestSurrounding_Type = {
    5533             :         PyVarObject_HEAD_INIT(NULL, 0)
    5534             :         .tp_name = "echo.TestSurrounding",
    5535             :         .tp_getset = py_echo_TestSurrounding_getsetters,
    5536             :         .tp_methods = py_echo_TestSurrounding_methods,
    5537             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    5538             :         .tp_new = py_echo_TestSurrounding_new,
    5539             : };
    5540             : 
    5541           1 : static bool pack_py_echo_TestSurrounding_args_in(PyObject *args, PyObject *kwargs, struct echo_TestSurrounding *r)
    5542             : {
    5543             :         PyObject *py_data;
    5544           1 :         const char *kwnames[] = {
    5545             :                 "data", NULL
    5546             :         };
    5547             : 
    5548           1 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_TestSurrounding", discard_const_p(char *, kwnames), &py_data)) {
    5549           0 :                 return false;
    5550             :         }
    5551             : 
    5552           1 :         if (py_data == NULL) {
    5553           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.data");
    5554           0 :                 return false;
    5555             :         }
    5556           1 :         r->in.data = talloc_ptrtype(r, r->in.data);
    5557           1 :         if (r->in.data == NULL) {
    5558           0 :                 PyErr_NoMemory();
    5559           0 :                 return false;
    5560             :         }
    5561           1 :         PY_CHECK_TYPE(&echo_Surrounding_Type, py_data, return false;);
    5562           1 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_data)) == NULL) {
    5563           0 :                 PyErr_NoMemory();
    5564           0 :                 return false;
    5565             :         }
    5566           1 :         r->in.data = (struct echo_Surrounding *)pytalloc_get_ptr(py_data);
    5567           1 :         return true;
    5568             : }
    5569             : 
    5570           1 : static PyObject *unpack_py_echo_TestSurrounding_args_out(struct echo_TestSurrounding *r)
    5571             : {
    5572             :         PyObject *result;
    5573             :         PyObject *py_data;
    5574           1 :         py_data = pytalloc_reference_ex(&echo_Surrounding_Type, r->out.data, r->out.data);
    5575           1 :         result = py_data;
    5576           1 :         return result;
    5577             : }
    5578             : 
    5579             : 
    5580           0 : static PyObject *py_echo_TestDoublePointer_in_get_data(PyObject *obj, void *closure)
    5581             : {
    5582           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(obj);
    5583             :         PyObject *py_data;
    5584           0 :         if (object->in.data == NULL) {
    5585           0 :                 Py_RETURN_NONE;
    5586             :         }
    5587           0 :         if (*object->in.data == NULL) {
    5588           0 :                 py_data = Py_None;
    5589           0 :                 Py_INCREF(py_data);
    5590             :         } else {
    5591           0 :                 if (**object->in.data == NULL) {
    5592           0 :                         py_data = Py_None;
    5593           0 :                         Py_INCREF(py_data);
    5594             :                 } else {
    5595           0 :                         py_data = PyLong_FromLong((uint16_t)(***object->in.data));
    5596             :                 }
    5597             :         }
    5598             :         {
    5599           0 :                 PyObject *py_data_level_1 = py_data;
    5600           0 :                 py_data = py_dcerpc_ndr_pointer_wrap(ndr_pointer_Type, py_data_level_1);
    5601           0 :                 Py_XDECREF(py_data_level_1);
    5602             :         }
    5603           0 :         return py_data;
    5604             : }
    5605             : 
    5606           0 : static int py_echo_TestDoublePointer_in_set_data(PyObject *py_obj, PyObject *value, void *closure)
    5607             : {
    5608           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(py_obj);
    5609           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.data));
    5610           0 :         if (value == NULL) {
    5611           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->in.data");
    5612           0 :                 return -1;
    5613             :         }
    5614           0 :         object->in.data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.data);
    5615           0 :         if (object->in.data == NULL) {
    5616           0 :                 PyErr_NoMemory();
    5617           0 :                 return -1;
    5618             :         }
    5619           0 :         if (value == Py_None) {
    5620           0 :                 *object->in.data = NULL;
    5621             :         } else {
    5622           0 :                 *object->in.data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), *object->in.data);
    5623           0 :                 if (*object->in.data == NULL) {
    5624           0 :                         PyErr_NoMemory();
    5625           0 :                         return -1;
    5626             :                 }
    5627           0 :                 value = py_dcerpc_ndr_pointer_deref(ndr_pointer_Type, value);
    5628           0 :                 if (value == NULL) {
    5629           0 :                         return -1;
    5630             :                 }
    5631           0 :                 if (value == Py_None) {
    5632           0 :                         **object->in.data = NULL;
    5633             :                 } else {
    5634           0 :                         **object->in.data = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), **object->in.data);
    5635           0 :                         if (**object->in.data == NULL) {
    5636           0 :                                 PyErr_NoMemory();
    5637           0 :                                 return -1;
    5638             :                         }
    5639             :                         {
    5640           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(***object->in.data));
    5641           0 :                                 if (PyLong_Check(value)) {
    5642             :                                         unsigned long long test_var;
    5643           0 :                                         test_var = PyLong_AsUnsignedLongLong(value);
    5644           0 :                                         if (PyErr_Occurred() != NULL) {
    5645           0 :                                                 return -1;
    5646             :                                         }
    5647           0 :                                         if (test_var > uint_max) {
    5648           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    5649             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    5650           0 :                                                 return -1;
    5651             :                                         }
    5652           0 :                                         ***object->in.data = test_var;
    5653             :                                 } else {
    5654           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    5655             :                                           PyLong_Type.tp_name);
    5656           0 :                                         return -1;
    5657             :                                 }
    5658             :                         }
    5659             :                 }
    5660             :         }
    5661           0 :         return 0;
    5662             : }
    5663             : 
    5664           0 : static PyObject *py_echo_TestDoublePointer_get_result(PyObject *obj, void *closure)
    5665             : {
    5666           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(obj);
    5667             :         PyObject *py_result;
    5668           0 :         py_result = PyLong_FromLong((uint16_t)(object->out.result));
    5669           0 :         return py_result;
    5670             : }
    5671             : 
    5672           0 : static int py_echo_TestDoublePointer_set_result(PyObject *py_obj, PyObject *value, void *closure)
    5673             : {
    5674           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(py_obj);
    5675           0 :         if (value == NULL) {
    5676           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: object->out.result");
    5677           0 :                 return -1;
    5678             :         }
    5679             :         {
    5680           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->out.result));
    5681           0 :                 if (PyLong_Check(value)) {
    5682             :                         unsigned long long test_var;
    5683           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    5684           0 :                         if (PyErr_Occurred() != NULL) {
    5685           0 :                                 return -1;
    5686             :                         }
    5687           0 :                         if (test_var > uint_max) {
    5688           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    5689             :                                   PyLong_Type.tp_name, uint_max, test_var);
    5690           0 :                                 return -1;
    5691             :                         }
    5692           0 :                         object->out.result = test_var;
    5693             :                 } else {
    5694           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    5695             :                           PyLong_Type.tp_name);
    5696           0 :                         return -1;
    5697             :                 }
    5698             :         }
    5699           0 :         return 0;
    5700             : }
    5701             : 
    5702             : static PyGetSetDef py_echo_TestDoublePointer_getsetters[] = {
    5703             :         {
    5704             :                 .name = discard_const_p(char, "in_data"),
    5705             :                 .get = py_echo_TestDoublePointer_in_get_data,
    5706             :                 .set = py_echo_TestDoublePointer_in_set_data,
    5707             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    5708             :         },
    5709             :         {
    5710             :                 .name = discard_const_p(char, "result"),
    5711             :                 .get = py_echo_TestDoublePointer_get_result,
    5712             :                 .set = py_echo_TestDoublePointer_set_result,
    5713             :                 .doc = discard_const_p(char, "PIDL-generated element of type uint16")
    5714             :         },
    5715             :         { .name = NULL }
    5716             : };
    5717             : 
    5718           0 : static PyObject *py_echo_TestDoublePointer_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    5719             : {
    5720           0 :         PyObject *self = pytalloc_new(struct echo_TestDoublePointer, type);
    5721           0 :         struct echo_TestDoublePointer *_self = (struct echo_TestDoublePointer *)pytalloc_get_ptr(self);
    5722           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    5723             :         /* a pointer to a NULL pointer */
    5724           0 :         _self->in.data = talloc_zero(mem_ctx, uint16_t **);
    5725           0 :         return self;
    5726             : }
    5727             : 
    5728           0 : static PyObject *py_echo_TestDoublePointer_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    5729             : {
    5730             : 
    5731             : 
    5732           0 :         return PyLong_FromLong(9);
    5733             : }
    5734             : 
    5735           0 : static PyObject *py_echo_TestDoublePointer_ndr_pack(PyObject *py_obj, ndr_flags_type ndr_inout_flags, libndr_flags ndr_push_flags)
    5736             : {
    5737           0 :         const struct ndr_interface_call *call = NULL;
    5738           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(py_obj);
    5739           0 :         PyObject *ret = NULL;
    5740           0 :         struct ndr_push *push = NULL;
    5741             :         DATA_BLOB blob;
    5742             :         enum ndr_err_code err;
    5743             : 
    5744           0 :         if (ndr_table_rpcecho.num_calls < 10) {
    5745           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestDoublePointer_ndr_pack");
    5746           0 :                 return NULL;
    5747             :         }
    5748           0 :         call = &ndr_table_rpcecho.calls[9];
    5749             : 
    5750           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    5751           0 :         if (push == NULL) {
    5752           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5753           0 :                 return NULL;
    5754             :         }
    5755             : 
    5756           0 :         push->flags |= ndr_push_flags;
    5757             : 
    5758           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    5759           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5760           0 :                 TALLOC_FREE(push);
    5761           0 :                 PyErr_SetNdrError(err);
    5762           0 :                 return NULL;
    5763             :         }
    5764           0 :         blob = ndr_push_blob(push);
    5765           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    5766           0 :         TALLOC_FREE(push);
    5767           0 :         return ret;
    5768             : }
    5769             : 
    5770           0 : static PyObject *py_echo_TestDoublePointer_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5771             : {
    5772           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5773           0 :         PyObject *bigendian_obj = NULL;
    5774           0 :         PyObject *ndr64_obj = NULL;
    5775           0 :         libndr_flags ndr_push_flags = 0;
    5776             : 
    5777           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    5778             :                 discard_const_p(char *, kwnames),
    5779             :                 &bigendian_obj,
    5780             :                 &ndr64_obj)) {
    5781           0 :                 return NULL;
    5782             :         }
    5783             : 
    5784           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5785           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5786             :         }
    5787           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5788           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5789             :         }
    5790             : 
    5791           0 :         return py_echo_TestDoublePointer_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    5792             : }
    5793             : 
    5794           0 : static PyObject *py_echo_TestDoublePointer_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5795             : {
    5796           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5797           0 :         PyObject *bigendian_obj = NULL;
    5798           0 :         PyObject *ndr64_obj = NULL;
    5799           0 :         libndr_flags ndr_push_flags = 0;
    5800             : 
    5801           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    5802             :                 discard_const_p(char *, kwnames),
    5803             :                 &bigendian_obj,
    5804             :                 &ndr64_obj)) {
    5805           0 :                 return NULL;
    5806             :         }
    5807             : 
    5808           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5809           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5810             :         }
    5811           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5812           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5813             :         }
    5814             : 
    5815           0 :         return py_echo_TestDoublePointer_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    5816             : }
    5817             : 
    5818           0 : static PyObject *py_echo_TestDoublePointer_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, ndr_flags_type ndr_inout_flags, libndr_flags ndr_pull_flags, bool allow_remaining)
    5819             : {
    5820           0 :         const struct ndr_interface_call *call = NULL;
    5821           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(py_obj);
    5822           0 :         struct ndr_pull *pull = NULL;
    5823             :         enum ndr_err_code err;
    5824             : 
    5825           0 :         if (ndr_table_rpcecho.num_calls < 10) {
    5826           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestDoublePointer_ndr_unpack");
    5827           0 :                 return NULL;
    5828             :         }
    5829           0 :         call = &ndr_table_rpcecho.calls[9];
    5830             : 
    5831           0 :         pull = ndr_pull_init_blob(blob, object);
    5832           0 :         if (pull == NULL) {
    5833           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5834           0 :                 return NULL;
    5835             :         }
    5836             : 
    5837           0 :         pull->flags |= ndr_pull_flags;
    5838             : 
    5839           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    5840           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5841           0 :                 TALLOC_FREE(pull);
    5842           0 :                 PyErr_SetNdrError(err);
    5843           0 :                 return NULL;
    5844             :         }
    5845           0 :         if (!allow_remaining) {
    5846             :                 uint32_t highest_ofs;
    5847             : 
    5848           0 :                 if (pull->offset > pull->relative_highest_offset) {
    5849           0 :                         highest_ofs = pull->offset;
    5850             :                 } else {
    5851           0 :                         highest_ofs = pull->relative_highest_offset;
    5852             :                 }
    5853           0 :                 if (highest_ofs < pull->data_size) {
    5854           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    5855             :                                 "not all bytes consumed ofs[%u] size[%u]",
    5856             :                                 highest_ofs, pull->data_size);
    5857           0 :                         TALLOC_FREE(pull);
    5858           0 :                         PyErr_SetNdrError(err);
    5859           0 :                         return NULL;
    5860             :                 }
    5861             :         }
    5862             : 
    5863           0 :         TALLOC_FREE(pull);
    5864           0 :         Py_RETURN_NONE;
    5865             : }
    5866             : 
    5867           0 : static PyObject *py_echo_TestDoublePointer_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5868             : {
    5869             :         DATA_BLOB blob;
    5870           0 :         Py_ssize_t blob_length = 0;
    5871           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5872           0 :         PyObject *bigendian_obj = NULL;
    5873           0 :         PyObject *ndr64_obj = NULL;
    5874           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5875           0 :         PyObject *allow_remaining_obj = NULL;
    5876           0 :         bool allow_remaining = false;
    5877             : 
    5878           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    5879             :                 discard_const_p(char *, kwnames),
    5880             :                 &blob.data, &blob_length,
    5881             :                 &bigendian_obj,
    5882             :                 &ndr64_obj,
    5883             :                 &allow_remaining_obj)) {
    5884           0 :                 return NULL;
    5885             :         }
    5886           0 :         blob.length = blob_length;
    5887             : 
    5888           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5889           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5890             :         }
    5891           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5892           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5893             :         }
    5894             : 
    5895           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5896           0 :                 allow_remaining = true;
    5897             :         }
    5898             : 
    5899           0 :         return py_echo_TestDoublePointer_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    5900             : }
    5901             : 
    5902           0 : static PyObject *py_echo_TestDoublePointer_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5903             : {
    5904             :         DATA_BLOB blob;
    5905           0 :         Py_ssize_t blob_length = 0;
    5906           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5907           0 :         PyObject *bigendian_obj = NULL;
    5908           0 :         PyObject *ndr64_obj = NULL;
    5909           0 :         libndr_flags ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5910           0 :         PyObject *allow_remaining_obj = NULL;
    5911           0 :         bool allow_remaining = false;
    5912             : 
    5913           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    5914             :                 discard_const_p(char *, kwnames),
    5915             :                 &blob.data, &blob_length,
    5916             :                 &bigendian_obj,
    5917             :                 &ndr64_obj,
    5918             :                 &allow_remaining_obj)) {
    5919           0 :                 return NULL;
    5920             :         }
    5921           0 :         blob.length = blob_length;
    5922             : 
    5923           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5924           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5925             :         }
    5926           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5927           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5928             :         }
    5929             : 
    5930           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5931           0 :                 allow_remaining = true;
    5932             :         }
    5933             : 
    5934           0 :         return py_echo_TestDoublePointer_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    5935             : }
    5936             : 
    5937           0 : static PyObject *py_echo_TestDoublePointer_ndr_print(PyObject *py_obj, const char *name, ndr_flags_type ndr_inout_flags)
    5938             : {
    5939           0 :         const struct ndr_interface_call *call = NULL;
    5940           0 :         struct echo_TestDoublePointer *object = pytalloc_get_ptr(py_obj);
    5941             :         PyObject *ret;
    5942             :         char *retstr;
    5943             : 
    5944           0 :         if (ndr_table_rpcecho.num_calls < 10) {
    5945           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_echo_TestDoublePointer_ndr_print");
    5946           0 :                 return NULL;
    5947             :         }
    5948           0 :         call = &ndr_table_rpcecho.calls[9];
    5949             : 
    5950           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    5951           0 :         ret = PyUnicode_FromString(retstr);
    5952           0 :         TALLOC_FREE(retstr);
    5953             : 
    5954           0 :         return ret;
    5955             : }
    5956             : 
    5957           0 : static PyObject *py_echo_TestDoublePointer_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5958             : {
    5959           0 :         return py_echo_TestDoublePointer_ndr_print(py_obj, "echo_TestDoublePointer_in", NDR_IN);
    5960             : }
    5961             : 
    5962           0 : static PyObject *py_echo_TestDoublePointer_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5963             : {
    5964           0 :         return py_echo_TestDoublePointer_ndr_print(py_obj, "echo_TestDoublePointer_out", NDR_OUT);
    5965             : }
    5966             : 
    5967             : static PyMethodDef py_echo_TestDoublePointer_methods[] = {
    5968             :         { "opnum", (PyCFunction)py_echo_TestDoublePointer_ndr_opnum, METH_NOARGS|METH_CLASS,
    5969             :                 "echo.TestDoublePointer.opnum() -> 9 (0x09) " },
    5970             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestDoublePointer_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    5971             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    5972             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestDoublePointer_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    5973             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    5974             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestDoublePointer_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    5975             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    5976             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_echo_TestDoublePointer_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    5977             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    5978             :         { "__ndr_print_in__", (PyCFunction)py_echo_TestDoublePointer_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    5979             :         { "__ndr_print_out__", (PyCFunction)py_echo_TestDoublePointer_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    5980             :         { NULL, NULL, 0, NULL }
    5981             : };
    5982             : 
    5983             : 
    5984             : static PyTypeObject echo_TestDoublePointer_Type = {
    5985             :         PyVarObject_HEAD_INIT(NULL, 0)
    5986             :         .tp_name = "echo.TestDoublePointer",
    5987             :         .tp_getset = py_echo_TestDoublePointer_getsetters,
    5988             :         .tp_methods = py_echo_TestDoublePointer_methods,
    5989             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    5990             :         .tp_new = py_echo_TestDoublePointer_new,
    5991             : };
    5992             : 
    5993           0 : static bool pack_py_echo_TestDoublePointer_args_in(PyObject *args, PyObject *kwargs, struct echo_TestDoublePointer *r)
    5994             : {
    5995             :         PyObject *py_data;
    5996           0 :         const char *kwnames[] = {
    5997             :                 "data", NULL
    5998             :         };
    5999             : 
    6000           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:echo_TestDoublePointer", discard_const_p(char *, kwnames), &py_data)) {
    6001           0 :                 return false;
    6002             :         }
    6003             : 
    6004           0 :         if (py_data == NULL) {
    6005           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: r->in.data");
    6006           0 :                 return false;
    6007             :         }
    6008           0 :         r->in.data = talloc_ptrtype(r, r->in.data);
    6009           0 :         if (r->in.data == NULL) {
    6010           0 :                 PyErr_NoMemory();
    6011           0 :                 return false;
    6012             :         }
    6013           0 :         if (py_data == Py_None) {
    6014           0 :                 *r->in.data = NULL;
    6015             :         } else {
    6016           0 :                 *r->in.data = talloc_ptrtype(r, *r->in.data);
    6017           0 :                 if (*r->in.data == NULL) {
    6018           0 :                         PyErr_NoMemory();
    6019           0 :                         return false;
    6020             :                 }
    6021           0 :                 py_data = py_dcerpc_ndr_pointer_deref(ndr_pointer_Type, py_data);
    6022           0 :                 if (py_data == NULL) {
    6023           0 :                         return false;
    6024             :                 }
    6025           0 :                 if (py_data == Py_None) {
    6026           0 :                         **r->in.data = NULL;
    6027             :                 } else {
    6028           0 :                         **r->in.data = talloc_ptrtype(r, **r->in.data);
    6029           0 :                         if (**r->in.data == NULL) {
    6030           0 :                                 PyErr_NoMemory();
    6031           0 :                                 return false;
    6032             :                         }
    6033             :                         {
    6034           0 :                                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(***r->in.data));
    6035           0 :                                 if (PyLong_Check(py_data)) {
    6036             :                                         unsigned long long test_var;
    6037           0 :                                         test_var = PyLong_AsUnsignedLongLong(py_data);
    6038           0 :                                         if (PyErr_Occurred() != NULL) {
    6039           0 :                                                 return false;
    6040             :                                         }
    6041           0 :                                         if (test_var > uint_max) {
    6042           0 :                                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",
    6043             :                                                   PyLong_Type.tp_name, uint_max, test_var);
    6044           0 :                                                 return false;
    6045             :                                         }
    6046           0 :                                         ***r->in.data = test_var;
    6047             :                                 } else {
    6048           0 :                                         PyErr_Format(PyExc_TypeError, "Expected type %s",
    6049             :                                           PyLong_Type.tp_name);
    6050           0 :                                         return false;
    6051             :                                 }
    6052             :                         }
    6053             :                 }
    6054             :         }
    6055           0 :         return true;
    6056             : }
    6057             : 
    6058           0 : static PyObject *unpack_py_echo_TestDoublePointer_args_out(struct echo_TestDoublePointer *r)
    6059             : {
    6060             :         PyObject *result;
    6061           0 :         result = PyLong_FromLong((uint16_t)(r->out.result));
    6062           0 :         return result;
    6063             : }
    6064             : 
    6065             : const struct PyNdrRpcMethodDef py_ndr_rpcecho_methods[] = {
    6066             :         { "AddOne", "S.AddOne(in_data) -> out_data", (py_dcerpc_call_fn)dcerpc_echo_AddOne_r, (py_data_pack_fn)pack_py_echo_AddOne_args_in, (py_data_unpack_fn)unpack_py_echo_AddOne_args_out, 0, &ndr_table_rpcecho },
    6067             :         { "EchoData", "S.EchoData(in_data) -> out_data", (py_dcerpc_call_fn)dcerpc_echo_EchoData_r, (py_data_pack_fn)pack_py_echo_EchoData_args_in, (py_data_unpack_fn)unpack_py_echo_EchoData_args_out, 1, &ndr_table_rpcecho },
    6068             :         { "SinkData", "S.SinkData(data) -> None", (py_dcerpc_call_fn)dcerpc_echo_SinkData_r, (py_data_pack_fn)pack_py_echo_SinkData_args_in, (py_data_unpack_fn)unpack_py_echo_SinkData_args_out, 2, &ndr_table_rpcecho },
    6069             :         { "SourceData", "S.SourceData(len) -> data", (py_dcerpc_call_fn)dcerpc_echo_SourceData_r, (py_data_pack_fn)pack_py_echo_SourceData_args_in, (py_data_unpack_fn)unpack_py_echo_SourceData_args_out, 3, &ndr_table_rpcecho },
    6070             :         { "TestCall", "S.TestCall(s1) -> s2", (py_dcerpc_call_fn)dcerpc_echo_TestCall_r, (py_data_pack_fn)pack_py_echo_TestCall_args_in, (py_data_unpack_fn)unpack_py_echo_TestCall_args_out, 4, &ndr_table_rpcecho },
    6071             :         { "TestCall2", "S.TestCall2(level) -> info", (py_dcerpc_call_fn)dcerpc_echo_TestCall2_r, (py_data_pack_fn)pack_py_echo_TestCall2_args_in, (py_data_unpack_fn)unpack_py_echo_TestCall2_args_out, 5, &ndr_table_rpcecho },
    6072             :         { "TestSleep", "S.TestSleep(seconds) -> result", (py_dcerpc_call_fn)dcerpc_echo_TestSleep_r, (py_data_pack_fn)pack_py_echo_TestSleep_args_in, (py_data_unpack_fn)unpack_py_echo_TestSleep_args_out, 6, &ndr_table_rpcecho },
    6073             :         { "TestEnum", "S.TestEnum(foo1, foo2, foo3) -> (foo1, foo2, foo3)", (py_dcerpc_call_fn)dcerpc_echo_TestEnum_r, (py_data_pack_fn)pack_py_echo_TestEnum_args_in, (py_data_unpack_fn)unpack_py_echo_TestEnum_args_out, 7, &ndr_table_rpcecho },
    6074             :         { "TestSurrounding", "S.TestSurrounding(data) -> data", (py_dcerpc_call_fn)dcerpc_echo_TestSurrounding_r, (py_data_pack_fn)pack_py_echo_TestSurrounding_args_in, (py_data_unpack_fn)unpack_py_echo_TestSurrounding_args_out, 8, &ndr_table_rpcecho },
    6075             :         { "TestDoublePointer", "S.TestDoublePointer(data) -> result", (py_dcerpc_call_fn)dcerpc_echo_TestDoublePointer_r, (py_data_pack_fn)pack_py_echo_TestDoublePointer_args_in, (py_data_unpack_fn)unpack_py_echo_TestDoublePointer_args_out, 9, &ndr_table_rpcecho },
    6076             :         {0}
    6077             : };
    6078             : 
    6079          15 : static PyObject *interface_rpcecho_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    6080             : {
    6081          15 :         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_rpcecho);
    6082             : }
    6083             : 
    6084             : #define PY_DOC_RPCECHO "Simple echo pipe"
    6085             : static PyTypeObject rpcecho_InterfaceType = {
    6086             :         PyVarObject_HEAD_INIT(NULL, 0)
    6087             :         .tp_name = "echo.rpcecho",
    6088             :         .tp_basicsize = sizeof(dcerpc_InterfaceObject),
    6089             :         .tp_doc = "rpcecho(binding, lp_ctx=None, credentials=None) -> connection\n"
    6090             : "\n"
    6091             : "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
    6092             : "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
    6093             : "credentials should be a credentials.Credentials object.\n\n"PY_DOC_RPCECHO,
    6094             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    6095             :         .tp_new = interface_rpcecho_new,
    6096             : };
    6097             : 
    6098           0 : static PyObject *syntax_rpcecho_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    6099             : {
    6100           0 :         return py_dcerpc_syntax_init_helper(type, args, kwargs, &ndr_table_rpcecho.syntax_id);
    6101             : }
    6102             : 
    6103             : #define PY_DOC_RPCECHO_SYNTAX "Simple echo pipe"
    6104             : static PyTypeObject rpcecho_SyntaxType = {
    6105             :         PyVarObject_HEAD_INIT(NULL, 0)
    6106             :         .tp_name = "echo.rpcecho_abstract_syntax",
    6107             :         .tp_doc = "rpcecho_abstract_syntax()\n"PY_DOC_RPCECHO_SYNTAX,
    6108             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    6109             :         .tp_new = syntax_rpcecho_new,
    6110             : };
    6111             : 
    6112             : static PyMethodDef echo_methods[] = {
    6113             :         { NULL, NULL, 0, NULL }
    6114             : };
    6115             : 
    6116             : static struct PyModuleDef moduledef = {
    6117             :         PyModuleDef_HEAD_INIT,
    6118             :         .m_name = "echo",
    6119             :         .m_doc = "echo DCE/RPC",
    6120             :         .m_size = -1,
    6121             :         .m_methods = echo_methods,
    6122             : };
    6123           2 : MODULE_INIT_FUNC(echo)
    6124             : {
    6125           2 :         PyObject *m = NULL;
    6126           2 :         PyObject *dep_talloc = NULL;
    6127           2 :         PyObject *dep_samba_dcerpc_base = NULL;
    6128           2 :         PyObject *dep_samba_dcerpc_misc = NULL;
    6129             : 
    6130           2 :         dep_talloc = PyImport_ImportModule("talloc");
    6131           2 :         if (dep_talloc == NULL)
    6132           0 :                 goto out;
    6133             : 
    6134           2 :         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
    6135           2 :         if (dep_samba_dcerpc_base == NULL)
    6136           0 :                 goto out;
    6137             : 
    6138           2 :         dep_samba_dcerpc_misc = PyImport_ImportModule("samba.dcerpc.misc");
    6139           2 :         if (dep_samba_dcerpc_misc == NULL)
    6140           0 :                 goto out;
    6141             : 
    6142           2 :         BaseObject_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "BaseObject");
    6143           2 :         if (BaseObject_Type == NULL)
    6144           0 :                 goto out;
    6145             : 
    6146           2 :         ndr_pointer_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ndr_pointer");
    6147           2 :         if (ndr_pointer_Type == NULL)
    6148           0 :                 goto out;
    6149             : 
    6150           2 :         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
    6151           2 :         if (ClientConnection_Type == NULL)
    6152           0 :                 goto out;
    6153             : 
    6154           2 :         ndr_syntax_id_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_misc, "ndr_syntax_id");
    6155           2 :         if (ndr_syntax_id_Type == NULL)
    6156           0 :                 goto out;
    6157             : 
    6158           2 :         echo_info1_Type.tp_base = BaseObject_Type;
    6159           2 :         echo_info1_Type.tp_basicsize = pytalloc_BaseObject_size();
    6160             : 
    6161           2 :         echo_info2_Type.tp_base = BaseObject_Type;
    6162           2 :         echo_info2_Type.tp_basicsize = pytalloc_BaseObject_size();
    6163             : 
    6164           2 :         echo_info3_Type.tp_base = BaseObject_Type;
    6165           2 :         echo_info3_Type.tp_basicsize = pytalloc_BaseObject_size();
    6166             : 
    6167           2 :         echo_info4_Type.tp_base = BaseObject_Type;
    6168           2 :         echo_info4_Type.tp_basicsize = pytalloc_BaseObject_size();
    6169             : 
    6170           2 :         echo_info5_Type.tp_base = BaseObject_Type;
    6171           2 :         echo_info5_Type.tp_basicsize = pytalloc_BaseObject_size();
    6172             : 
    6173           2 :         echo_info6_Type.tp_base = BaseObject_Type;
    6174           2 :         echo_info6_Type.tp_basicsize = pytalloc_BaseObject_size();
    6175             : 
    6176           2 :         echo_info7_Type.tp_base = BaseObject_Type;
    6177           2 :         echo_info7_Type.tp_basicsize = pytalloc_BaseObject_size();
    6178             : 
    6179           2 :         echo_Info_Type.tp_base = BaseObject_Type;
    6180           2 :         echo_Info_Type.tp_basicsize = pytalloc_BaseObject_size();
    6181             : 
    6182           2 :         echo_Enum2_Type.tp_base = BaseObject_Type;
    6183           2 :         echo_Enum2_Type.tp_basicsize = pytalloc_BaseObject_size();
    6184             : 
    6185           2 :         echo_Enum3_Type.tp_base = BaseObject_Type;
    6186           2 :         echo_Enum3_Type.tp_basicsize = pytalloc_BaseObject_size();
    6187             : 
    6188           2 :         echo_Surrounding_Type.tp_base = BaseObject_Type;
    6189           2 :         echo_Surrounding_Type.tp_basicsize = pytalloc_BaseObject_size();
    6190             : 
    6191           2 :         echo_AddOne_Type.tp_base = BaseObject_Type;
    6192           2 :         echo_AddOne_Type.tp_basicsize = pytalloc_BaseObject_size();
    6193             : 
    6194           2 :         echo_EchoData_Type.tp_base = BaseObject_Type;
    6195           2 :         echo_EchoData_Type.tp_basicsize = pytalloc_BaseObject_size();
    6196             : 
    6197           2 :         echo_SinkData_Type.tp_base = BaseObject_Type;
    6198           2 :         echo_SinkData_Type.tp_basicsize = pytalloc_BaseObject_size();
    6199             : 
    6200           2 :         echo_SourceData_Type.tp_base = BaseObject_Type;
    6201           2 :         echo_SourceData_Type.tp_basicsize = pytalloc_BaseObject_size();
    6202             : 
    6203           2 :         echo_TestCall_Type.tp_base = BaseObject_Type;
    6204           2 :         echo_TestCall_Type.tp_basicsize = pytalloc_BaseObject_size();
    6205             : 
    6206           2 :         echo_TestCall2_Type.tp_base = BaseObject_Type;
    6207           2 :         echo_TestCall2_Type.tp_basicsize = pytalloc_BaseObject_size();
    6208             : 
    6209           2 :         echo_TestSleep_Type.tp_base = BaseObject_Type;
    6210           2 :         echo_TestSleep_Type.tp_basicsize = pytalloc_BaseObject_size();
    6211             : 
    6212           2 :         echo_TestEnum_Type.tp_base = BaseObject_Type;
    6213           2 :         echo_TestEnum_Type.tp_basicsize = pytalloc_BaseObject_size();
    6214             : 
    6215           2 :         echo_TestSurrounding_Type.tp_base = BaseObject_Type;
    6216           2 :         echo_TestSurrounding_Type.tp_basicsize = pytalloc_BaseObject_size();
    6217             : 
    6218           2 :         echo_TestDoublePointer_Type.tp_base = BaseObject_Type;
    6219           2 :         echo_TestDoublePointer_Type.tp_basicsize = pytalloc_BaseObject_size();
    6220             : 
    6221           2 :         rpcecho_InterfaceType.tp_base = ClientConnection_Type;
    6222             : 
    6223           2 :         rpcecho_SyntaxType.tp_base = ndr_syntax_id_Type;
    6224           2 :         rpcecho_SyntaxType.tp_basicsize = pytalloc_BaseObject_size();
    6225             : 
    6226           2 :         if (PyType_Ready(&echo_info1_Type) < 0)
    6227           0 :                 goto out;
    6228           2 :         if (PyType_Ready(&echo_info2_Type) < 0)
    6229           0 :                 goto out;
    6230           2 :         if (PyType_Ready(&echo_info3_Type) < 0)
    6231           0 :                 goto out;
    6232           2 :         if (PyType_Ready(&echo_info4_Type) < 0)
    6233           0 :                 goto out;
    6234           2 :         if (PyType_Ready(&echo_info5_Type) < 0)
    6235           0 :                 goto out;
    6236           2 :         if (PyType_Ready(&echo_info6_Type) < 0)
    6237           0 :                 goto out;
    6238           2 :         if (PyType_Ready(&echo_info7_Type) < 0)
    6239           0 :                 goto out;
    6240           2 :         if (PyType_Ready(&echo_Info_Type) < 0)
    6241           0 :                 goto out;
    6242           2 :         if (PyType_Ready(&echo_Enum2_Type) < 0)
    6243           0 :                 goto out;
    6244           2 :         if (PyType_Ready(&echo_Enum3_Type) < 0)
    6245           0 :                 goto out;
    6246           2 :         if (PyType_Ready(&echo_Surrounding_Type) < 0)
    6247           0 :                 goto out;
    6248           2 :         if (PyType_Ready(&echo_AddOne_Type) < 0)
    6249           0 :                 goto out;
    6250           2 :         if (PyType_Ready(&echo_EchoData_Type) < 0)
    6251           0 :                 goto out;
    6252           2 :         if (PyType_Ready(&echo_SinkData_Type) < 0)
    6253           0 :                 goto out;
    6254           2 :         if (PyType_Ready(&echo_SourceData_Type) < 0)
    6255           0 :                 goto out;
    6256           2 :         if (PyType_Ready(&echo_TestCall_Type) < 0)
    6257           0 :                 goto out;
    6258           2 :         if (PyType_Ready(&echo_TestCall2_Type) < 0)
    6259           0 :                 goto out;
    6260           2 :         if (PyType_Ready(&echo_TestSleep_Type) < 0)
    6261           0 :                 goto out;
    6262           2 :         if (PyType_Ready(&echo_TestEnum_Type) < 0)
    6263           0 :                 goto out;
    6264           2 :         if (PyType_Ready(&echo_TestSurrounding_Type) < 0)
    6265           0 :                 goto out;
    6266           2 :         if (PyType_Ready(&echo_TestDoublePointer_Type) < 0)
    6267           0 :                 goto out;
    6268           2 :         if (PyType_Ready(&rpcecho_InterfaceType) < 0)
    6269           0 :                 goto out;
    6270           2 :         if (PyType_Ready(&rpcecho_SyntaxType) < 0)
    6271           0 :                 goto out;
    6272           2 :         if (!PyInterface_AddNdrRpcMethods(&rpcecho_InterfaceType, py_ndr_rpcecho_methods))
    6273           0 :                 return NULL;
    6274             : 
    6275             : #ifdef PY_INFO1_PATCH
    6276             :         PY_INFO1_PATCH(&echo_info1_Type);
    6277             : #endif
    6278             : #ifdef PY_INFO2_PATCH
    6279             :         PY_INFO2_PATCH(&echo_info2_Type);
    6280             : #endif
    6281             : #ifdef PY_INFO3_PATCH
    6282             :         PY_INFO3_PATCH(&echo_info3_Type);
    6283             : #endif
    6284             : #ifdef PY_INFO4_PATCH
    6285             :         PY_INFO4_PATCH(&echo_info4_Type);
    6286             : #endif
    6287             : #ifdef PY_INFO5_PATCH
    6288             :         PY_INFO5_PATCH(&echo_info5_Type);
    6289             : #endif
    6290             : #ifdef PY_INFO6_PATCH
    6291             :         PY_INFO6_PATCH(&echo_info6_Type);
    6292             : #endif
    6293             : #ifdef PY_INFO7_PATCH
    6294             :         PY_INFO7_PATCH(&echo_info7_Type);
    6295             : #endif
    6296             : #ifdef PY_INFO_PATCH
    6297             :         PY_INFO_PATCH(&echo_Info_Type);
    6298             : #endif
    6299             : #ifdef PY_ENUM2_PATCH
    6300             :         PY_ENUM2_PATCH(&echo_Enum2_Type);
    6301             : #endif
    6302             : #ifdef PY_ENUM3_PATCH
    6303             :         PY_ENUM3_PATCH(&echo_Enum3_Type);
    6304             : #endif
    6305             : #ifdef PY_SURROUNDING_PATCH
    6306             :         PY_SURROUNDING_PATCH(&echo_Surrounding_Type);
    6307             : #endif
    6308             : #ifdef PY_ADDONE_PATCH
    6309             :         PY_ADDONE_PATCH(&echo_AddOne_Type);
    6310             : #endif
    6311             : #ifdef PY_ECHODATA_PATCH
    6312             :         PY_ECHODATA_PATCH(&echo_EchoData_Type);
    6313             : #endif
    6314             : #ifdef PY_SINKDATA_PATCH
    6315             :         PY_SINKDATA_PATCH(&echo_SinkData_Type);
    6316             : #endif
    6317             : #ifdef PY_SOURCEDATA_PATCH
    6318             :         PY_SOURCEDATA_PATCH(&echo_SourceData_Type);
    6319             : #endif
    6320             : #ifdef PY_TESTCALL_PATCH
    6321             :         PY_TESTCALL_PATCH(&echo_TestCall_Type);
    6322             : #endif
    6323             : #ifdef PY_TESTCALL2_PATCH
    6324             :         PY_TESTCALL2_PATCH(&echo_TestCall2_Type);
    6325             : #endif
    6326             : #ifdef PY_TESTSLEEP_PATCH
    6327             :         PY_TESTSLEEP_PATCH(&echo_TestSleep_Type);
    6328             : #endif
    6329             : #ifdef PY_TESTENUM_PATCH
    6330             :         PY_TESTENUM_PATCH(&echo_TestEnum_Type);
    6331             : #endif
    6332             : #ifdef PY_TESTSURROUNDING_PATCH
    6333             :         PY_TESTSURROUNDING_PATCH(&echo_TestSurrounding_Type);
    6334             : #endif
    6335             : #ifdef PY_TESTDOUBLEPOINTER_PATCH
    6336             :         PY_TESTDOUBLEPOINTER_PATCH(&echo_TestDoublePointer_Type);
    6337             : #endif
    6338             : #ifdef PY_RPCECHO_PATCH
    6339             :         PY_RPCECHO_PATCH(&rpcecho_InterfaceType);
    6340             : #endif
    6341             : #ifdef PY_RPCECHO_ABSTRACT_SYNTAX_PATCH
    6342             :         PY_RPCECHO_ABSTRACT_SYNTAX_PATCH(&rpcecho_SyntaxType);
    6343             : #endif
    6344             : #ifdef PY_ABSTRACT_SYNTAX_PATCH
    6345             :         PY_ABSTRACT_SYNTAX_PATCH(&rpcecho_SyntaxType);
    6346             : #endif
    6347             : 
    6348           2 :         m = PyModule_Create(&moduledef);
    6349           2 :         if (m == NULL)
    6350           0 :                 goto out;
    6351             : 
    6352           2 :         PyModule_AddObject(m, "ECHO_ENUM1", PyLong_FromLong((uint16_t)(ECHO_ENUM1)));
    6353           2 :         PyModule_AddObject(m, "ECHO_ENUM2", PyLong_FromLong((uint16_t)(ECHO_ENUM2)));
    6354           2 :         PyModule_AddObject(m, "ECHO_ENUM1_32", PyLong_FromUnsignedLongLong((uint32_t)(ECHO_ENUM1_32)));
    6355           2 :         PyModule_AddObject(m, "ECHO_ENUM2_32", PyLong_FromUnsignedLongLong((uint32_t)(ECHO_ENUM2_32)));
    6356           2 :         Py_INCREF((PyObject *)(void *)&echo_info1_Type);
    6357           2 :         PyModule_AddObject(m, "info1", (PyObject *)(void *)&echo_info1_Type);
    6358           2 :         Py_INCREF((PyObject *)(void *)&echo_info2_Type);
    6359           2 :         PyModule_AddObject(m, "info2", (PyObject *)(void *)&echo_info2_Type);
    6360           2 :         Py_INCREF((PyObject *)(void *)&echo_info3_Type);
    6361           2 :         PyModule_AddObject(m, "info3", (PyObject *)(void *)&echo_info3_Type);
    6362           2 :         Py_INCREF((PyObject *)(void *)&echo_info4_Type);
    6363           2 :         PyModule_AddObject(m, "info4", (PyObject *)(void *)&echo_info4_Type);
    6364           2 :         Py_INCREF((PyObject *)(void *)&echo_info5_Type);
    6365           2 :         PyModule_AddObject(m, "info5", (PyObject *)(void *)&echo_info5_Type);
    6366           2 :         Py_INCREF((PyObject *)(void *)&echo_info6_Type);
    6367           2 :         PyModule_AddObject(m, "info6", (PyObject *)(void *)&echo_info6_Type);
    6368           2 :         Py_INCREF((PyObject *)(void *)&echo_info7_Type);
    6369           2 :         PyModule_AddObject(m, "info7", (PyObject *)(void *)&echo_info7_Type);
    6370           2 :         Py_INCREF((PyObject *)(void *)&echo_Info_Type);
    6371           2 :         PyModule_AddObject(m, "Info", (PyObject *)(void *)&echo_Info_Type);
    6372           2 :         Py_INCREF((PyObject *)(void *)&echo_Enum2_Type);
    6373           2 :         PyModule_AddObject(m, "Enum2", (PyObject *)(void *)&echo_Enum2_Type);
    6374           2 :         Py_INCREF((PyObject *)(void *)&echo_Enum3_Type);
    6375           2 :         PyModule_AddObject(m, "Enum3", (PyObject *)(void *)&echo_Enum3_Type);
    6376           2 :         Py_INCREF((PyObject *)(void *)&echo_Surrounding_Type);
    6377           2 :         PyModule_AddObject(m, "Surrounding", (PyObject *)(void *)&echo_Surrounding_Type);
    6378           2 :         Py_INCREF((PyObject *)(void *)&echo_AddOne_Type);
    6379           2 :         PyModule_AddObject(m, "AddOne", (PyObject *)(void *)&echo_AddOne_Type);
    6380           2 :         Py_INCREF((PyObject *)(void *)&echo_EchoData_Type);
    6381           2 :         PyModule_AddObject(m, "EchoData", (PyObject *)(void *)&echo_EchoData_Type);
    6382           2 :         Py_INCREF((PyObject *)(void *)&echo_SinkData_Type);
    6383           2 :         PyModule_AddObject(m, "SinkData", (PyObject *)(void *)&echo_SinkData_Type);
    6384           2 :         Py_INCREF((PyObject *)(void *)&echo_SourceData_Type);
    6385           2 :         PyModule_AddObject(m, "SourceData", (PyObject *)(void *)&echo_SourceData_Type);
    6386           2 :         Py_INCREF((PyObject *)(void *)&echo_TestCall_Type);
    6387           2 :         PyModule_AddObject(m, "TestCall", (PyObject *)(void *)&echo_TestCall_Type);
    6388           2 :         Py_INCREF((PyObject *)(void *)&echo_TestCall2_Type);
    6389           2 :         PyModule_AddObject(m, "TestCall2", (PyObject *)(void *)&echo_TestCall2_Type);
    6390           2 :         Py_INCREF((PyObject *)(void *)&echo_TestSleep_Type);
    6391           2 :         PyModule_AddObject(m, "TestSleep", (PyObject *)(void *)&echo_TestSleep_Type);
    6392           2 :         Py_INCREF((PyObject *)(void *)&echo_TestEnum_Type);
    6393           2 :         PyModule_AddObject(m, "TestEnum", (PyObject *)(void *)&echo_TestEnum_Type);
    6394           2 :         Py_INCREF((PyObject *)(void *)&echo_TestSurrounding_Type);
    6395           2 :         PyModule_AddObject(m, "TestSurrounding", (PyObject *)(void *)&echo_TestSurrounding_Type);
    6396           2 :         Py_INCREF((PyObject *)(void *)&echo_TestDoublePointer_Type);
    6397           2 :         PyModule_AddObject(m, "TestDoublePointer", (PyObject *)(void *)&echo_TestDoublePointer_Type);
    6398           2 :         Py_INCREF((PyObject *)(void *)&rpcecho_InterfaceType);
    6399           2 :         PyModule_AddObject(m, "rpcecho", (PyObject *)(void *)&rpcecho_InterfaceType);
    6400           2 :         Py_INCREF((PyObject *)(void *)&rpcecho_SyntaxType);
    6401           2 :         PyModule_AddObject(m, "rpcecho_abstract_syntax", (PyObject *)(void *)&rpcecho_SyntaxType);
    6402           2 :         Py_INCREF((PyObject *)(void *)&rpcecho_SyntaxType);
    6403           2 :         PyModule_AddObject(m, "abstract_syntax", (PyObject *)(void *)&rpcecho_SyntaxType);
    6404             : #ifdef PY_MOD_ECHO_PATCH
    6405             :         PY_MOD_ECHO_PATCH(m);
    6406             : #endif
    6407           2 :         out:
    6408           2 :         Py_XDECREF(dep_talloc);
    6409           2 :         Py_XDECREF(dep_samba_dcerpc_base);
    6410           2 :         Py_XDECREF(dep_samba_dcerpc_misc);
    6411           2 :         return m;
    6412             : 
    6413             : }

Generated by: LCOV version 1.14