diff --git a/CellFrame/python-cellframe.c b/CellFrame/python-cellframe.c index 33936f47f10599adc977e1a773c2510be7dd8fea..3654ce422cf7839b2dbc25d63dcb81ba88d8315a 100644 --- a/CellFrame/python-cellframe.c +++ b/CellFrame/python-cellframe.c @@ -373,8 +373,8 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ PyType_Ready( &ServerCore_ServerCoreType ) < 0 || PyType_Ready( &dapEvents_dapEventsType ) < 0 || PyType_Ready( &dapEventsSocket_dapEventsSocketType ) < 0 || - PyType_Ready( &CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType ) < 0 || - PyType_Ready( &CryptoDataTypeObjecy_CryptoDataTypeObjecyType ) < 0 || + PyType_Ready( &CryptoKeyTypeObject_CryptoKeyTypeObjectType ) < 0 || + PyType_Ready( &CryptoDataTypeObject_CryptoDataTypeObjectType ) < 0 || PyType_Ready(&DapSignObject_DapSignObjectType) < 0 || PyType_Ready(&DapSignTypeObject_DapSignTypeObjectType) < 0 || // === Chain === @@ -427,6 +427,11 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ PyType_Ready(&DapChainNetSrvObject_DapChainNetSrvObjectType) < 0 || PyType_Ready(&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType) < 0 || PyType_Ready(&DapChainNetSrvDatumObject_DapChainNetSrvDatumObjectType) < 0 || + PyType_Ready(&DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType) < 0 || + PyType_Ready(&DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType) < 0 || + PyType_Ready(&DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType) < 0 || + PyType_Ready(&DapChainNetSrvPriceObject_DapChainNetSrvPriceObjectType) < 0 || + PyType_Ready(&DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType) < 0 || // ============= PyType_Ready(&DapChainGDBObject_DapChainGDBType) < 0 || @@ -480,8 +485,8 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ PyModule_AddObject(module, "Events", (PyObject*)&dapEvents_dapEventsType); PyModule_AddObject(module, "EventsSocket", (PyObject*)&dapEventsSocket_dapEventsSocketType); - PyModule_AddObject(module, "CryptoKeyType", (PyObject*)&CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType); - PyModule_AddObject(module, "CryptoDataType", (PyObject*)&CryptoDataTypeObjecy_CryptoDataTypeObjecyType); + PyModule_AddObject(module, "CryptoKeyType", (PyObject*)&CryptoKeyTypeObject_CryptoKeyTypeObjectType); + PyModule_AddObject(module, "CryptoDataType", (PyObject*)&CryptoDataTypeObject_CryptoDataTypeObjectType); // === Chain === PyModule_AddObject(module, "Chain", (PyObject*)&dapChainObject_dapChainType); @@ -533,6 +538,11 @@ PyMODINIT_FUNC PyInit_libCellFrame(void){ PyModule_AddObject(module, "ChainNetSrv", (PyObject*)&DapChainNetSrvObject_DapChainNetSrvObjectType); PyModule_AddObject(module, "ChainNetSrvClient", (PyObject*)&DapChainNetSrvClientObject_DapChainNetSrvClientObjectType); PyModule_AddObject(module, "ChainNetSrvDatum", (PyObject*)&DapChainNetSrvDatumObject_DapChainNetSrvDatumObjectType); + PyModule_AddObject(module , "ChainNetSrvPrice", (PyObject*)&DapChainNetSrvPriceObject_DapChainNetSrvPriceObjectType); + PyModule_AddObject(module, "ChainNetSrvOrder", (PyObject*)&DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType); + PyModule_AddObject(module, "ChainNetSrvOrderDirection", (PyObject*)&DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType); + PyModule_AddObject(module, "ChainNetSrvUID", (PyObject*)&DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); + PyModule_AddObject(module, "ChainNetSrvPriceUnitUID", (PyObject*)&DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); // ============= PyModule_AddObject(module, "ChainGDB", (PyObject*)&DapChainGDBObject_DapChainGDBType); diff --git a/CellFrame/wrapping_dap_mempool.c b/CellFrame/wrapping_dap_mempool.c index f7bb254f9a64b93e0682116b10bca4335ed4cc67..a512ec0987ee72daa4a6815933e347d8c1d1ecf1 100644 --- a/CellFrame/wrapping_dap_mempool.c +++ b/CellFrame/wrapping_dap_mempool.c @@ -7,4 +7,39 @@ PyObject *dap_chain_mempool_add_proc_py(PyObject *self, PyObject *args){ return NULL; dap_chain_mempool_add_proc(DAP_HTTP(((PyDapServerObject*)obj_server)->t_server), MEMPOOL_URL); return PyLong_FromLong(0); +} + +PyObject *dap_chain_mempool_tx_create_py(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_chain; + PyObject *obj_key_from; + PyObject *obj_addr_from; + PyObject *obj_addr_to; + PyObject *obj_addr_fee; + char *l_token_ticker; + uint64_t l_value; + uint64_t l_value_fee; + if (!PyArg_ParseTuple(args, "OOOOOskk", &obj_chain, &obj_key_from, &obj_addr_from, &obj_addr_to, &obj_addr_fee, + &l_token_ticker, &l_value, &l_value_fee)){ + return NULL; + } + dap_chain_t *l_chain = ((PyDapChainObject*)obj_chain)->chain_t; + dap_enc_key_t *l_key_from = ((PyCryptoKeyObject*)obj_key_from)->key; + dap_chain_addr_t *l_addr_from = ((PyDapChainAddrObject*)obj_addr_from)->addr; + dap_chain_addr_t *l_addr_to = ((PyDapChainAddrObject*)obj_addr_to)->addr; + dap_chain_addr_t *l_addr_fee = ((PyDapChainAddrObject*)obj_addr_fee)->addr; + uint256_t l_value_256 = dap_chain_uint256_from(l_value); + uint256_t l_value_fee_256 = dap_chain_uint256_from(l_value_fee); + dap_chain_hash_fast_t *l_hash_tx = dap_chain_mempool_tx_create(l_chain, l_key_from, + l_addr_from, l_addr_to, + l_addr_fee, l_token_ticker, + l_value_256, l_value_fee_256); + if (l_hash_tx == NULL){ + return Py_None; + } else { + PyDapHashFastObject *obj_hf = PyObject_New(PyDapHashFastObject, &DapHashFastObject_DapHashFastObjectType); + PyObject_Dir((PyObject*)obj_hf); + obj_hf->hash_fast = l_hash_tx; + return (PyObject*)obj_hf; + } } \ No newline at end of file diff --git a/dists/examples/0.Beginning/var/lib/ca/.keep-it b/dists/examples/0.Beginning/var/lib/ca/.keep-it deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dists/examples/1.Authority/var/lib/ca/.keep-it b/dists/examples/1.Authority/var/lib/ca/.keep-it deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dists/examples/1.Authority/var/lib/wallet/.keep-it b/dists/examples/1.Authority/var/lib/wallet/.keep-it deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dists/examples/1.Authority/var/log/.keep-it b/dists/examples/1.Authority/var/log/.keep-it deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/dists/examples/plugins/demoCustomCMD/__pycache__/demoCustomCMD.cpython-39.pyc b/dists/examples/plugins/demoCustomCMD/__pycache__/demoCustomCMD.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30945060df00ff47bd9d7d39f2ff158f21cc9c04 Binary files /dev/null and b/dists/examples/plugins/demoCustomCMD/__pycache__/demoCustomCMD.cpython-39.pyc differ diff --git a/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py b/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py new file mode 100644 index 0000000000000000000000000000000000000000..cd1eb93184466957efc054605ca7c8613d44f7bc --- /dev/null +++ b/dists/examples/plugins/demoCustomCMD/demoCustomCMD.py @@ -0,0 +1,34 @@ +from API_CellFrame import logItNotice, AppCliServer + +""" +This function takes two arguments +argv is an array of incoming arguments +indexStrReply is an internal index that correlates what is needed + to fill the desired buffer with the data that will be passed to the CLI. +""" +def cmdDemo(argv, indexStrReply): + reply = "Arguments :\n" + for i in range(len(argv)): + reply += "arg["+str(i)+"]: "+argv[i]+"\n" + AppCliServer.setReplyText(reply, indexStrReply) + +def cmdDemo2(argv, indexStrReply): + AppCliServer.setReplyText("I simple demo command", indexStrReply) + +def init(): + logItNotice("Running plugin order") + """ + The cmdItemCreate function creates a CLI command. + This function takes four arguments. + Command name, command handler function, short description of + of the command, full description of the command. + """ + AppCliServer.cmdItemCreate("demo", cmdDemo, "Command demo", +""" + This command is intended to demonstrate the work of custom command in the CellFrame API for Python. +""") + AppCliServer.cmdItemCreate("demo2", cmdDemo2, "Second command demo", +""" + This is demo and testing +""") + return 0 diff --git a/dists/examples/plugins/demoCustomCMD/manifest.json b/dists/examples/plugins/demoCustomCMD/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..bf34c36336b6dea0c6e717989145cc0afb042263 --- /dev/null +++ b/dists/examples/plugins/demoCustomCMD/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "demoCustomCMD", + "version": "1.0", + "author": "DEMLABS (C) 2022", + "dependencys": [], + "description": "This is a plugin example for working custom command." +} + diff --git a/dists/examples/plugins/demoOrder/demoOrder.py b/dists/examples/plugins/demoOrder/demoOrder.py new file mode 100644 index 0000000000000000000000000000000000000000..85397d2ad095f2d3a9b550d15bf853ec66deb308 --- /dev/null +++ b/dists/examples/plugins/demoOrder/demoOrder.py @@ -0,0 +1,169 @@ +from API_CellFrame import logItNotice, ChainNetSrvOrder, ChainNet, ChainNetSrvUID, ChainNetSrvOrderDirection, ChainNetSrvPriceUnitUID +from API_CellFrame import Crypto, CryptoKeyType, AppCliServer, ChainHashFast +import time +from datetime import datetime, timedelta + +def infoOrder(order): +# hash = ChainHashFast.strToHashFast(hash_str) +# order = ChainNetSrvOrder.find(net, hash_str) + reply = "Order: \n" + reply += "\tVersion:" + str(order.version)+"\n" + reply += "\tUID: " + str(order.uid) + "\n" + reply += "\tDirection: " + str(order.direction) + "\n" + reply += "\tNode addr: " + str(order.nodeAddr) + "\n" + reply += "\tCond hash: " + str(order.condHash) + "\n" + reply += "\tPrice unit: " + str(order.priceUnit) + "\n" + created = datetime.fromtimestamp(order.tsCreated) + reply += "\tCreated: " + str(created) + "\n" + expires = datetime.fromtimestamp(order.tsExpires) + reply += "\tExpires: " + str(expires) + "\n" + reply += "\tSrv price: " + str(order.srvPrice) + "\n" + reply += "\tSrv price ticker: " + order.srvPriceTicker + "\n" + reply += "\textSignSize:" + str(order.extSize) + "\n" + reply += "\tSignature:\n" + sign = order.extSign + if sign is None: + reply += "Signature none" + else: + type = sign.type + pkey = sign.pkey + pkey_type = pkey.type + # pkey_hash = pkey.hash + pkey_size = pkey.size + pkey_dict = { + 'type': str(pkey_type), + 'size': pkey_size + } + pkey_hash = sign.pkeyHash + sig_dict = { + 'type': str(sign.type), + 'pkey': pkey_dict, + 'pkey_hash': str(pkey_hash), + 'size': str(sign.size) + } + reply += str(sig_dict) +# reply += "\Signs:" + str(order.ext) + "\n" + return reply + +def pwoCMD(argv, indexStrReply): + print(indexStrReply) + if (len(argv) == 5): + net = ChainNet.byName(argv[2]) + if argv[3] == "find": + order = ChainNetSrvOrder.find(net, argv[4]) + reply = "" + if order is None: + reply = "Order with hash "+argv[4]+" not fined." + else: + reply = "Order: \n" + order_reply = infoOrder(order) + reply += order_reply + # reply += "\tVersion:" + str(order.version)+"\n" +# reply += "\tUID: " + str(order.uid) + "\n" +# reply += "\tDirection: " + str(order.direction) + "\n" +# reply += "\tNode addr: " + str(order.nodeAddr) + "\n" +## reply += "\tCond hash: " + str(order.condHash) + "\n" +# reply += "\tPrice unit: " + str(order.priceUnit) + "\n" +# created = datetime.fromtimestamp(order.tsCreated) +# reply += "\tCreated: " + str(created) + "\n" +# expires = datetime.fromtimestamp(order.tsExpires) +# reply += "\tExpires: " + str(expires) + "\n" +# reply += "\tSrv price: " + str(order.srvPrice) + "\n" +# reply += "\tSrv price ticker: " + order.srvPriceTicker + "\n" +# reply += "\text size:" + str(order.extSize) + "\n" +# reply += "\text:" + str(order.ext) + "\n" + AppCliServer.setReplyText(reply, indexStrReply) + elif argv[3] == "del": + res = ChainNetSrvOrder.delete(net, argv[4]) + AppCliServer.setReplyText("Result: "+str(res)+".", indexStrReply) + else: + AppCliServer.setReplyText("An unknown action is specified to be performerd on the order.", indexStrReply) + else: + AppCliServer.setReplyText("This command takes only four arguments.", indexStrReply) + + + +def infoCMD(argv, indexStrReply): + if (len(argv) == 2): + hash = ChainHashFast.strToHashFast(argv[1]) + order = ChainNetSrvOrder.find(hash) + reply = "Order: \n" + order_reply = infoOrder(order) + reply += order_reply +# reply += "\tVersion:" + str(order.version)+"\n" +# reply += "\tUID: " + str(order.uid) + "\n" +# reply += "\tDirection: " + str(order.direction) + "\n" +# reply += "\tNode addr: " + str(order.nodeAddr) + "\n" +# reply += "\tCond hash: " + str(order.condHash) + "\n" +# reply += "\tPrice unit: " + str(order.priceUnit) + "\n" +# created = datetime.fromtimestamp(order.tsCreated) +# reply += "\tCreated: " + str(created) + "\n" +# expires = datetime.fromtimestamp(order.tsExpires) +# reply += "\tExpires: " + str(expires) + "\n" +# reply += "\tSrv price: " + str(order.srvPrice) + "\n" +# reply += "\tSrv price ticker: " + order.srvPriceTicker + "\n" +# reply += "\text size:" + str(order.extSize) + "\n" +# reply += "\text:" + str(order.ext) + "\n" + AppCliServer.setReplyText(reply, indexStrReply) + else: + AppCliServer.setReplyText("Order hash not set", indexStrReply) + +""" + +""" + +def create_key(): + return Crypto.generateNewKey(CryptoKeyType.DAP_ENC_KEY_TYPE_SIG_BLISS(), "SARON00151454_VDGTKHJFY", 512, " I SIMPKLE SEED STRING ") + +def order_notify(op_code, group, key, order): + print("Notify: \n") + print("op_code: "+op_code+"\n") + print("group: "+group+"\n") + print("key: "+key+"\n") + if order is not None: + print(infoOrder(order)) + else: + print("No order.") + +def init(): + logItNotice("Running plugin order") + net = ChainNet.byName("kelvin-testnet") +#Getting info + ChainNetSrvOrder.addNotify(net, order_notify) + gdb_group = ChainNetSrvOrder.getGdbGroup(net) + logItNotice("Ordr in group: "+gdb_group) + node_list_group = ChainNetSrvOrder.getNodelistGroup(net) + logItNotice("Node list group: "+node_list_group) +#Create order + print("net: "+ str(net)) + net_srv = ChainNetSrvUID(12345) + direction = ChainNetSrvOrderDirection.getDirSell() + print("direction" + str(direction)) + node_addr = net.getCurAddr() + tx_cond = "TXCOND" + price = 531 + priceUnitUid = ChainNetSrvPriceUnitUID.mb() + print ("Price Unit UID:" + str(priceUnitUid)) + key = create_key() + #Expires + dt_exp = datetime.now() + dt_delta = timedelta(days = 30) + dt_exp += dt_delta + print (dt_exp) + print (dt_exp.timestamp()) + ts_expires = dt_exp.timestamp() + print(type(ts_expires)) + order = ChainNetSrvOrder(net, direction, net_srv, node_addr, None, 100, priceUnitUid, "tCELL", ts_expires, "http://myvi.com/?QBS".encode('utf-8'), key) + hash = order.save(net) + logItNotice("HASH order:"+str(hash)) + AppCliServer.cmdItemCreate("pwo", pwoCMD, "Example command for working with orders through the plugin", +""" + Arguments for command: + net <net> find <hash order> + net <net> del <hash order> +""") + return 0 + +#def deinit(): +# logItNotice("Plugin client deinit") + diff --git a/dists/examples/plugins/demoOrder/manifest.json b/dists/examples/plugins/demoOrder/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..5ce8cb56306946d749ec9c7d385b09a3c55ed92f --- /dev/null +++ b/dists/examples/plugins/demoOrder/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "demoOrder", + "version": "1.0", + "author": "DEMLABS (C) 2022", + "dependencys": [], + "description": "This is a plugin with examples for working with orders." +} + diff --git a/dists/examples/plugins/exampleCreateTx/__pycache__/exampleCreateTx.cpython-39.pyc b/dists/examples/plugins/exampleCreateTx/__pycache__/exampleCreateTx.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7990e721a45d87bd5cf65a6c36790bff05fd7599 Binary files /dev/null and b/dists/examples/plugins/exampleCreateTx/__pycache__/exampleCreateTx.cpython-39.pyc differ diff --git a/dists/examples/plugins/exampleCreateTx/exampleCreateTx.py b/dists/examples/plugins/exampleCreateTx/exampleCreateTx.py new file mode 100644 index 0000000000000000000000000000000000000000..0a36f256751027b36e4ad7347fbd1ea2748598ff --- /dev/null +++ b/dists/examples/plugins/exampleCreateTx/exampleCreateTx.py @@ -0,0 +1,19 @@ +from API_CellFrame import Mempool, ChainWallet, logItNotice, configGetItem, ChainNet, ChainAddr + +def init(): + wallet_path = configGetItem("resources", "wallets_path") + logItNotice("wallet path: "+wallet_path) + wallet = ChainWallet.open("mywallet1", wallet_path) + chain_net = ChainNet.byName("subzero") + chain = chain_net.getChainByName("support") + key = wallet.getKey(0) + addr_from = wallet.getAddr(chain_net.id) + addr_to = ChainAddr.fromStr("mJUUJk6Yk2gBSTjcCmbwJ2ozjDTLPKZTmTVM9AUysMfWt4oQcNwjtCNEbkGo1dWVmkNXaQYbPtMqdHD4ftF5Sfx4mo9ss9r4jauSXDhV") + addr_fee = None + value = 50000 + value_fee = 0 +# tx_hash = Mempool.txCreate(chain, key, addr_from, addr_to, addr_fee, "tCELL", value, value_fee) +# tx_hash_str = str(tx_hash) +# print(tx_hash_str) +# logItNotice("Created transaction with hash: " + tx_hash_str) + return 0 diff --git a/dists/examples/plugins/exampleCreateTx/manifest.json b/dists/examples/plugins/exampleCreateTx/manifest.json new file mode 100644 index 0000000000000000000000000000000000000000..38a328aa5788bbbf07c41a707911cbedb36622a2 --- /dev/null +++ b/dists/examples/plugins/exampleCreateTx/manifest.json @@ -0,0 +1,8 @@ +{ + "name": "exampleCreateTx", + "version": "1.0", + "author": "DEMLABS (C) 2022", + "dependencys": [], + "description": "This plugin is an example of a service plugin." +} + diff --git a/dists/examples/0.Beginning/.gitignore b/dists/examples/standalone/0.Beginning/.gitignore similarity index 100% rename from dists/examples/0.Beginning/.gitignore rename to dists/examples/standalone/0.Beginning/.gitignore diff --git a/dists/examples/0.Beginning/CMakeLists.txt b/dists/examples/standalone/0.Beginning/CMakeLists.txt similarity index 100% rename from dists/examples/0.Beginning/CMakeLists.txt rename to dists/examples/standalone/0.Beginning/CMakeLists.txt diff --git a/dists/examples/0.Beginning/MyChains.py b/dists/examples/standalone/0.Beginning/MyChains.py similarity index 100% rename from dists/examples/0.Beginning/MyChains.py rename to dists/examples/standalone/0.Beginning/MyChains.py diff --git a/dists/examples/0.Beginning/MyChainsCli.py b/dists/examples/standalone/0.Beginning/MyChainsCli.py similarity index 100% rename from dists/examples/0.Beginning/MyChainsCli.py rename to dists/examples/standalone/0.Beginning/MyChainsCli.py diff --git a/dists/examples/1.Authority/.gitignore b/dists/examples/standalone/1.Authority/.gitignore similarity index 100% rename from dists/examples/1.Authority/.gitignore rename to dists/examples/standalone/1.Authority/.gitignore diff --git a/dists/examples/1.Authority/MyAuth.py b/dists/examples/standalone/1.Authority/MyAuth.py similarity index 100% rename from dists/examples/1.Authority/MyAuth.py rename to dists/examples/standalone/1.Authority/MyAuth.py diff --git a/dists/examples/1.Authority/MyAuthCA.py b/dists/examples/standalone/1.Authority/MyAuthCA.py similarity index 100% rename from dists/examples/1.Authority/MyAuthCA.py rename to dists/examples/standalone/1.Authority/MyAuthCA.py diff --git a/dists/examples/1.Authority/MyAuthCli.py b/dists/examples/standalone/1.Authority/MyAuthCli.py similarity index 100% rename from dists/examples/1.Authority/MyAuthCli.py rename to dists/examples/standalone/1.Authority/MyAuthCli.py diff --git a/dists/examples/1.Authority/MyAuthCmd.py b/dists/examples/standalone/1.Authority/MyAuthCmd.py similarity index 100% rename from dists/examples/1.Authority/MyAuthCmd.py rename to dists/examples/standalone/1.Authority/MyAuthCmd.py diff --git a/dists/examples/1.Authority/MyAuthConf.py b/dists/examples/standalone/1.Authority/MyAuthConf.py similarity index 100% rename from dists/examples/1.Authority/MyAuthConf.py rename to dists/examples/standalone/1.Authority/MyAuthConf.py diff --git a/dists/examples/10.Warehouse/MyChains.py b/dists/examples/standalone/10.Warehouse/MyChains.py similarity index 100% rename from dists/examples/10.Warehouse/MyChains.py rename to dists/examples/standalone/10.Warehouse/MyChains.py diff --git a/dists/examples/10.Warehouse/MyChainsCli.py b/dists/examples/standalone/10.Warehouse/MyChainsCli.py similarity index 100% rename from dists/examples/10.Warehouse/MyChainsCli.py rename to dists/examples/standalone/10.Warehouse/MyChainsCli.py diff --git a/dists/examples/10.Warehouse/MyChainsConf.py b/dists/examples/standalone/10.Warehouse/MyChainsConf.py similarity index 100% rename from dists/examples/10.Warehouse/MyChainsConf.py rename to dists/examples/standalone/10.Warehouse/MyChainsConf.py diff --git a/dists/examples/2.Exchange/MyExchange.py b/dists/examples/standalone/2.Exchange/MyExchange.py similarity index 100% rename from dists/examples/2.Exchange/MyExchange.py rename to dists/examples/standalone/2.Exchange/MyExchange.py diff --git a/dists/examples/2.Exchange/MyExchangeConf.py b/dists/examples/standalone/2.Exchange/MyExchangeConf.py similarity index 100% rename from dists/examples/2.Exchange/MyExchangeConf.py rename to dists/examples/standalone/2.Exchange/MyExchangeConf.py diff --git a/dists/examples/2.Exchange/Settings.py b/dists/examples/standalone/2.Exchange/Settings.py similarity index 100% rename from dists/examples/2.Exchange/Settings.py rename to dists/examples/standalone/2.Exchange/Settings.py diff --git a/dists/examples/3.Stock/.gitignore b/dists/examples/standalone/3.Stock/.gitignore similarity index 100% rename from dists/examples/3.Stock/.gitignore rename to dists/examples/standalone/3.Stock/.gitignore diff --git a/dists/examples/3.Stock/CMakeLists.txt b/dists/examples/standalone/3.Stock/CMakeLists.txt similarity index 100% rename from dists/examples/3.Stock/CMakeLists.txt rename to dists/examples/standalone/3.Stock/CMakeLists.txt diff --git a/dists/examples/3.Stock/MyStock.py b/dists/examples/standalone/3.Stock/MyStock.py similarity index 100% rename from dists/examples/3.Stock/MyStock.py rename to dists/examples/standalone/3.Stock/MyStock.py diff --git a/dists/examples/3.Stock/MyStockCli.py b/dists/examples/standalone/3.Stock/MyStockCli.py similarity index 100% rename from dists/examples/3.Stock/MyStockCli.py rename to dists/examples/standalone/3.Stock/MyStockCli.py diff --git a/dists/examples/3.Stock/MyStockCmd.py b/dists/examples/standalone/3.Stock/MyStockCmd.py similarity index 100% rename from dists/examples/3.Stock/MyStockCmd.py rename to dists/examples/standalone/3.Stock/MyStockCmd.py diff --git a/dists/examples/3.Stock/MyStockConf.py b/dists/examples/standalone/3.Stock/MyStockConf.py similarity index 100% rename from dists/examples/3.Stock/MyStockConf.py rename to dists/examples/standalone/3.Stock/MyStockConf.py diff --git a/dists/examples/3.Stock/MyStockInitCA.py b/dists/examples/standalone/3.Stock/MyStockInitCA.py similarity index 100% rename from dists/examples/3.Stock/MyStockInitCA.py rename to dists/examples/standalone/3.Stock/MyStockInitCA.py diff --git a/dists/examples/3.Stock/test.sh b/dists/examples/standalone/3.Stock/test.sh similarity index 100% rename from dists/examples/3.Stock/test.sh rename to dists/examples/standalone/3.Stock/test.sh diff --git a/dists/examples/4.Logistic/MyChains.py b/dists/examples/standalone/4.Logistic/MyChains.py similarity index 100% rename from dists/examples/4.Logistic/MyChains.py rename to dists/examples/standalone/4.Logistic/MyChains.py diff --git a/dists/examples/4.Logistic/MyChainsCli.py b/dists/examples/standalone/4.Logistic/MyChainsCli.py similarity index 100% rename from dists/examples/4.Logistic/MyChainsCli.py rename to dists/examples/standalone/4.Logistic/MyChainsCli.py diff --git a/dists/examples/4.Logistic/MyChainsConf.py b/dists/examples/standalone/4.Logistic/MyChainsConf.py similarity index 100% rename from dists/examples/4.Logistic/MyChainsConf.py rename to dists/examples/standalone/4.Logistic/MyChainsConf.py diff --git a/dists/examples/5.Excise/MyChains.py b/dists/examples/standalone/5.Excise/MyChains.py similarity index 100% rename from dists/examples/5.Excise/MyChains.py rename to dists/examples/standalone/5.Excise/MyChains.py diff --git a/dists/examples/5.Excise/MyChainsCli.py b/dists/examples/standalone/5.Excise/MyChainsCli.py similarity index 100% rename from dists/examples/5.Excise/MyChainsCli.py rename to dists/examples/standalone/5.Excise/MyChainsCli.py diff --git a/dists/examples/5.Excise/MyChainsConf.py b/dists/examples/standalone/5.Excise/MyChainsConf.py similarity index 100% rename from dists/examples/5.Excise/MyChainsConf.py rename to dists/examples/standalone/5.Excise/MyChainsConf.py diff --git a/dists/examples/6.Issues/MyChains.py b/dists/examples/standalone/6.Issues/MyChains.py similarity index 100% rename from dists/examples/6.Issues/MyChains.py rename to dists/examples/standalone/6.Issues/MyChains.py diff --git a/dists/examples/6.Issues/MyChainsCli.py b/dists/examples/standalone/6.Issues/MyChainsCli.py similarity index 100% rename from dists/examples/6.Issues/MyChainsCli.py rename to dists/examples/standalone/6.Issues/MyChainsCli.py diff --git a/dists/examples/6.Issues/MyChainsConf.py b/dists/examples/standalone/6.Issues/MyChainsConf.py similarity index 100% rename from dists/examples/6.Issues/MyChainsConf.py rename to dists/examples/standalone/6.Issues/MyChainsConf.py diff --git a/dists/examples/7.WorkTrack/MyChains.py b/dists/examples/standalone/7.WorkTrack/MyChains.py similarity index 100% rename from dists/examples/7.WorkTrack/MyChains.py rename to dists/examples/standalone/7.WorkTrack/MyChains.py diff --git a/dists/examples/7.WorkTrack/MyChainsCli.py b/dists/examples/standalone/7.WorkTrack/MyChainsCli.py similarity index 100% rename from dists/examples/7.WorkTrack/MyChainsCli.py rename to dists/examples/standalone/7.WorkTrack/MyChainsCli.py diff --git a/dists/examples/7.WorkTrack/MyChainsConf.py b/dists/examples/standalone/7.WorkTrack/MyChainsConf.py similarity index 100% rename from dists/examples/7.WorkTrack/MyChainsConf.py rename to dists/examples/standalone/7.WorkTrack/MyChainsConf.py diff --git a/dists/examples/8.Support/MyChains.py b/dists/examples/standalone/8.Support/MyChains.py similarity index 100% rename from dists/examples/8.Support/MyChains.py rename to dists/examples/standalone/8.Support/MyChains.py diff --git a/dists/examples/8.Support/MyChainsCli.py b/dists/examples/standalone/8.Support/MyChainsCli.py similarity index 100% rename from dists/examples/8.Support/MyChainsCli.py rename to dists/examples/standalone/8.Support/MyChainsCli.py diff --git a/dists/examples/8.Support/MyChainsConf.py b/dists/examples/standalone/8.Support/MyChainsConf.py similarity index 100% rename from dists/examples/8.Support/MyChainsConf.py rename to dists/examples/standalone/8.Support/MyChainsConf.py diff --git a/dists/examples/9.Accounting/MyChains.py b/dists/examples/standalone/9.Accounting/MyChains.py similarity index 100% rename from dists/examples/9.Accounting/MyChains.py rename to dists/examples/standalone/9.Accounting/MyChains.py diff --git a/dists/examples/9.Accounting/MyChainsCli.py b/dists/examples/standalone/9.Accounting/MyChainsCli.py similarity index 100% rename from dists/examples/9.Accounting/MyChainsCli.py rename to dists/examples/standalone/9.Accounting/MyChainsCli.py diff --git a/dists/examples/9.Accounting/MyChainsConf.py b/dists/examples/standalone/9.Accounting/MyChainsConf.py similarity index 100% rename from dists/examples/9.Accounting/MyChainsConf.py rename to dists/examples/standalone/9.Accounting/MyChainsConf.py diff --git a/dists/examples/CMakeLists.txt b/dists/examples/standalone/CMakeLists.txt similarity index 100% rename from dists/examples/CMakeLists.txt rename to dists/examples/standalone/CMakeLists.txt diff --git a/include/python-cellframe.h b/include/python-cellframe.h index ddd69dd0c59b3f9a077ef42e1b194da427582d93..7ee16c65548a177ca0946f98adc85ad59e0314ab 100644 --- a/include/python-cellframe.h +++ b/include/python-cellframe.h @@ -41,6 +41,8 @@ #include "wrapping_dap_chain_net_srv.h" #include "wrapping_dap_chain_net_srv_client.h" #include "wrapping_dap_chain_net_srv_datum.h" +#include "wrapping_dap_chain_net_srv_common.h" +#include "wrapping_dap_chain_net_srv_order.h" // ============ diff --git a/include/wrapping_dap_mempool.h b/include/wrapping_dap_mempool.h index 8b637e344979f070249d8b9efb386458ea87b523..a51064ec0a2119fea1b35593dad652b4666208db 100644 --- a/include/wrapping_dap_mempool.h +++ b/include/wrapping_dap_mempool.h @@ -5,15 +5,20 @@ #include "dap_chain_mempool.h" #include "dap_server_python.h" #include "dap_http.h" +#include "libdap-chain-python.h" +#include "wrapping_dap_pkey.h" +#include "wrapping_dap_chain_common.h" typedef struct PyDapMempool{ PyObject_HEAD }PyDapMempoolObject; PyObject *dap_chain_mempool_add_proc_py(PyObject *self, PyObject *args); +PyObject *dap_chain_mempool_tx_create_py(PyObject *self, PyObject *args); static PyMethodDef DapMempoolMethods[] = { {"addProc", dap_chain_mempool_add_proc_py, METH_VARARGS | METH_STATIC, ""}, + {"txCreate", dap_chain_mempool_tx_create_py, METH_VARARGS | METH_STATIC, ""}, {NULL,NULL,0,NULL} }; diff --git a/modules/cellframe-sdk/app-cli/include/libdap-app-cli-python.h b/modules/cellframe-sdk/app-cli/include/libdap-app-cli-python.h index 4d555157448a59161e86dc3b0a67523c433c6e88..2602470b40346f7b251f3d5fa23596c3b64b8343 100644 --- a/modules/cellframe-sdk/app-cli/include/libdap-app-cli-python.h +++ b/modules/cellframe-sdk/app-cli/include/libdap-app-cli-python.h @@ -14,60 +14,4 @@ typedef struct PyAppCli{ PyObject* dap_app_cli_main_py(PyObject *self, PyObject *args); -static PyMethodDef AppCliMethods[] = { - {"main", dap_app_cli_main_py, METH_VARARGS | METH_STATIC, "Main CLI function"}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapAppCli_dapAppCliType = { - PyVarObject_HEAD_INIT(NULL, 0) - "AppCli", /* tp_name */ - sizeof(PyAppCliObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "AppCli object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - AppCliMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc*/ - 0, /* tp_bases*/ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag*/ - 0, /* tp_finalize*/ -}; - +extern PyTypeObject DapAppCli_dapAppCliType; diff --git a/modules/cellframe-sdk/app-cli/src/libdap-app-cli-python.c b/modules/cellframe-sdk/app-cli/src/libdap-app-cli-python.c index c4643ada50aa424b2a28e9fcda6fb705fef7095b..5c94ed103b8416a90aabe942c888f666450538d9 100644 --- a/modules/cellframe-sdk/app-cli/src/libdap-app-cli-python.c +++ b/modules/cellframe-sdk/app-cli/src/libdap-app-cli-python.c @@ -3,6 +3,63 @@ #define LOG_TAG "libdap-app-cli-crypto" +PyMethodDef AppCliMethods[] = { + {"main", dap_app_cli_main_py, METH_VARARGS | METH_STATIC, "Main CLI function"}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapAppCli_dapAppCliType = { + PyVarObject_HEAD_INIT(NULL, 0) + "AppCli", /* tp_name */ + sizeof(PyAppCliObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "AppCli object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + AppCliMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc*/ + 0, /* tp_bases*/ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag*/ + 0, /* tp_finalize*/ +}; + /** * @brief dap_app_cli_main_py * @param self diff --git a/modules/cellframe-sdk/chain/include/libdap-chain-python.h b/modules/cellframe-sdk/chain/include/libdap-chain-python.h index 835181f69bf2c31ebd4b761f286275e7ada897b9..dceaefd8b0dea3756456dc5d1c9d0978af890780 100644 --- a/modules/cellframe-sdk/chain/include/libdap-chain-python.h +++ b/modules/cellframe-sdk/chain/include/libdap-chain-python.h @@ -42,70 +42,10 @@ PyObject *dap_chain_python_atom_get_datums(PyObject *self, PyObject *args); PyObject *dap_chain_python_atom_iter_get_next(PyObject *self, PyObject *args); PyObject *dap_chain_python_atom_iter_get_dag(PyObject *self, PyObject *args); -static PyMethodDef DapChainMethods[] = { - {"findById", (PyCFunction)dap_chain_find_by_id_py, METH_VARARGS|METH_STATIC, ""}, - {"loadFromCfg", (PyCFunction)dap_chain_load_from_cfg_py, METH_VARARGS|METH_STATIC, ""}, - {"hasFileStore", (PyCFunction)dap_chain_has_file_store_py, METH_NOARGS, ""}, - {"saveAll", (PyCFunction) dap_chain_save_all_py, METH_NOARGS, ""}, - {"loadAll", (PyCFunction)dap_chain_load_all_py, METH_NOARGS, ""}, - {"createAtomItem", (PyCFunction) dap_chain_python_create_atom_iter, METH_VARARGS, ""}, - {"atomIterGetFirst", (PyCFunction) dap_chain_python_atom_iter_get_first, METH_VARARGS, ""}, - {"atomGetDatums", (PyCFunction) dap_chain_python_atom_get_datums, METH_VARARGS, ""}, - {"atomIterGetNext", (PyCFunction)dap_chain_python_atom_iter_get_next, METH_VARARGS, ""}, - {"getDag", (PyCFunction)dap_chain_python_atom_iter_get_dag, METH_NOARGS}, - //{"close", (PyCFunction)dap_chain_close_py, METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject dapChainObject_dapChainType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain", /* tp_name */ - sizeof(PyDapChainObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PyDapChainObject_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyDapChainObject_new, /* tp_new */ - -}; +extern PyTypeObject dapChainObject_dapChainType; static inline bool PyDapChain_Check(PyObject* self){ - if (PyObject_TypeCheck(self, &dapChainObject_dapChainType) == 0){ - return true; - } else { - return false; - } + return PyObject_TypeCheck(self, &dapChainObject_dapChainType); } diff --git a/modules/cellframe-sdk/chain/include/libdap_chain_atom_iter_python.h b/modules/cellframe-sdk/chain/include/libdap_chain_atom_iter_python.h index 27171414983266c5dff57bf0737d3d97cb109a91..ed2d5ed61ee4ca5c0ffd4ae1e4df938ff312bebe 100644 --- a/modules/cellframe-sdk/chain/include/libdap_chain_atom_iter_python.h +++ b/modules/cellframe-sdk/chain/include/libdap_chain_atom_iter_python.h @@ -12,56 +12,9 @@ typedef struct PyChainAtomIter{ dap_chain_atom_iter_t *atom_iter; } PyChainAtomIterObject; -static PyMethodDef DapChainAtomIterMethods[] = { - {NULL, NULL, 0, NULL} -}; +extern PyTypeObject DapChainAtomIter_DapChainAtomIterType; -static PyTypeObject DapChainAtomIter_DapChainAtomIterType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.AtomIter", /* tp_name */ - sizeof(PyChainAtomIterObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain atom iter objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainAtomIterMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; - -static bool PyDapChainAtomIter_Check(PyObject *obj){ - return PyObject_TypeCheck(obj, &DapChainAtomIter_DapChainAtomIterType); -} +bool PyDapChainAtomIter_Check(PyObject *obj); #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/chain/include/libdap_chain_type_python.h b/modules/cellframe-sdk/chain/include/libdap_chain_type_python.h index e5eddcda619d98c3a7dcbad34d892e39bd7f8f9b..4c6d3f7f4cc3acb6d7ef269017081f3279b03df6 100644 --- a/modules/cellframe-sdk/chain/include/libdap_chain_type_python.h +++ b/modules/cellframe-sdk/chain/include/libdap_chain_type_python.h @@ -18,57 +18,7 @@ PyObject* CHAIN_TYPE_EMISSION_PY(); PyObject* CHAIN_TYPE_TX_PY(); PyObject* CHAIN_TYPE_LAST_PY(); -static PyMethodDef DapChainTypeMethods[] = { - {"CHAIN_TYPE_FIRST", (PyCFunction)CHAIN_TYPE_FIRST_PY, METH_NOARGS|METH_STATIC, ""}, - {"CHAIN_TYPE_TOKEN", (PyCFunction)CHAIN_TYPE_TOKEN_PY, METH_NOARGS|METH_STATIC, ""}, - {"CHAIN_TYPE_EMISSION", (PyCFunction)CHAIN_TYPE_EMISSION_PY, METH_NOARGS|METH_STATIC, ""}, - {"CHAIN_TYPE_TX", (PyCFunction)CHAIN_TYPE_TX_PY, METH_NOARGS|METH_STATIC, ""}, - {"CHAIN_TYPE_LAST", (PyCFunction)CHAIN_TYPE_LAST_PY, METH_NOARGS|METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject dapChainTypeObject_dapChainTypeType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainType", /* tp_name */ - sizeof(PyChainTypeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain type objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainTypeMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; +extern PyTypeObject dapChainTypeObject_dapChainTypeType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_atom_ptr.h b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_atom_ptr.h index 6789b403704122c66e15f30f52ee5cd848c89e28..777a1c112c8f0308a570b91859d00f0e57a5128f 100644 --- a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_atom_ptr.h +++ b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_atom_ptr.h @@ -12,52 +12,9 @@ typedef struct PyChainAtomPtr{ dap_chain_atom_ptr_t ptr; }PyChainAtomPtrObject; -static PyMethodDef DapChainAtomPtrMethods[] = { - {NULL, NULL, 0, NULL} -}; +extern PyTypeObject DapChainAtomPtr_DapChainAtomPtrType; -static PyTypeObject DapChainAtomPtr_DapChainAtomPtrType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.AtomPtr", /* tp_name */ - sizeof(PyChainAtomPtrObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain atom ptr objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainAtomPtrMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; +bool PyDapChainAtomIter_Check(PyObject *obj); #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cell.h b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cell.h index ad654eaa4445fa3dfd5c6b017b0f154b827cda46..0211f0d1605496c694f4d326b90dea526100229b 100644 --- a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cell.h +++ b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cell.h @@ -23,54 +23,7 @@ PyObject *dap_chain_cell_load_py(PyObject *self, PyObject *args); PyObject *dap_chain_cell_file_update_py(PyObject *self, PyObject *args); PyObject *dap_chain_cell_file_append_py(PyObject *self, PyObject *args); -static PyMethodDef PyDapChainCellObjectMethods[] ={ - {"load", dap_chain_cell_load_py, METH_VARARGS | METH_STATIC, ""}, - {"update", dap_chain_cell_file_update_py, METH_VARARGS, ""}, - {"append", dap_chain_cell_file_append_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainCell_DapChainCellObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Cell", /* tp_name */ - sizeof(PyDapChainCellObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cell object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainCellObjectMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainCell_DapChainCellObjectType; static bool PyDapChainCell_Check(PyObject *self){ return PyObject_TypeCheck(self, &DapChainCell_DapChainCellObjectType); @@ -83,94 +36,14 @@ typedef struct PyDapChainCellDeclReq{ dap_chain_cell_decl_req_t *decl_req; }PyDapChainCellDeclReqObject; -static PyTypeObject DapChainCellDeclReq_DapChainCellDeclReqObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.DapChainCellDeclReq", /* tp_name */ - sizeof(PyDapChainCellDeclReqObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cell decl req object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainCellDeclReq_DapChainCellDeclReqObjectType; typedef struct PyDapChainCellDecl{ PyObject_HEAD dap_chain_cell_decl_t* decl; }PyDapChainDeclObject; -static PyTypeObject DapChainDecl_DapChainDeclObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.DapChainCellDecl", /* tp_name */ - sizeof(PyDapChainDeclObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cell decl object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainDecl_DapChainDeclObjectType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cs.h b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cs.h index 2ddf02f33d16a31b6829c21a04fd49c3bb9979bb..90e69ca8e4b231372909a64ddd8b89e17a52c822 100644 --- a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cs.h +++ b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_cs.h @@ -27,56 +27,7 @@ PyObject *dap_chain_cs_create_py(PyObject *self, PyObject *args); PyObject *dap_chain_class_add_py (PyObject *self, PyObject *args); PyObject *dap_chain_class_create_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainCSMethods[] = { - {"csAdd", (PyCFunction)dap_chain_cs_add_py, METH_VARARGS, ""}, - {"csCreate", (PyCFunction)dap_chain_cs_create_py, METH_VARARGS, ""}, - {"classAdd", (PyCFunction)dap_chain_class_add_py, METH_VARARGS, ""}, - {"classCreate", (PyCFunction)dap_chain_class_create_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainCsObject_DapChainCsObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.CS", /* tp_name */ - sizeof(PyDapChainCsObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cs object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainCSMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - DapChainCSObject_new, /* tp_new */ -}; - +extern PyTypeObject DapChainCsObject_DapChainCsObjectType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_ledger.h b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_ledger.h index 51a47d75ab6a303166056428585f64d5b5c54f4a..4d82b1fc72080781cf886295cd38bdc3c5b5c330 100644 --- a/modules/cellframe-sdk/chain/include/wrapping_dap_chain_ledger.h +++ b/modules/cellframe-sdk/chain/include/wrapping_dap_chain_ledger.h @@ -49,76 +49,7 @@ PyObject *dap_chain_ledger_tx_find_by_pkey_py(PyObject *self, PyObject *args); PyObject *dap_chain_ledger_tx_cache_find_out_cond_py(PyObject *self, PyObject *args); PyObject *dap_chain_ledger_tx_cache_get_out_cond_value_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainLedgerMethods[] = { - {"setLocalCellId", (PyCFunction)dap_chain_ledger_set_local_cell_id_py, METH_VARARGS, ""}, - {"nodeDatumTxCalcHash", (PyCFunction)dap_chain_node_datum_tx_calc_hash_py, METH_VARARGS, ""}, - {"txAdd", (PyCFunction)dap_chain_ledger_tx_add_py, METH_VARARGS, ""}, - {"tokenAdd", (PyCFunction)dap_chain_ledger_token_add_py, METH_VARARGS, ""}, - {"tokenEmissionAdd", (PyCFunction)dap_chain_ledger_token_emission_add_py, METH_VARARGS, ""}, - {"tokenEmissionFind", (PyCFunction)dap_chain_ledger_token_emission_find_py, METH_VARARGS, ""}, - {"txGetTokenTickerByHash", (PyCFunction)dap_chain_ledger_tx_get_token_ticker_by_hash_py, METH_VARARGS, ""}, - {"addrGetTokenTickerAll", (PyCFunction)dap_chain_ledger_addr_get_token_ticker_all_py, METH_VARARGS, ""}, - {"addrGetTokenTickerAllFast", (PyCFunction)dap_chain_ledger_addr_get_token_ticker_all_fast_py, METH_VARARGS, ""}, - {"txCacheCheck", (PyCFunction)dap_chain_ledger_tx_cache_check_py, METH_VARARGS, ""}, - {"datumTxCacheCheck", (PyCFunction)dap_chain_node_datum_tx_cache_check_py, METH_VARARGS, ""}, - {"txRemove", (PyCFunction)dap_chain_ledger_tx_remove_py, METH_VARARGS, ""}, - {"purge", (PyCFunction)dap_chain_ledger_purge_py, METH_VARARGS, ""}, - {"count", (PyCFunction)dap_chain_ledger_count_py, METH_VARARGS, ""}, - {"countFromTo", (PyCFunction)dap_chain_ledger_count_from_to_py, METH_VARARGS, ""}, - {"txHashIsUsedOutItem", (PyCFunction)dap_chain_ledger_tx_hash_is_used_out_item_py, METH_VARARGS, ""}, - {"calcBalance", (PyCFunction)dap_chain_ledger_calc_balance_py, METH_VARARGS, ""}, - {"calcBalanceFull", (PyCFunction)dap_chain_ledger_calc_balance_full_py, METH_VARARGS, ""}, - {"txFindByHash", (PyCFunction)dap_chain_ledger_tx_find_by_hash_py, METH_VARARGS, ""}, - {"txFindByAddr", (PyCFunction)dap_chain_ledger_tx_find_by_addr_py, METH_VARARGS, ""}, - {"txFindByPkey", (PyCFunction)dap_chain_ledger_tx_find_by_pkey_py, METH_VARARGS, ""}, - {"txCacheFindOutCond", (PyCFunction)dap_chain_ledger_tx_cache_find_out_cond_py, METH_VARARGS, ""}, - {"txCacheGetOutCondValue", (PyCFunction)dap_chain_ledger_tx_cache_get_out_cond_value_py, METH_VARARGS, ""}, - - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainLedger_DapChainLedgerType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Ledger", /* tp_name */ - sizeof(PyDapChainLedgerObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain ledger objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainLedgerMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; +extern PyTypeObject DapChainLedger_DapChainLedgerType; static char*** ListStringToArrayStringFormatChar(PyObject *list); static size_t *ListIntToSizeT(PyObject *list); diff --git a/modules/cellframe-sdk/chain/src/libdap-chain-python.c b/modules/cellframe-sdk/chain/src/libdap-chain-python.c index 4d78548890b9a7ffcff09bce987839c01fee9c16..63f7c668677b7e338e55d48f93f5c47cb4f06e56 100644 --- a/modules/cellframe-sdk/chain/src/libdap-chain-python.c +++ b/modules/cellframe-sdk/chain/src/libdap-chain-python.c @@ -11,6 +11,63 @@ void deinit_chain_py(){ dap_chain_deinit(); } +static PyMethodDef DapChainMethods[] = { + {"findById", (PyCFunction)dap_chain_find_by_id_py, METH_VARARGS|METH_STATIC, ""}, + {"loadFromCfg", (PyCFunction)dap_chain_load_from_cfg_py, METH_VARARGS|METH_STATIC, ""}, + {"hasFileStore", (PyCFunction)dap_chain_has_file_store_py, METH_NOARGS, ""}, + {"saveAll", (PyCFunction) dap_chain_save_all_py, METH_NOARGS, ""}, + {"loadAll", (PyCFunction)dap_chain_load_all_py, METH_NOARGS, ""}, + {"createAtomItem", (PyCFunction) dap_chain_python_create_atom_iter, METH_VARARGS, ""}, + {"atomIterGetFirst", (PyCFunction) dap_chain_python_atom_iter_get_first, METH_VARARGS, ""}, + {"atomGetDatums", (PyCFunction) dap_chain_python_atom_get_datums, METH_VARARGS, ""}, + {"atomIterGetNext", (PyCFunction)dap_chain_python_atom_iter_get_next, METH_VARARGS, ""}, + {"getDag", (PyCFunction)dap_chain_python_atom_iter_get_dag, METH_NOARGS}, + //{"close", (PyCFunction)dap_chain_close_py, METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject dapChainObject_dapChainType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain", /* tp_name */ + sizeof(PyDapChainObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PyDapChainObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyDapChainObject_new, /* tp_new */ +}; + PyObject *dap_chain_find_by_id_py(PyObject *self, PyObject *args){ PyObject *obj_net_id; PyObject *obj_chain_id; @@ -96,7 +153,6 @@ PyObject *dap_chain_python_create_atom_iter(PyObject *self, PyObject *args){ bool with_treshold = (obj_boolean == Py_True) ? 1 : 0; PyObject *obj_atom_iter = _PyObject_New(&DapChainAtomIter_DapChainAtomIterType); PyObject_Init(obj_atom_iter, &DapChainAtomIter_DapChainAtomIterType); - PyObject_Dir(obj_atom_iter); ((PyChainAtomIterObject*)obj_atom_iter)->atom_iter = ((PyDapChainObject*)self)->chain_t->callback_atom_iter_create( ((PyDapChainObject*)self)->chain_t, @@ -116,7 +172,6 @@ PyObject *dap_chain_python_atom_iter_get_first(PyObject *self, PyObject *args){ } PyObject *obj_atom_ptr = _PyObject_New(&DapChainAtomPtr_DapChainAtomPtrType); obj_atom_ptr = PyObject_Init(obj_atom_ptr, &DapChainAtomPtr_DapChainAtomPtrType); - PyObject_Dir(obj_atom_ptr); size_t l_atom_size = 0; ((PyChainAtomPtrObject*)obj_atom_ptr)->ptr = ((PyDapChainObject*)self)->chain_t->callback_atom_iter_get_first( ((PyChainAtomIterObject*)obj_iter)->atom_iter, &l_atom_size @@ -140,7 +195,6 @@ PyObject *dap_chain_python_atom_get_datums(PyObject *self, PyObject *args){ for (int i=0; i < datums_count; i++){ PyObject *obj_datum = _PyObject_New(&DapChainDatumObject_DapChainDatumObjectType); obj_datum = PyObject_Init(obj_datum, &DapChainDatumObject_DapChainDatumObjectType); - PyObject_Dir(obj_datum); ((PyDapChainDatumObject*)obj_datum)->datum = l_datums[i]; PyList_SetItem(list_datums, i, obj_datum); } @@ -161,7 +215,6 @@ PyObject *dap_chain_python_atom_iter_get_next(PyObject *self, PyObject *args){ } PyObject *obj_atom_ptr = _PyObject_New(&DapChainAtomPtr_DapChainAtomPtrType); obj_atom_ptr = PyObject_Init(obj_atom_ptr, &DapChainAtomPtr_DapChainAtomPtrType); - PyObject_Dir(obj_atom_ptr); ((PyChainAtomPtrObject*)obj_atom_ptr)->ptr = ((PyDapChainObject*)self)->chain_t->callback_atom_iter_get_next( ((PyChainAtomIterObject*)atom_iter)->atom_iter, &atom_size); @@ -174,7 +227,6 @@ PyObject *dap_chain_python_atom_iter_get_next(PyObject *self, PyObject *args){ PyObject *dap_chain_python_atom_iter_get_dag(PyObject *self, PyObject *args){ (void)args; PyDapChainCsDagObject *obj_dag = PyObject_New(PyDapChainCsDagObject, &DapChainCsDag_DapChainCsDagType); - PyObject_Dir((PyObject*)obj_dag); obj_dag->dag = DAP_CHAIN_CS_DAG(((PyDapChainObject*)self)->chain_t); return (PyObject*)obj_dag; } diff --git a/modules/cellframe-sdk/chain/src/libdap_chain_atom_iter_python.c b/modules/cellframe-sdk/chain/src/libdap_chain_atom_iter_python.c new file mode 100644 index 0000000000000000000000000000000000000000..da80ea351f96bc5dbd55bbca063f05f7bea62df5 --- /dev/null +++ b/modules/cellframe-sdk/chain/src/libdap_chain_atom_iter_python.c @@ -0,0 +1,52 @@ +#include "libdap_chain_atom_iter_python.h" + +PyMethodDef DapChainAtomIterMethods[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainAtomIter_DapChainAtomIterType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.AtomIter", /* tp_name */ + sizeof(PyChainAtomIterObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain atom iter objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainAtomIterMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + +bool PyDapChainAtomIter_Check(PyObject *obj){ + return PyObject_TypeCheck(obj, &DapChainAtomIter_DapChainAtomIterType); +} diff --git a/modules/cellframe-sdk/chain/src/libdap_chain_type_python.c b/modules/cellframe-sdk/chain/src/libdap_chain_type_python.c index 2ce46a8ecd38485dbe4c82820c771641d0ff382a..30b5328a6290b50d4f6059df75226ba5ee84a512 100644 --- a/modules/cellframe-sdk/chain/src/libdap_chain_type_python.c +++ b/modules/cellframe-sdk/chain/src/libdap_chain_type_python.c @@ -1,5 +1,57 @@ #include "libdap_chain_type_python.h" +PyMethodDef DapChainTypeMethods[] = { + {"CHAIN_TYPE_FIRST", (PyCFunction)CHAIN_TYPE_FIRST_PY, METH_NOARGS|METH_STATIC, ""}, + {"CHAIN_TYPE_TOKEN", (PyCFunction)CHAIN_TYPE_TOKEN_PY, METH_NOARGS|METH_STATIC, ""}, + {"CHAIN_TYPE_EMISSION", (PyCFunction)CHAIN_TYPE_EMISSION_PY, METH_NOARGS|METH_STATIC, ""}, + {"CHAIN_TYPE_TX", (PyCFunction)CHAIN_TYPE_TX_PY, METH_NOARGS|METH_STATIC, ""}, + {"CHAIN_TYPE_LAST", (PyCFunction)CHAIN_TYPE_LAST_PY, METH_NOARGS|METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject dapChainTypeObject_dapChainTypeType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainType", /* tp_name */ + sizeof(PyChainTypeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain type objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainTypeMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + PyObject* CHAIN_TYPE_FIRST_PY(){ PyObject *dap_chain_obj = _PyObject_New(&dapChainTypeObject_dapChainTypeType); ((PyChainTypeObject*)dap_chain_obj)->chain_type = CHAIN_TYPE_FIRST; diff --git a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_atom_ptr.c b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_atom_ptr.c new file mode 100644 index 0000000000000000000000000000000000000000..b1db5fa250fa738c24c015e68e7bb60481db3739 --- /dev/null +++ b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_atom_ptr.c @@ -0,0 +1,48 @@ +#include "wrapping_dap_chain_atom_ptr.h" + +PyMethodDef DapChainAtomPtrMethods[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainAtomPtr_DapChainAtomPtrType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.AtomPtr", /* tp_name */ + sizeof(PyChainAtomPtrObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain atom ptr objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainAtomPtrMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; diff --git a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cell.c b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cell.c index ff90cabcb06e97384d0638d90d7db6cb3baa5571..679d8a0a0cc77de4212b7552d43fc5043371b2b2 100644 --- a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cell.c +++ b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cell.c @@ -1,5 +1,56 @@ #include "wrapping_dap_chain_cell.h" +/* Dap chain cell */ + +PyMethodDef PyDapChainCellObjectMethods[] ={ + {"load", dap_chain_cell_load_py, METH_VARARGS | METH_STATIC, ""}, + {"update", dap_chain_cell_file_update_py, METH_VARARGS, ""}, + {"append", dap_chain_cell_file_append_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainCell_DapChainCellObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Cell", /* tp_name */ + sizeof(PyDapChainCellObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cell object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainCellObjectMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + void DapChainCellObject_delete(PyDapChainCellObject* object){ dap_chain_cell_delete(object->cell); Py_TYPE(object)->tp_free((PyObject*)object); @@ -32,3 +83,91 @@ PyObject *dap_chain_cell_file_append_py(PyObject *self, PyObject *args){ int res = dap_chain_cell_file_append(((PyDapChainCellObject*)self)->cell, atom, atom_size); return PyLong_FromLong(res); } + +/* Dap chain cell decl req */ + +PyTypeObject DapChainCellDeclReq_DapChainCellDeclReqObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.DapChainCellDeclReq", /* tp_name */ + sizeof(PyDapChainCellDeclReqObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cell decl req object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Dap chain decl */ + +PyTypeObject DapChainDecl_DapChainDeclObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.DapChainCellDecl", /* tp_name */ + sizeof(PyDapChainDeclObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cell decl object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; diff --git a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cs.c b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cs.c index fbc7122d9a6d86f47197ee40e306ede836782596..829a5bc4e2f430a1616a4411c8f5db87db550237 100644 --- a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cs.c +++ b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_cs.c @@ -1,5 +1,55 @@ #include "wrapping_dap_chain_cs.h" +PyMethodDef DapChainCSMethods[] = { + {"csAdd", (PyCFunction)dap_chain_cs_add_py, METH_VARARGS, ""}, + {"csCreate", (PyCFunction)dap_chain_cs_create_py, METH_VARARGS, ""}, + {"classAdd", (PyCFunction)dap_chain_class_add_py, METH_VARARGS, ""}, + {"classCreate", (PyCFunction)dap_chain_class_create_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainCsObject_DapChainCsObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.CS", /* tp_name */ + sizeof(PyDapChainCsObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cs object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainCSMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + DapChainCSObject_new, /* tp_new */ +}; + /* Callback created */ static int wrapping_dap_chain_callback_new_cfg(dap_chain_t* chain, dap_config_t* cfg) { diff --git a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_ledger.c b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_ledger.c index a18deeb32403f31414aac18fe8d4f224bef78a04..0a0e445b6a563c844912ffc728200798aaaf86d5 100644 --- a/modules/cellframe-sdk/chain/src/wrapping_dap_chain_ledger.c +++ b/modules/cellframe-sdk/chain/src/wrapping_dap_chain_ledger.c @@ -1,5 +1,76 @@ #include "wrapping_dap_chain_ledger.h" +PyMethodDef DapChainLedgerMethods[] = { + {"setLocalCellId", (PyCFunction)dap_chain_ledger_set_local_cell_id_py, METH_VARARGS, ""}, + {"nodeDatumTxCalcHash", (PyCFunction)dap_chain_node_datum_tx_calc_hash_py, METH_VARARGS, ""}, + {"txAdd", (PyCFunction)dap_chain_ledger_tx_add_py, METH_VARARGS, ""}, + {"tokenAdd", (PyCFunction)dap_chain_ledger_token_add_py, METH_VARARGS, ""}, + {"tokenEmissionAdd", (PyCFunction)dap_chain_ledger_token_emission_add_py, METH_VARARGS, ""}, + {"tokenEmissionFind", (PyCFunction)dap_chain_ledger_token_emission_find_py, METH_VARARGS, ""}, + {"txGetTokenTickerByHash", (PyCFunction)dap_chain_ledger_tx_get_token_ticker_by_hash_py, METH_VARARGS, ""}, + {"addrGetTokenTickerAll", (PyCFunction)dap_chain_ledger_addr_get_token_ticker_all_py, METH_VARARGS, ""}, + {"addrGetTokenTickerAllFast", (PyCFunction)dap_chain_ledger_addr_get_token_ticker_all_fast_py, METH_VARARGS, ""}, + {"txCacheCheck", (PyCFunction)dap_chain_ledger_tx_cache_check_py, METH_VARARGS, ""}, + {"datumTxCacheCheck", (PyCFunction)dap_chain_node_datum_tx_cache_check_py, METH_VARARGS, ""}, + {"txRemove", (PyCFunction)dap_chain_ledger_tx_remove_py, METH_VARARGS, ""}, + {"purge", (PyCFunction)dap_chain_ledger_purge_py, METH_VARARGS, ""}, + {"count", (PyCFunction)dap_chain_ledger_count_py, METH_VARARGS, ""}, + {"countFromTo", (PyCFunction)dap_chain_ledger_count_from_to_py, METH_VARARGS, ""}, + {"txHashIsUsedOutItem", (PyCFunction)dap_chain_ledger_tx_hash_is_used_out_item_py, METH_VARARGS, ""}, + {"calcBalance", (PyCFunction)dap_chain_ledger_calc_balance_py, METH_VARARGS, ""}, + {"calcBalanceFull", (PyCFunction)dap_chain_ledger_calc_balance_full_py, METH_VARARGS, ""}, + {"txFindByHash", (PyCFunction)dap_chain_ledger_tx_find_by_hash_py, METH_VARARGS, ""}, + {"txFindByAddr", (PyCFunction)dap_chain_ledger_tx_find_by_addr_py, METH_VARARGS, ""}, + {"txFindByPkey", (PyCFunction)dap_chain_ledger_tx_find_by_pkey_py, METH_VARARGS, ""}, + {"txCacheFindOutCond", (PyCFunction)dap_chain_ledger_tx_cache_find_out_cond_py, METH_VARARGS, ""}, + {"txCacheGetOutCondValue", (PyCFunction)dap_chain_ledger_tx_cache_get_out_cond_value_py, METH_VARARGS, ""}, + + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainLedger_DapChainLedgerType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Ledger", /* tp_name */ + sizeof(PyDapChainLedgerObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain ledger objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainLedgerMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + PyObject *DapChainLedgerObject_create(PyTypeObject *type_object, PyObject *args, PyObject *kwds){ uint16_t check_flag; char *net_name; diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_common.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_common.h index e6b91b64ba86c8a58e4dffa544096923984d7747..7fb7eaa898c242986992401108071c1d0f5f6126 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_common.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_common.h @@ -43,53 +43,7 @@ typedef struct PyDapChainHashSlow{ PyObject *dap_chain_hash_slow_to_str_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainHashSlowMethod[] = { - {"toStr", (PyCFunction)dap_chain_hash_slow_to_str_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainHashSlowObject_DapChainHashSlowObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.HashSlow", /* tp_name */ - sizeof(PyDapChainHashSlowObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain hash slow object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainHashSlowMethod, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - +extern PyTypeObject DapChainHashSlowObject_DapChainHashSlowObjectType; /*=================*/ @@ -109,58 +63,7 @@ PyObject *dap_chain_addr_get_net_id_py(PyObject *self, PyObject *args); PyObject *obj_addr_str(PyObject *self); -static PyMethodDef DapChainAddrMethods[] = { - {"toStr", (PyCFunction)dap_chain_addr_to_str_py, METH_VARARGS, ""}, - {"fromStr", (PyCFunction)dap_chain_addr_from_str_py, METH_VARARGS | METH_STATIC, ""}, - {"fill", (PyCFunction)dap_chain_addr_fill_py, METH_VARARGS | METH_STATIC, ""}, - {"fillFromKey", (PyCFunction)dap_chain_addr_fill_from_key_py, METH_VARARGS, ""}, - {"checkSum", (PyCFunction)dap_chain_addr_check_sum_py, METH_VARARGS, ""}, - {"getNetId", (PyCFunction)dap_chain_addr_get_net_id_py, METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainAddrObject_DapChainAddrObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Addr", /* tp_name */ - sizeof(PyDapChainAddrObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - obj_addr_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain addr object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainAddrMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - +extern PyTypeObject DapChainAddrObject_DapChainAddrObjectType; /*=================*/ @@ -173,52 +76,7 @@ typedef struct PyDapChainNetId{ PyObject *dap_chain_net_id_from_str_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetIdObjectMethods[] = { - {"fromStr", (PyCFunction)dap_chain_net_id_from_str_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetIdObject_DapChainNetIdObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.NetID", /* tp_name */ - sizeof(PyDapChainNetIdObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net id object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetIdObjectMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetIdObject_DapChainNetIdObjectType; /*=================*/ @@ -229,108 +87,33 @@ typedef struct PyDapChainNetSrvUID{ dap_chain_net_srv_uid_t net_srv_uid; }PyDapChainNetSrvUIDObject; -PyObject *dap_chain_net_srv_uid_from_str_py(PyObject *self, PyObject *args); - -static PyMethodDef DapChainNetSrvUIDObject[] = { - {"fromStr", (PyCFunction)dap_chain_net_srv_uid_from_str_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrvUID", /* tp_name */ - sizeof(dap_chain_net_srv_uid_t), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net srv uid object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetSrvUIDObject, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +int PyDapChainNetSrvUIDObject_init(PyObject *self, PyObject *args, PyObject *kwds); +PyObject* PyDapChainNetSrvUIDObject_str(PyDapChainNetSrvUIDObject *self); + +extern PyTypeObject DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType; static bool PyDapChainNetSrvUid_Check(PyDapChainNetSrvUIDObject *a_obj){ - return !PyObject_TypeCheck(a_obj, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); + return PyObject_TypeCheck(a_obj, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); } /*=================*/ -/* Chain net srv uid */ +/* Chain net srv price unit uid */ typedef struct PyDapChainNetSrvPriceUnitUID{ PyObject_HEAD dap_chain_net_srv_price_unit_uid_t price_unit_uid; }PyDapChainNetSrvPriceUnitUIDObject; -static PyTypeObject DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrvPriceUnitUID", /* tp_name */ - sizeof(PyDapChainNetSrvPriceUnitUIDObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net srv price unit uid object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +PyObject *PyDapChainNetSrvPriceUnitUID_str(PyObject *self); + +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_undefined(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_mb(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_sec(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_day(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_kb(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_b(PyObject *self, PyObject *args); + +extern PyTypeObject DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType; /*=================*/ /* Chain cell id */ @@ -341,48 +124,7 @@ typedef struct PyDapChainID{ PyObject *DapChainIdObject_str(PyObject *self); -static PyTypeObject DapChainIDObject_DapChainIDType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainID" , /* tp_name */ - sizeof(PyDapChainIDObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - DapChainIdObject_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain id object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - +extern PyTypeObject DapChainIDObject_DapChainIDType; /*=================*/ @@ -394,150 +136,29 @@ typedef struct PyDapChainCellID{ PyObject *PyDapChainCellIdObject_str(PyObject *self); -static PyTypeObject DapChainCellIDObject_DapChainCellIDType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainCellID" , /* tp_name */ - sizeof(PyDapChainCellIDObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - PyDapChainCellIdObject_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cell id object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - +extern PyTypeObject DapChainCellIDObject_DapChainCellIDType; /*=================*/ -/* Chain cell id */ +/* Chain node addr */ typedef struct PyDapChainNodeAddr{ PyObject_HEAD dap_chain_node_addr_t *node_addr; }PyDapChainNodeAddrObject; -static PyTypeObject DapChainNodeAddrObject_DapChainNodeAddrObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNodeAddr" , /* tp_name */ - sizeof(PyDapChainCellIDObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain node addr object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +PyObject* PyDapChainNodeAddrObject_str(PyObject* self); +extern PyTypeObject DapChainNodeAddrObject_DapChainNodeAddrObjectType; /*=================*/ -/* Chain cell id */ +/* Chain hash slow kind */ typedef struct PyDapChainHashSlowKind{ PyObject_HEAD dap_chain_hash_slow_kind_t *slow_kind; }PyDapChainHashSlowKindObject; -static PyTypeObject DapChainSlowKindObject_DapChainSlowKindType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainSlowKind" , /* tp_name */ - sizeof(PyDapChainHashSlowKindObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain slow kind object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - +extern PyTypeObject DapChainSlowKindObject_DapChainSlowKindType; /*=================*/ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum.h index 43c0952a71bd2c57a89122caf56b46a86eee8682..21a642ed1f4165b627da723a6cd49cd1c6bafc6a 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum.h @@ -41,47 +41,8 @@ typedef struct PyDapChainDatumTypeId{ dap_chain_datum_typeid_t *type_id; }PyDapChainDatumTypeIdObject; -static PyTypeObject DapChainDatumTypeIdObject_DapChainDatumTypeIdObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.DatumTypeId", /* tp_name */ - sizeof(PyDapChainDatumTypeIdObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum type id object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainDatumTypeIdObject_DapChainDatumTypeIdObjectType; + /* -------------------------------- */ typedef struct PyDapChainDatum{ @@ -102,65 +63,7 @@ PyObject *wrapping_dap_chain_datum_get_datum_token_emission(PyObject *self, PyOb PyObject *dap_chain_datum_get_type_str_py(PyObject *self, PyObject *args); PyObject *wrapping_dap_chain_datum_get_version_str_py(PyObject *self, void* closure); -static PyMethodDef DapChainDatumMethods[] = { - {"getSize", dap_chain_datum_size_py, METH_NOARGS, ""}, - {"isDatumTX", dap_chain_datum_is_type_tx, METH_NOARGS, ""}, - {"getDatumTX", wrapping_dap_chain_datum_get_datum_tx, METH_NOARGS, ""}, - {"isDatumToken", dap_chain_datum_is_type_token, METH_NOARGS, ""}, - {"getDatumToken", wrapping_dap_chain_datum_get_datum_token, METH_NOARGS, ""}, - {"isDatumTokenEmission", dap_chain_datum_is_type_emission, METH_NOARGS, ""}, - {"getDatumTokenEmission", wrapping_dap_chain_datum_get_datum_token_emission, METH_NOARGS, ""}, - {"getTypeStr", dap_chain_datum_get_type_str_py, METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef DapChainDatumGetSet[] = { - {"versionStr", (getter)wrapping_dap_chain_datum_get_version_str_py, NULL, NULL}, - {"tsCreated", (getter)dap_chain_datum_get_ts_created_py, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainDatumObject_DapChainDatumObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Datum", /* tp_name */ - sizeof(PyDapChainDatumObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainDatumMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainDatumGetSet, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyDapChainDatumObject_new, /* tp_new */ -}; +extern PyTypeObject DapChainDatumObject_DapChainDatumObjectType; /* -------------------------------- */ /* DAP Chain datum iter*/ @@ -169,47 +72,7 @@ typedef struct PyDapChainDatumIter{ dap_chain_datum_iter_t *datum_iter; }PyDapChainDatumIterObject; -static PyTypeObject DapChainDatumIterObject_DapChainDatumIterObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.DatumIter", /* tp_name */ - sizeof(PyDapChainDatumIterObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum iter object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainDatumIterObject_DapChainDatumIterObjectType; /* -------------------------------- */ #ifdef __cplusplus diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_token.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_token.h index 33c1c94a0a71da3ba7731bcb0b2a64f8eb361ee9..90fa5d7fb591e5c0ef36b67506bc15318fa5fc91 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_token.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_token.h @@ -48,58 +48,7 @@ PyObject *wrapping_dap_chain_datum_token_get_type_str(PyObject *self, void *clos //PyObject *wrapping_dap_chain_datum_token_get_size(PyObject *self, void *closure); PyObject *wrapping_dap_chain_datum_token_get_data(PyObject *self, void *closure); -static PyGetSetDef PyDapChainDatumTokenGetsSetsDef[]={ - {"ticker", (getter)wrapping_dap_chain_datum_token_get_ticker, NULL, NULL, NULL}, - {"typeStr", (getter)wrapping_dap_chain_datum_token_get_type_str, NULL, NULL, NULL}, - {"data", (getter)wrapping_dap_chain_datum_token_get_data, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainDatumTokenMethods[] = { - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainDatumToken_DapChainDatumTokenObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.DatumTokenObject", /* tp_name */ - sizeof(PyDapChainDatumTokenObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum token object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainDatumTokenMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapChainDatumTokenGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainDatumToken_DapChainDatumTokenObjectType; /* ------------------------------------------- */ @@ -119,61 +68,7 @@ PyObject *wrapping_dap_chain_datum_token_emission_get_value(PyObject *self, void PyObject *wrapping_dap_chain_datum_token_emission_get_nonce(PyObject *self, void *closure); PyObject *wrapping_dap_chain_datum_token_emission_get_data(PyObject *self, void *closure); -static PyGetSetDef PyDapChainDatumTokenEmissionGetsSetsDef[]={ - {"version", (getter)wrapping_dap_chain_datum_token_emission_get_version, NULL, NULL}, - {"typeStr", (getter)wrapping_dap_chain_datum_token_emission_get_type_str, NULL, NULL}, - {"ticker", (getter)wrapping_dap_chain_datum_token_emission_get_ticker, NULL, NULL}, - {"addr", (getter)wrapping_dap_chain_datum_token_emission_get_addr, NULL, NULL}, - {"value", (getter)wrapping_dap_chain_datum_token_emission_get_value, NULL, NULL}, - {"data", (getter)wrapping_dap_chain_datum_token_emission_get_data, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainDatumTokenEmissionMethods[]={ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainDatumTokenEmission_DapChainDatumTokenEmissionObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.DatumTokenEmission", /* tp_name */ - sizeof(PyDapChainDatumTokenEmissionObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum token emission object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainDatumTokenEmissionMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapChainDatumTokenEmissionGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainDatumTokenEmission_DapChainDatumTokenEmissionObjectType; /* ------------------------------------------- */ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_tx.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_tx.h index 875b712fbd0ed80c1850e2fb527d3871416f3eda..6afa0be4cff1542b716cf7867c20bc98289086e0 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_tx.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_datum_tx.h @@ -66,60 +66,7 @@ PyObject *TX_ITEM_TYPE_IN_COND_PY(void); PyObject *TX_ITEM_TYPE_OUT_COND_PY(void); PyObject *TX_ITEM_TYPE_RECEIPT_PY(void); -static PyMethodDef PyDapChainTxItemTypeObjectMethods[] ={ - {"TX_ITEM_TYPE_IN", (PyCFunction)TX_ITEM_TYPE_IN_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_OUT", (PyCFunction)TX_ITEM_TYPE_OUT_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_PKEY", (PyCFunction)TX_ITEM_TYPE_PKEY_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_SIG", (PyCFunction)TX_ITEM_TYPE_SIG_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_TOKEN", (PyCFunction)TX_ITEM_TYPE_TOKEN_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_IN_COND", (PyCFunction)TX_ITEM_TYPE_IN_COND_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_OUT_COND", (PyCFunction)TX_ITEM_TYPE_OUT_COND_PY, METH_NOARGS | METH_STATIC, ""}, - {"TX_ITEM_TYPE_RECEIPT", (PyCFunction)TX_ITEM_TYPE_RECEIPT_PY, - METH_NOARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainTxItemObject_DapChainTxItemTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.TxItemType", /* tp_name */ - sizeof(PyDapChainTxItemTypeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx item type object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainTxItemTypeObjectMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxItemObject_DapChainTxItemTypeObjectType; /* -------------------------------------- */ @@ -132,53 +79,7 @@ typedef struct PyDapChainTxCondType{ PyObject *COND_SERVICE_PROVIDE_PY(); PyObject *COND_SERVICE_BILL_PY(); -static PyMethodDef DapChainTxCondTypeMethods[] = { - {"COND_SERVICE_PROVIDE", COND_SERVICE_PROVIDE_PY, METH_NOARGS | METH_STATIC, ""}, - {"COND_SERVICE_BILL", COND_SERVICE_BILL_PY, METH_NOARGS | METH_STATIC, ""}, - {NULL, NULL,0, NULL} -}; - -static PyTypeObject DapChainTxCondType_DapChainTxCondTypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.TxCondType", /* tp_name */ - sizeof(PyDapChainTxCondTypeObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx cond type object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainTxCondTypeMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxCondType_DapChainTxCondTypeObject; /* -------------------------------------- */ @@ -204,66 +105,7 @@ PyObject *wrapping_dap_chain_datum_tx_get_items(PyObject *self, PyObject *args); PyObject *wrapping_dap_chain_datum_tx_get_hash(PyObject *self, void* closure); PyObject *wrapping_dap_chain_datum_tx_get_tsCreated(PyObject *self, void* closure); -static PyGetSetDef PyDaoChainDatumTxObjectGetsSets[] = { - {"hash", (getter) wrapping_dap_chain_datum_tx_get_hash, NULL, NULL, NULL}, - {"dateCreated", (getter) wrapping_dap_chain_datum_tx_get_tsCreated, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainDatumTxObjectMethods[] ={ - {"getSize", (PyCFunction)dap_chain_datum_tx_get_size_py, METH_VARARGS, ""}, - {"addItem", (PyCFunction)dap_chain_datum_tx_add_item_py, METH_VARARGS, ""}, - {"addInItem", (PyCFunction)dap_chain_datum_tx_add_in_item_py, METH_VARARGS, ""}, - {"addInCondItem", (PyCFunction)dap_chain_datum_tx_add_in_cond_item_py, METH_VARARGS, ""}, - {"addOutItem", (PyCFunction)dap_chain_datum_tx_add_out_item_py, METH_VARARGS, ""}, - {"addOutCond", (PyCFunction)dap_chain_datum_tx_add_out_cond_item_py, METH_VARARGS, ""}, - {"addSignItem", (PyCFunction)dap_chain_datum_tx_add_sign_item_py, METH_VARARGS, ""}, - {"verifySign", (PyCFunction)dap_chain_datum_tx_verify_sign_py, METH_VARARGS, ""}, - {"getItems", (PyCFunction)wrapping_dap_chain_datum_tx_get_items, METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainDatumTx_DapChainDatumTxObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.DatumTx", /* tp_name */ - sizeof(PyDapChainDatumTxObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0,//(destructor)PyDapChainDatumTxObject_delete, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain datum tx object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainDatumTxObjectMethods, /* tp_methods */ - 0, /* tp_members */ - PyDaoChainDatumTxObjectGetsSets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyDapChainDatumTxObject_create, /* tp_new */ -}; +extern PyTypeObject DapChainDatumTx_DapChainDatumTxObjectType; /* -------------------------------------- */ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in.h index 787680a842de3aadbadd9f66ab30ade4d6451b4e..34b15c4d59433ec85b4da3d75e5b6b9a9bf8ed39 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in.h @@ -42,53 +42,7 @@ typedef struct PyDapChainTXIn{ PyObject *wrapping_dap_chain_tx_in_get_prev_hash(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_in_get_out_prev_idx(PyObject *self, void *closure); -static PyGetSetDef DapChainTxGetsSetsDef[] = { - {"prevHash", (getter)wrapping_dap_chain_tx_in_get_prev_hash, NULL, NULL, NULL}, - {"prevIdx", (getter)wrapping_dap_chain_tx_in_get_out_prev_idx, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxInObject_DapChainTxInTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxIn", /* tp_name */ - sizeof(PyDapChainTXInObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx in object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapChainTxGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxInObject_DapChainTxInTypeObjectType; #ifdef __cplusplus extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in_cond.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in_cond.h index d59338650a44c347d9a5c2227968d8e8f7cd1884..d67061be805dbf304d100700943222bc27c632c1 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in_cond.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_in_cond.h @@ -42,58 +42,7 @@ PyObject *wrapping_dap_chain_tx_in_cond_get_receipt_prev_idx(PyObject *self, voi PyObject *wrapping_dap_chain_tx_in_cond_get_prev_hash(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_in_cond_get_out_prev_idx(PyObject *self, void *closure); -static PyGetSetDef DapChainTxInCondGetsSetsDef[] = { - {"receiptPrevIdx",(getter)wrapping_dap_chain_tx_in_cond_get_receipt_prev_idx, NULL, NULL, NULL}, - {"prevHash", (getter)wrapping_dap_chain_tx_in_cond_get_prev_hash, NULL, NULL, NULL}, - {"outPrevIdx", (getter)wrapping_dap_chain_tx_in_cond_get_out_prev_idx, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef DapChainTxInCondMethodsDef[] = { - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainTxInCondObject_DapChainTxInCondTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxInCond", /* tp_name */ - sizeof(PyDapChainTXInCondObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx in cond object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainTxInCondMethodsDef, /* tp_methods */ - 0, /* tp_members */ - DapChainTxInCondGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxInCondObject_DapChainTxInCondTypeObjectType; #ifdef __cplusplus extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out.h index ff107e5fad1358a582a631503f523b8e6ceecbee..e9a839a2882e5f70438141fbd8af44e56f7c9404 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out.h @@ -41,57 +41,7 @@ typedef struct PyDapChainTXOut{ PyObject *wrapping_dap_chain_tx_out_get_addr(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_get_value(PyObject *self, void *closure); -static PyGetSetDef DapChainTxOutGetsSetsDef[] = { - {"addr", (getter)wrapping_dap_chain_tx_out_get_addr, NULL, NULL, NULL}, - {"value", (getter)wrapping_dap_chain_tx_out_get_value, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainTxOutObjectMethods[] ={ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainTxOutObject_DapChainTxOutTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOut", /* tp_name */ - sizeof(PyDapChainTXOutObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx out object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainTxOutObjectMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainTxOutGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutObject_DapChainTxOutTypeObjectType; //#ifdef __cplusplus //extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond.h index 7810e58114cdc88cf399567a21db82876de9524d..533e3b550557525e41a8832d1e418f6681842124 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond.h @@ -43,55 +43,7 @@ PyObject *wrapping_dap_chain_tx_out_cond_get_value(PyObject *self, void *closure PyObject *wrapping_dap_chain_tx_out_cond_get_type_subtype(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_cond_get_subtype(PyObject *self, void *closure); -static PyGetSetDef PyDapChainTxOutCondGetsSetsDef[] = { - {"tsExpires", (getter)wrapping_dap_chain_tx_out_cond_get_ts_expires, NULL, NULL, NULL}, - {"value", (getter)wrapping_dap_chain_tx_out_cond_get_value, NULL, NULL, NULL}, - {"typeSubtype", (getter)wrapping_dap_chain_tx_out_cond_get_type_subtype, NULL, NULL, NULL}, - {"subtype", (getter)wrapping_dap_chain_tx_out_cond_get_subtype, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxOutCond_DapChainTxOutCondType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutCond", /* tp_name */ - sizeof(PyDapChainTxOutCondObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx out cond object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - PyDapChainTxOutCondGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutCond_DapChainTxOutCondType; //============= DapChaTxOutCondSubtype typedef struct PyDapChainTxOutCondSubType{ @@ -101,47 +53,7 @@ typedef struct PyDapChainTxOutCondSubType{ PyObject *PyDapChainTxOutCondSubType_str(PyObject *self); -static PyTypeObject DapChainTxOutCondSubType_DapChainTxOutCondSubTypeType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutCondSubType", /* tp_name */ - sizeof(PyDapChainTxOutCondSubTypeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - PyDapChainTxOutCondSubType_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx out cond object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutCondSubType_DapChainTxOutCondSubTypeType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.h index c595ed07e40a93d6a6c826453e7efbbcf07469cc..65ecd25ef21ac8da95a525db908567ec41123df2 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.h @@ -38,55 +38,7 @@ PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_uid(PyObject *self, PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_pkey(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_map_price(PyObject *self, void *closure); - static PyGetSetDef DapChainTxOutCondSubtypeStvPayGetsSetsDef[]={ - {"unit", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_unit,NULL,NULL,NULL}, - {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_uid,NULL,NULL,NULL}, - {"pkeyHash", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_pkey,NULL,NULL,NULL}, - {"maxPrice", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_map_price,NULL,NULL,NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxOutCondSubTypeSrvPay_DapChainTxOutCondSubTypeSrvPayObject = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutCondSubTypeSrvPay", /* tp_name */ - sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ - "Chain tx cond subtype srv pay object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapChainTxOutCondSubtypeStvPayGetsSetsDef, /* tp_getset */ - &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutCondSubTypeSrvPay_DapChainTxOutCondSubTypeSrvPayObject; #ifdef __cplusplus }; diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.h index c479c4639f071e9c014051b6a9b6909c4b84a5da..60e598c08396b6696960d82967c01c041da075d4 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.h @@ -37,54 +37,7 @@ PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_uid(PyObject *sel PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_addr(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_value(PyObject *self, void *closure); -static PyGetSetDef DapChainTxOutCondSubtypeSrvStakeGetsSetsDef[]={ - {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_uid,NULL,NULL,NULL}, - {"addr", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_addr,NULL,NULL,NULL}, - {"value", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_value, NULL, NULL,NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxOutCondSubTypeSrvStake_DapChainTxOutCondSubTypeSrvStakeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutCondSubTypeSrvStake", /* tp_name */ - sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ - "Chain tx cond subtype srv stake object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapChainTxOutCondSubtypeSrvStakeGetsSetsDef, /* tp_getset */ - &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutCondSubTypeSrvStake_DapChainTxOutCondSubTypeSrvStakeObject; #ifdef __cplusplus }; diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.h index 873d3b297b92ac735a68aee7c25cae884f88a293..13e253d30ce3e717fa8d60d65657ed2477359edf 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.h @@ -38,55 +38,7 @@ PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_net_id(PyObject PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_token(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_value(PyObject *self, void *closure); -static PyGetSetDef DapChainTxOutCondSubtypeSrvXchangeGetsSetsDef[]={ - {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_uid,NULL,NULL,NULL}, - {"netId", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_net_id,NULL,NULL,NULL}, - {"token", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_token,NULL,NULL,NULL}, - {"value", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_value,NULL,NULL,NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxOutCondSubTypeSrvXchange_DapChainTxOutCondSubTypeSrvXchangeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutCondSubTypeSrvXchange", /* tp_name */ - sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ - "Chain tx cond subtype srv xchange object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapChainTxOutCondSubtypeSrvXchangeGetsSetsDef, /* tp_getset */ - &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutCondSubTypeSrvXchange_DapChainTxOutCondSubTypeSrvXchangeObject; #ifdef __cplusplus }; diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_ext.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_ext.h index e8c842756d39a1b0ecdc7020beac9c701cedf8a1..54b6507994c88146be102f36c6a18d22618a913b 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_ext.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_out_ext.h @@ -42,59 +42,7 @@ PyObject *wrapping_dap_chain_tx_out_ext_get_addr(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_ext_get_token(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_out_ext_get_value(PyObject *self, void *closure); -static PyGetSetDef DapChainTxOutExtGetsSetsDef[] = { - {"addr", (getter)wrapping_dap_chain_tx_out_ext_get_addr, NULL, NULL, NULL}, - {"token", (getter)wrapping_dap_chain_tx_out_ext_get_token, NULL, NULL, NULL}, - {"value", (getter)wrapping_dap_chain_tx_out_ext_get_value, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainTxOutExtObjectMethods[] ={ - {NULL, NULL, 0, NULL} -}; - - -static PyTypeObject DapChainTxOutExtObject_DapChainTxOutExtTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxOutExt", /* tp_name */ - sizeof(PyDapChainTXOutExtObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx out ext object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainTxOutExtObjectMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainTxOutExtGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxOutExtObject_DapChainTxOutExtTypeObjectType; #ifdef __cplusplus extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_pkey.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_pkey.h index e611e8c8d728f630bae106b3264ca4d50687787b..8a6ba165ee4bb80ea673195cb94bfe5c29179791 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_pkey.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_pkey.h @@ -44,59 +44,7 @@ PyObject *wrapping_dap_chain_tx_pkey_seq_no(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_pkey_get_pkey(PyObject *self, void *closure); -static PyGetSetDef DapChainTxPkeyGetsSetsDef[] = { - {"sigType", (getter)wrapping_dap_chain_tx_pkey_sig_type, NULL, NULL, NULL}, - {"sigSize", (getter)wrapping_dap_chain_tx_pkey_sig_size, NULL, NULL, NULL}, - {"sequenceNumber", (getter)wrapping_dap_chain_tx_pkey_seq_no, NULL, NULL, NULL}, - {"pkey", (getter)wrapping_dap_chain_tx_pkey_get_pkey, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainTxPkeyObjectMethods[] ={ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainTxPkeyObject_DapChainTxPkeyTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxPkey", /* tp_name */ - sizeof(PyDapChainTXPkeyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx pkey object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainTxPkeyObjectMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainTxPkeyGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxPkeyObject_DapChainTxPkeyTypeObjectType; #ifdef __cplusplus extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_receipt.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_receipt.h index 1d868f1a7618b2ec6402a635c5e667e1ddaeb2c6..528634ba74bc2ff8614cbf2945c9ace3e8547a4d 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_receipt.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_receipt.h @@ -51,59 +51,7 @@ PyObject *wrapping_dap_chain_tx_receipt_get_value(PyObject *self, void *closure) PyObject *wrapping_dap_chain_tx_receipt_get_sig_provider(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_receipt_get_sig_client(PyObject *self, void *closure); -static PyGetSetDef DapChainTxReceiptGetSetDefs[] = { - {"size", (getter)wrapping_dap_chain_tx_receipt_get_size, NULL, NULL, NULL}, - {"extSize", (getter)wrapping_dap_chain_tx_receipt_get_ext_size, NULL, NULL, NULL}, - {"units", (getter)wrapping_dap_chain_tx_receipt_get_units, NULL, NULL, NULL}, - {"uid", (getter)wrapping_dap_chain_tx_receipt_get_uid, NULL, NULL, NULL}, - {"unitsType", (getter)wrapping_dap_chain_tx_receipt_get_units_type, NULL, NULL, NULL}, - {"value", (getter)wrapping_dap_chain_tx_receipt_get_value, NULL, NULL, NULL}, - {"provider", (getter)wrapping_dap_chain_tx_receipt_get_sig_provider, NULL, NULL, NULL}, - {"client", (getter)wrapping_dap_chain_tx_receipt_get_sig_client, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxReceiptObject_DapChainTxReceiptTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxReceipt", /* tp_name */ - sizeof(PyDapChainTXReceiptObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx item receipt object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapChainTxReceiptGetSetDefs, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxReceiptObject_DapChainTxReceiptTypeObjectType; #ifdef __cplusplus extern "C"{ diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_sig.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_sig.h index 9b6b09ff75a138a74192c98c5e5a649d3257a7fd..7f00ea5ba31ebb90f5dff4823e3993329748ed71 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_sig.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_sig.h @@ -44,57 +44,7 @@ typedef struct PyDapChainTXSig{ PyObject *wrapping_dap_chain_tx_sig_get_sign(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_sig_get_sig_size(PyObject *self, void *closure); -static PyGetSetDef DapChainTxSigGetsSetsDef[] = { - {"sign", (getter)wrapping_dap_chain_tx_sig_get_sign, NULL, NULL, NULL}, - {"sigSize", (getter)wrapping_dap_chain_tx_sig_get_sig_size, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapChainTxSigObjectMethods[] ={ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainTxSigObject_DapChainTxSigTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxSig", /* tp_name */ - sizeof(PyDapChainTXSigObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx signature object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainTxSigObjectMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainTxSigGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxSigObject_DapChainTxSigTypeObjectType; //#ifdef __cplusplus //} diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token.h index c69361b33c6d18fa9d3aaa3e3a2e73b8ddc64c12..6c79b862805c1ad3bf29ed7866cf0b9fe9cb90f2 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token.h @@ -44,54 +44,7 @@ PyObject *wrapping_dap_chain_tx_token_get_ticker(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_token_get_token_emission_hash(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_token_get_token_emission_chain_id(PyObject *self, void *closure); -static PyGetSetDef PyDapChainTxTokenGetsSetsDef[] = { - {"ticker", (getter)wrapping_dap_chain_tx_token_get_ticker, NULL, NULL, NULL}, - {"tokenEmissionHash", (getter)wrapping_dap_chain_tx_token_get_token_emission_hash, NULL, NULL, NULL}, - {"tokenEmissionChainId", (getter)wrapping_dap_chain_tx_token_get_token_emission_chain_id, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxToken_DapChainTxTokenType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxToken", /* tp_name */ - sizeof(PyDapChainTxTokenObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx token object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - PyDapChainTxTokenGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxToken_DapChainTxTokenType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token_ext.h b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token_ext.h index 58bdc7a55d564fe079612714a6628d30ec5a25d6..90ced87af6a508c4ce55d979713253727a419105 100644 --- a/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token_ext.h +++ b/modules/cellframe-sdk/common/include/wrapping_dap_chain_tx_token_ext.h @@ -47,57 +47,7 @@ PyObject *wrapping_dap_chain_tx_token_get_net_id(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_token_get_tx_hash(PyObject *self, void *closure); PyObject *wrapping_dap_chain_tx_token_get_tx_out_idx(PyObject *self, void *closure); -static PyGetSetDef PyDapChainTxTokenExtGetsSetsDef[] = { - {"version", (getter)wrapping_dap_chain_tx_token_ext_get_version, NULL, NULL, NULL}, - {"ticker", (getter)wrapping_dap_chain_tx_token_ext_get_ticker, NULL, NULL, NULL}, - {"chainId", (getter)wrapping_dap_chain_tx_token_get_chain_id, NULL, NULL, NULL}, - {"netId", (getter)wrapping_dap_chain_tx_token_get_net_id, NULL,NULL, NULL}, - {"txHash", (getter)wrapping_dap_chain_tx_token_get_tx_hash, NULL, NULL, NULL}, - {"txOutIdx", (getter)wrapping_dap_chain_tx_token_get_tx_out_idx, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainTxTokenExt_DapChainTxTokenExtType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainTxTokenExt", /* tp_name */ - sizeof(PyDapChainTxTokenExtObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain tx token ext object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - PyDapChainTxTokenExtGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainTxTokenExt_DapChainTxTokenExtType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_common.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_common.c index 45e10bc6b6dfb1a850a103216a59bff68d173a17..9f4aed05b8893032386f0482a4315e908266a733 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_common.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_common.c @@ -1,9 +1,334 @@ #include "wrapping_dap_chain_common.h" +/* Chain hash slow */ +PyMethodDef DapChainHashSlowMethod[] = { + {"toStr", (PyCFunction)dap_chain_hash_slow_to_str_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainHashSlowObject_DapChainHashSlowObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.HashSlow", /* tp_name */ + sizeof(PyDapChainHashSlowObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain hash slow object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainHashSlowMethod, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Hash slow kind */ +PyTypeObject DapChainSlowKindObject_DapChainSlowKindType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainSlowKind" , /* tp_name */ + sizeof(PyDapChainHashSlowKindObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain slow kind object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Chain addr */ +PyMethodDef DapChainAddrMethods[] = { + {"toStr", (PyCFunction)dap_chain_addr_to_str_py, METH_VARARGS, ""}, + {"fromStr", (PyCFunction)dap_chain_addr_from_str_py, METH_VARARGS | METH_STATIC, ""}, + {"fill", (PyCFunction)dap_chain_addr_fill_py, METH_VARARGS | METH_STATIC, ""}, + {"fillFromKey", (PyCFunction)dap_chain_addr_fill_from_key_py, METH_VARARGS, ""}, + {"checkSum", (PyCFunction)dap_chain_addr_check_sum_py, METH_VARARGS, ""}, + {"getNetId", (PyCFunction)dap_chain_addr_get_net_id_py, METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainAddrObject_DapChainAddrObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Addr", /* tp_name */ + sizeof(PyDapChainAddrObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + obj_addr_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain addr object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainAddrMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Chain net id */ +PyMethodDef DapChainNetIdObjectMethods[] = { + {"fromStr", (PyCFunction)dap_chain_net_id_from_str_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetIdObject_DapChainNetIdObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.NetID", /* tp_name */ + sizeof(PyDapChainNetIdObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net id object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetIdObjectMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Chain net srv uid */ +PyMethodDef DapChainNetSrvUIDObject[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvUID", /* tp_name */ + sizeof(dap_chain_net_srv_uid_t), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainNetSrvUIDObject_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv uid object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvUIDObject, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PyDapChainNetSrvUIDObject_init, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* Chain id */ +PyTypeObject DapChainIDObject_DapChainIDType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainID" , /* tp_name */ + sizeof(PyDapChainIDObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + DapChainIdObject_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain id object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *DapChainIdObject_str(PyObject *self){ return Py_BuildValue("s", dap_strdup_printf("0x%016"DAP_UINT64_FORMAT_x, ((PyDapChainIDObject*)self)->chain_id->uint64)); } +/* Dap chain cell id */ +PyTypeObject DapChainCellIDObject_DapChainCellIDType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainCellID" , /* tp_name */ + sizeof(PyDapChainCellIDObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainCellIdObject_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cell id object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *PyDapChainCellIdObject_str(PyObject *self){ return Py_BuildValue("s", dap_strdup_printf("0x%016"DAP_UINT64_FORMAT_x, ((PyDapChainCellIDObject*)self)->cell_id.uint64)); } @@ -100,11 +425,185 @@ PyObject *dap_chain_net_id_from_str_py(PyObject *self, PyObject *args){ return Py_BuildValue("O", obj_net_id); } -PyObject *dap_chain_net_srv_uid_from_str_py(PyObject *self, PyObject *args){ - const char *str; - if (!PyArg_ParseTuple(args, "s", &str)) - return NULL; - PyObject *obj = _PyObject_New(&DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); - ((PyDapChainNetSrvUIDObject*)obj)->net_srv_uid = dap_chain_net_srv_uid_from_str(str); - return Py_BuildValue("O", obj); +/* Chain net srv price unit uid */ +PyMethodDef PyDapChainNetSrvPriceUnitUID_Methods[] = { + {"undefined", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_undefined, METH_NOARGS | METH_STATIC, ""}, + {"mb", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_mb, METH_NOARGS | METH_STATIC, ""}, + {"sec", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_sec, METH_NOARGS | METH_STATIC, ""}, + {"day", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_day, METH_NOARGS | METH_STATIC, ""}, + {"kb", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_kb, METH_NOARGS | METH_STATIC, ""}, + {"b", (PyCFunction)wrapping_dap_chain_net_srv_price_unit_uid_get_b, METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvPriceUnitUID", /* tp_name */ + sizeof(PyDapChainNetSrvPriceUnitUIDObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainNetSrvPriceUnitUID_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv price unit uid object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainNetSrvPriceUnitUID_Methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +int PyDapChainNetSrvUIDObject_init(PyObject *self, PyObject *args, PyObject *kwds){ + (void)kwds; + uint64_t uid; + if (!PyArg_ParseTuple(args, "k", &uid)){ + return -1; + } + PyDapChainNetSrvUIDObject *l_obj_srv_uid = (PyDapChainNetSrvUIDObject*)self; + l_obj_srv_uid->net_srv_uid.uint64 = uid; + return 0; +} + +PyObject *PyDapChainNetSrvPriceUnitUID_str(PyObject *self){ + return Py_BuildValue("s", serv_unit_enum_to_str(&((PyDapChainNetSrvPriceUnitUIDObject*)self)->price_unit_uid.enm)); +} + +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_undefined(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_UNDEFINED; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_UNDEFINED; + return (PyObject*)obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_mb(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_MB; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_MB; + return (PyObject*)obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_sec(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_SEC; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_SEC; + return (PyObject*)obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_day(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_DAY; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_DAY; + return (PyObject*)obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_kb(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_KB; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_KB; + return (PyObject*)obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_price_unit_uid_get_b(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvPriceUnitUIDObject *obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, + &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_price_uid); + obj_srv_price_uid->price_unit_uid.uint32 = SERV_UNIT_B; + obj_srv_price_uid->price_unit_uid.enm = SERV_UNIT_B; + return (PyObject*)obj_srv_price_uid; +} + +/* wrapping dap_chain_node_addr_t */ +PyTypeObject DapChainNodeAddrObject_DapChainNodeAddrObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNodeAddr" , /* tp_name */ + sizeof(PyDapChainCellIDObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainNodeAddrObject_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain node addr object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +PyObject* PyDapChainNodeAddrObject_str(PyObject* self){ + char *ret = dap_strdup_printf(NODE_ADDR_FP_STR, NODE_ADDR_FP_ARGS(((PyDapChainNodeAddrObject *) self)->node_addr)); + return Py_BuildValue("s", ret); +} + +/* wrapping dap_chain_net_srv_uid_t */ +PyObject* PyDapChainNetSrvUIDObject_str(PyDapChainNetSrvUIDObject *self){ + char *res = dap_strdup_printf("0x%016"DAP_UINT64_FORMAT_X, ((PyDapChainNetSrvUIDObject*)self)->net_srv_uid.uint64); + return Py_BuildValue("s", res); } diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum.c index cdb9defdcfab9d0de29aaade5717a0da71fdd8dc..905ca00b629fb51199964f3ddc9c3b4119a7863a 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum.c @@ -3,6 +3,111 @@ //void PyDapChainDatumObject_dealloc(PyDapChainDatumObject* object){ //} +/* Dap chain datum type id */ + +PyTypeObject DapChainDatumTypeIdObject_DapChainDatumTypeIdObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.DatumTypeId", /* tp_name */ + sizeof(PyDapChainDatumTypeIdObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum type id object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +/* DAP chain datum */ +PyMethodDef DapChainDatumMethods[] = { + {"getSize", dap_chain_datum_size_py, METH_NOARGS, ""}, + {"isDatumTX", dap_chain_datum_is_type_tx, METH_NOARGS, ""}, + {"getDatumTX", wrapping_dap_chain_datum_get_datum_tx, METH_NOARGS, ""}, + {"isDatumToken", dap_chain_datum_is_type_token, METH_NOARGS, ""}, + {"getDatumToken", wrapping_dap_chain_datum_get_datum_token, METH_NOARGS, ""}, + {"isDatumTokenEmission", dap_chain_datum_is_type_emission, METH_NOARGS, ""}, + {"getDatumTokenEmission", wrapping_dap_chain_datum_get_datum_token_emission, METH_NOARGS, ""}, + {"getTypeStr", dap_chain_datum_get_type_str_py, METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef DapChainDatumGetSet[] = { + {"versionStr", (getter)wrapping_dap_chain_datum_get_version_str_py, NULL, NULL}, + {"tsCreated", (getter)dap_chain_datum_get_ts_created_py, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainDatumObject_DapChainDatumObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Datum", /* tp_name */ + sizeof(PyDapChainDatumObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainDatumMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainDatumGetSet, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyDapChainDatumObject_new, /* tp_new */ +}; + PyObject *PyDapChainDatumObject_new(PyTypeObject *type_object, PyObject *args, PyObject *kwds){ uint16_t type_id; PyBytesObject *bytes; @@ -118,3 +223,46 @@ PyObject *wrapping_dap_chain_datum_get_version_str_py(PyObject *self, void* clos (void)closure; return Py_BuildValue("s", dap_strdup_printf("0x%02X",((PyDapChainDatumObject*)self)->datum->header.version_id)); } + +/* DAP chain datum iter */ +PyTypeObject DapChainDatumIterObject_DapChainDatumIterObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.DatumIter", /* tp_name */ + sizeof(PyDapChainDatumIterObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum iter object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_token.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_token.c index d0fa1cb7c4645860ca0c94cf16f2f2ed0d79c72f..62a0717fcc96883f9ef364806664c9ef40bea28c 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_token.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_token.c @@ -1,6 +1,59 @@ #include "wrapping_dap_chain_datum_token.h" /* Token */ +PyGetSetDef PyDapChainDatumTokenGetsSetsDef[]={ + {"ticker", (getter)wrapping_dap_chain_datum_token_get_ticker, NULL, NULL, NULL}, + {"typeStr", (getter)wrapping_dap_chain_datum_token_get_type_str, NULL, NULL, NULL}, + {"data", (getter)wrapping_dap_chain_datum_token_get_data, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainDatumTokenMethods[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainDatumToken_DapChainDatumTokenObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.DatumTokenObject", /* tp_name */ + sizeof(PyDapChainDatumTokenObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum token object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainDatumTokenMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapChainDatumTokenGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_datum_token_get_ticker(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("s", ((PyDapChainDatumTokenObject*)self)->token->ticker); @@ -62,6 +115,62 @@ PyObject *wrapping_dap_chain_datum_token_get_data(PyObject *self, void *closure) } /* Token Emission */ +PyGetSetDef PyDapChainDatumTokenEmissionGetsSetsDef[]={ + {"version", (getter)wrapping_dap_chain_datum_token_emission_get_version, NULL, NULL}, + {"typeStr", (getter)wrapping_dap_chain_datum_token_emission_get_type_str, NULL, NULL}, + {"ticker", (getter)wrapping_dap_chain_datum_token_emission_get_ticker, NULL, NULL}, + {"addr", (getter)wrapping_dap_chain_datum_token_emission_get_addr, NULL, NULL}, + {"value", (getter)wrapping_dap_chain_datum_token_emission_get_value, NULL, NULL}, + {"data", (getter)wrapping_dap_chain_datum_token_emission_get_data, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainDatumTokenEmissionMethods[]={ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainDatumTokenEmission_DapChainDatumTokenEmissionObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.DatumTokenEmission", /* tp_name */ + sizeof(PyDapChainDatumTokenEmissionObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum token emission object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainDatumTokenEmissionMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapChainDatumTokenEmissionGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_datum_token_emission_get_version(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("I", ((PyDapChainDatumTokenEmissionObject*)self)->token_emission->hdr.version); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_tx.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_tx.c index eb80c92ef72b74a5eac4e3e8b9f35897b6f1e88e..86024cc6c4589391870af1f292285808a1eb3980 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_tx.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_datum_tx.c @@ -2,6 +2,61 @@ /* DAP chain tx iter type */ +PyMethodDef PyDapChainTxItemTypeObjectMethods[] ={ + {"TX_ITEM_TYPE_IN", (PyCFunction)TX_ITEM_TYPE_IN_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_OUT", (PyCFunction)TX_ITEM_TYPE_OUT_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_PKEY", (PyCFunction)TX_ITEM_TYPE_PKEY_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_SIG", (PyCFunction)TX_ITEM_TYPE_SIG_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_TOKEN", (PyCFunction)TX_ITEM_TYPE_TOKEN_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_IN_COND", (PyCFunction)TX_ITEM_TYPE_IN_COND_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_OUT_COND", (PyCFunction)TX_ITEM_TYPE_OUT_COND_PY, METH_NOARGS | METH_STATIC, ""}, + {"TX_ITEM_TYPE_RECEIPT", (PyCFunction)TX_ITEM_TYPE_RECEIPT_PY, + METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainTxItemObject_DapChainTxItemTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.TxItemType", /* tp_name */ + sizeof(PyDapChainTxItemTypeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx item type object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainTxItemTypeObjectMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *TX_ITEM_TYPE_IN_PY(void){ return PyLong_FromLong(TX_ITEM_TYPE_IN); } @@ -30,6 +85,54 @@ PyObject *TX_ITEM_TYPE_RECEIPT_PY(void){ /* -------------------------------------- */ /* DAP chain tx cond type */ +PyMethodDef DapChainTxCondTypeMethods[] = { + {"COND_SERVICE_PROVIDE", COND_SERVICE_PROVIDE_PY, METH_NOARGS | METH_STATIC, ""}, + {"COND_SERVICE_BILL", COND_SERVICE_BILL_PY, METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL,0, NULL} +}; + +PyTypeObject DapChainTxCondType_DapChainTxCondTypeObject = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.TxCondType", /* tp_name */ + sizeof(PyDapChainTxCondTypeObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx cond type object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainTxCondTypeMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *COND_SERVICE_PROVIDE_PY(){ PyObject *obj = _PyObject_New(&DapChainTxCondType_DapChainTxCondTypeObject); ((PyDapChainTxCondTypeObject*)obj)->tx_cond_type_t = COND_SERVICE_PROVIDE; @@ -43,6 +146,67 @@ PyObject *COND_SERVICE_BILL_PY(){ /* -------------------------------------- */ /* DAP chain datum tx */ +PyGetSetDef PyDaoChainDatumTxObjectGetsSets[] = { + {"hash", (getter) wrapping_dap_chain_datum_tx_get_hash, NULL, NULL, NULL}, + {"dateCreated", (getter) wrapping_dap_chain_datum_tx_get_tsCreated, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainDatumTxObjectMethods[] ={ + {"getSize", (PyCFunction)dap_chain_datum_tx_get_size_py, METH_VARARGS, ""}, + {"addItem", (PyCFunction)dap_chain_datum_tx_add_item_py, METH_VARARGS, ""}, + {"addInItem", (PyCFunction)dap_chain_datum_tx_add_in_item_py, METH_VARARGS, ""}, + {"addInCondItem", (PyCFunction)dap_chain_datum_tx_add_in_cond_item_py, METH_VARARGS, ""}, + {"addOutItem", (PyCFunction)dap_chain_datum_tx_add_out_item_py, METH_VARARGS, ""}, + {"addOutCond", (PyCFunction)dap_chain_datum_tx_add_out_cond_item_py, METH_VARARGS, ""}, + {"addSignItem", (PyCFunction)dap_chain_datum_tx_add_sign_item_py, METH_VARARGS, ""}, + {"verifySign", (PyCFunction)dap_chain_datum_tx_verify_sign_py, METH_VARARGS, ""}, + {"getItems", (PyCFunction)wrapping_dap_chain_datum_tx_get_items, METH_NOARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainDatumTx_DapChainDatumTxObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.DatumTx", /* tp_name */ + sizeof(PyDapChainDatumTxObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0,//(destructor)PyDapChainDatumTxObject_delete, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain datum tx object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainDatumTxObjectMethods, /* tp_methods */ + 0, /* tp_members */ + PyDaoChainDatumTxObjectGetsSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyDapChainDatumTxObject_create, /* tp_new */ +}; + PyObject *PyDapChainDatumTxObject_create(PyTypeObject *type_object, PyObject *args, PyObject *kwds){ PyDapChainDatumTxObject *obj = (PyDapChainDatumTxObject*)PyType_GenericNew(type_object, args, kwds); obj->datum_tx = dap_chain_datum_tx_create(); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in.c index cf57079197e3bf5ffbb5a68ab745c2196afd63cf..7dbf0ad3c08b73038717739d8bde4e76e418af0d 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in.c @@ -1,4 +1,51 @@ #include "wrapping_dap_chain_tx_in.h" +PyGetSetDef DapChainTxGetsSetsDef[] = { + {"prevHash", (getter)wrapping_dap_chain_tx_in_get_prev_hash, NULL, NULL, NULL}, + {"prevIdx", (getter)wrapping_dap_chain_tx_in_get_out_prev_idx, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainTxInObject_DapChainTxInTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxIn", /* tp_name */ + sizeof(PyDapChainTXInObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx in object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainTxGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; PyObject *wrapping_dap_chain_tx_in_get_prev_hash(PyObject *self, void *closure){ (void)closure; diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in_cond.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in_cond.c index 01c5988fd8d779002010af6a1dcb917be0d2bf48..d6e05b3385463db9abd29cfdf1399490e353b386 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in_cond.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_in_cond.c @@ -1,5 +1,58 @@ #include "wrapping_dap_chain_tx_in_cond.h" +PyGetSetDef DapChainTxInCondGetsSetsDef[] = { + {"receiptPrevIdx",(getter)wrapping_dap_chain_tx_in_cond_get_receipt_prev_idx, NULL, NULL, NULL}, + {"prevHash", (getter)wrapping_dap_chain_tx_in_cond_get_prev_hash, NULL, NULL, NULL}, + {"outPrevIdx", (getter)wrapping_dap_chain_tx_in_cond_get_out_prev_idx, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef DapChainTxInCondMethodsDef[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainTxInCondObject_DapChainTxInCondTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxInCond", /* tp_name */ + sizeof(PyDapChainTXInCondObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx in cond object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainTxInCondMethodsDef, /* tp_methods */ + 0, /* tp_members */ + DapChainTxInCondGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_in_cond_get_receipt_prev_idx(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("I", ((PyDapChainTXInCondObject*)self)->tx_in_cond->header.receipt_idx); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out.c index b01c40da194b7b72f24f03bd7d98e398b870b861..90eb5b8632930d2cd719666931a232a7fb4d2633 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out.c @@ -1,5 +1,57 @@ #include "wrapping_dap_chain_tx_out.h" +PyGetSetDef DapChainTxOutGetsSetsDef[] = { + {"addr", (getter)wrapping_dap_chain_tx_out_get_addr, NULL, NULL, NULL}, + {"value", (getter)wrapping_dap_chain_tx_out_get_value, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainTxOutObjectMethods[] ={ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainTxOutObject_DapChainTxOutTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOut", /* tp_name */ + sizeof(PyDapChainTXOutObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx out object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainTxOutObjectMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainTxOutGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_get_addr(PyObject *self, void *closure){ (void)closure; PyObject *obj_addr = _PyObject_New(&DapChainAddrObject_DapChainAddrObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond.c index 8915f6934cab26033eaee58351bbe5e21e4e374a..7afc37ccc9ab3fd7f49c74226faaf77845d71245 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond.c @@ -1,5 +1,55 @@ #include "wrapping_dap_chain_tx_out_cond.h" +PyGetSetDef PyDapChainTxOutCondGetsSetsDef[] = { + {"tsExpires", (getter)wrapping_dap_chain_tx_out_cond_get_ts_expires, NULL, NULL, NULL}, + {"value", (getter)wrapping_dap_chain_tx_out_cond_get_value, NULL, NULL, NULL}, + {"typeSubtype", (getter)wrapping_dap_chain_tx_out_cond_get_type_subtype, NULL, NULL, NULL}, + {"subtype", (getter)wrapping_dap_chain_tx_out_cond_get_subtype, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainTxOutCond_DapChainTxOutCondType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutCond", /* tp_name */ + sizeof(PyDapChainTxOutCondObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx out cond object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + PyDapChainTxOutCondGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_cond_get_ts_expires(PyObject *self, void *closure){ (void)closure; PyDateTime_IMPORT; @@ -10,6 +60,50 @@ PyObject *wrapping_dap_chain_tx_out_cond_get_value(PyObject *self, void *closure (void)closure; return Py_BuildValue("k", ((PyDapChainTxOutCondObject*)self)->out_cond->header.value); } + +// DapChaTxOutCondSubtype +PyTypeObject DapChainTxOutCondSubType_DapChainTxOutCondSubTypeType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutCondSubType", /* tp_name */ + sizeof(PyDapChainTxOutCondSubTypeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainTxOutCondSubType_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx out cond object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_cond_get_type_subtype(PyObject *self, void *closure){ (void)closure; PyDapChainTxOutCondSubTypeObject *obj_type_subtype = PyObject_New(PyDapChainTxOutCondSubTypeObject, diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.c index 44e701561ed9813d3c5dc13f45c4b563b2c89d5d..bd255ff9bf9bb560d6e083b95c25f9b87aba9959 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_pay.c @@ -1,5 +1,55 @@ #include "wrapping_dap_chain_tx_out_cond_subtype_srv_pay.h" +PyGetSetDef DapChainTxOutCondSubtypeStvPayGetsSetsDef[]={ + {"unit", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_unit,NULL,NULL,NULL}, + {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_uid,NULL,NULL,NULL}, + {"pkeyHash", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_pkey,NULL,NULL,NULL}, + {"maxPrice", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_map_price,NULL,NULL,NULL}, + {NULL} +}; + +PyTypeObject DapChainTxOutCondSubTypeSrvPay_DapChainTxOutCondSubTypeSrvPayObject = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutCondSubTypeSrvPay", /* tp_name */ + sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ + "Chain tx cond subtype srv pay object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainTxOutCondSubtypeStvPayGetsSetsDef, /* tp_getset */ + &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_pay_get_unit(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("I", ((PyDapChainTxOutCondObject*)self)->out_cond->subtype.srv_pay.unit.uint32); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.c index dfe171b8861607695ec217fc2336670030ca787b..5f658e9e4653327e6f70e94a3f850c3b0282560c 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_stake.c @@ -1,5 +1,54 @@ #include "wrapping_dap_chain_tx_out_cond_subtype_srv_stake.h" +PyGetSetDef DapChainTxOutCondSubtypeSrvStakeGetsSetsDef[]={ + {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_uid,NULL,NULL,NULL}, + {"addr", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_addr,NULL,NULL,NULL}, + {"value", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_value, NULL, NULL,NULL}, + {NULL} +}; + +PyTypeObject DapChainTxOutCondSubTypeSrvStake_DapChainTxOutCondSubTypeSrvStakeObject = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutCondSubTypeSrvStake", /* tp_name */ + sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ + "Chain tx cond subtype srv stake object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainTxOutCondSubtypeSrvStakeGetsSetsDef, /* tp_getset */ + &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_stake_get_uid(PyObject *self, void *closure){ (void)closure; PyDapChainNetSrvUIDObject *obj_net_srv_uid = PyObject_New(PyDapChainNetSrvUIDObject, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.c index 281adbac128375d3b7f85c6c99086983f464025c..81db5633d9a6ce68b74fb7ca1125ce723b3c1a53 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.c @@ -1,5 +1,55 @@ #include "wrapping_dap_chain_tx_out_cond_subtype_srv_xchange.h" +PyGetSetDef DapChainTxOutCondSubtypeSrvXchangeGetsSetsDef[]={ + {"uid", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_uid,NULL,NULL,NULL}, + {"netId", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_net_id,NULL,NULL,NULL}, + {"token", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_token,NULL,NULL,NULL}, + {"value", (getter)wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_value,NULL,NULL,NULL}, + {NULL} +}; + +PyTypeObject DapChainTxOutCondSubTypeSrvXchange_DapChainTxOutCondSubTypeSrvXchangeObject = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutCondSubTypeSrvXchange", /* tp_name */ + sizeof(PyDapChainTxOutCondObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASE_EXC_SUBCLASS, /* tp_flags */ + "Chain tx cond subtype srv xchange object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainTxOutCondSubtypeSrvXchangeGetsSetsDef, /* tp_getset */ + &DapChainTxOutCond_DapChainTxOutCondType, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_cond_subtype_srv_xchange_get_uid(PyObject *self, void *closure){ (void)closure; PyDapChainNetSrvUIDObject *obj_net_srv_uid = PyObject_New(PyDapChainNetSrvUIDObject, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_ext.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_ext.c index 092317b1e015c8ce3a4efc79ea02f054b1c2c2f5..e1763858f7e1f0e8189359f1e248cce830bb1fa4 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_ext.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_out_ext.c @@ -1,5 +1,59 @@ #include "wrapping_dap_chain_tx_out_ext.h" +PyGetSetDef DapChainTxOutExtGetsSetsDef[] = { + {"addr", (getter)wrapping_dap_chain_tx_out_ext_get_addr, NULL, NULL, NULL}, + {"token", (getter)wrapping_dap_chain_tx_out_ext_get_token, NULL, NULL, NULL}, + {"value", (getter)wrapping_dap_chain_tx_out_ext_get_value, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainTxOutExtObjectMethods[] ={ + {NULL, NULL, 0, NULL} +}; + + +PyTypeObject DapChainTxOutExtObject_DapChainTxOutExtTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxOutExt", /* tp_name */ + sizeof(PyDapChainTXOutExtObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx out ext object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainTxOutExtObjectMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainTxOutExtGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_out_ext_get_addr(PyObject *self, void *closure){ (void)closure; PyObject *obj_addr = _PyObject_New(&DapChainAddrObject_DapChainAddrObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_pkey.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_pkey.c index 25e8e6b458b32b16b03930865f8f5e89be9053e7..e9602869970491ee251c50dfc0c3bc0b99f22664 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_pkey.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_pkey.c @@ -1,5 +1,59 @@ #include "wrapping_dap_chain_tx_pkey.h" +PyGetSetDef DapChainTxPkeyGetsSetsDef[] = { + {"sigType", (getter)wrapping_dap_chain_tx_pkey_sig_type, NULL, NULL, NULL}, + {"sigSize", (getter)wrapping_dap_chain_tx_pkey_sig_size, NULL, NULL, NULL}, + {"sequenceNumber", (getter)wrapping_dap_chain_tx_pkey_seq_no, NULL, NULL, NULL}, + {"pkey", (getter)wrapping_dap_chain_tx_pkey_get_pkey, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainTxPkeyObjectMethods[] ={ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainTxPkeyObject_DapChainTxPkeyTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxPkey", /* tp_name */ + sizeof(PyDapChainTXPkeyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx pkey object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainTxPkeyObjectMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainTxPkeyGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_pkey_sig_type(PyObject *self, void *closure){ (void)closure; PyObject *obj_sign_type = _PyObject_New(&DapSignTypeObject_DapSignTypeObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_receipt.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_receipt.c index e45e9547b4cd12a5ae22e7da915a8163b984f2d9..ee6c57d606d7343f68ad95d8ea6913bd2405b446 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_receipt.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_receipt.c @@ -1,5 +1,59 @@ #include "wrapping_dap_chain_tx_receipt.h" +PyGetSetDef DapChainTxReceiptGetSetDefs[] = { + {"size", (getter)wrapping_dap_chain_tx_receipt_get_size, NULL, NULL, NULL}, + {"extSize", (getter)wrapping_dap_chain_tx_receipt_get_ext_size, NULL, NULL, NULL}, + {"units", (getter)wrapping_dap_chain_tx_receipt_get_units, NULL, NULL, NULL}, + {"uid", (getter)wrapping_dap_chain_tx_receipt_get_uid, NULL, NULL, NULL}, + {"unitsType", (getter)wrapping_dap_chain_tx_receipt_get_units_type, NULL, NULL, NULL}, + {"value", (getter)wrapping_dap_chain_tx_receipt_get_value, NULL, NULL, NULL}, + {"provider", (getter)wrapping_dap_chain_tx_receipt_get_sig_provider, NULL, NULL, NULL}, + {"client", (getter)wrapping_dap_chain_tx_receipt_get_sig_client, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainTxReceiptObject_DapChainTxReceiptTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxReceipt", /* tp_name */ + sizeof(PyDapChainTXReceiptObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx item receipt object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainTxReceiptGetSetDefs, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_receipt_get_size(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("H", ((PyDapChainTXReceiptObject*)self)->tx_receipt->size); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_sig.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_sig.c index 5516b5c906214ef29147b083ac58e5c5a73dd7d6..62fd34e1fe38c954b1a7a06f792c3e041d62bfc9 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_sig.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_sig.c @@ -1,5 +1,57 @@ #include "wrapping_dap_chain_tx_sig.h" +PyGetSetDef DapChainTxSigGetsSetsDef[] = { + {"sign", (getter)wrapping_dap_chain_tx_sig_get_sign, NULL, NULL, NULL}, + {"sigSize", (getter)wrapping_dap_chain_tx_sig_get_sig_size, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapChainTxSigObjectMethods[] ={ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainTxSigObject_DapChainTxSigTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxSig", /* tp_name */ + sizeof(PyDapChainTXSigObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx signature object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainTxSigObjectMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainTxSigGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_sig_get_sign(PyObject *self, void *closure){ (void)closure; PyDapSignObject *obj_sign = PyObject_New(PyDapSignObject, &DapSignObject_DapSignObjectType); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token.c index fdb6fe4756bf1f990c384b195a0e84c30e81ddd5..ce448e98b8b3df813d79a3782684dca3ed550585 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token.c @@ -1,5 +1,54 @@ #include "wrapping_dap_chain_tx_token.h" +PyGetSetDef PyDapChainTxTokenGetsSetsDef[] = { + {"ticker", (getter)wrapping_dap_chain_tx_token_get_ticker, NULL, NULL, NULL}, + {"tokenEmissionHash", (getter)wrapping_dap_chain_tx_token_get_token_emission_hash, NULL, NULL, NULL}, + {"tokenEmissionChainId", (getter)wrapping_dap_chain_tx_token_get_token_emission_chain_id, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainTxToken_DapChainTxTokenType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxToken", /* tp_name */ + sizeof(PyDapChainTxTokenObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx token object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + PyDapChainTxTokenGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_token_get_ticker(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("s", ((PyDapChainTxTokenObject*)self)->token->header.ticker); diff --git a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token_ext.c b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token_ext.c index ec0932fc247d192ecff2590abb97fde18220b9d7..d2b6012d258db3fdb7d069a207f5a4437603717d 100644 --- a/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token_ext.c +++ b/modules/cellframe-sdk/common/src/wrapping_dap_chain_tx_token_ext.c @@ -1,5 +1,57 @@ #include "wrapping_dap_chain_tx_token_ext.h" +PyGetSetDef PyDapChainTxTokenExtGetsSetsDef[] = { + {"version", (getter)wrapping_dap_chain_tx_token_ext_get_version, NULL, NULL, NULL}, + {"ticker", (getter)wrapping_dap_chain_tx_token_ext_get_ticker, NULL, NULL, NULL}, + {"chainId", (getter)wrapping_dap_chain_tx_token_get_chain_id, NULL, NULL, NULL}, + {"netId", (getter)wrapping_dap_chain_tx_token_get_net_id, NULL,NULL, NULL}, + {"txHash", (getter)wrapping_dap_chain_tx_token_get_tx_hash, NULL, NULL, NULL}, + {"txOutIdx", (getter)wrapping_dap_chain_tx_token_get_tx_out_idx, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainTxTokenExt_DapChainTxTokenExtType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainTxTokenExt", /* tp_name */ + sizeof(PyDapChainTxTokenExtObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain tx token ext object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + PyDapChainTxTokenExtGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_tx_token_ext_get_version(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("B", ((PyDapChainTxTokenExtObject*)self)->token_ext->header.version); diff --git a/modules/cellframe-sdk/gdb/include/wrapping_dap_chain_gdb.h b/modules/cellframe-sdk/gdb/include/wrapping_dap_chain_gdb.h index 2acb866410993ed43ef0e76deb4c87dbe403cea5..8c906935be0b6470f58c44a60d8fbf84624457a0 100644 --- a/modules/cellframe-sdk/gdb/include/wrapping_dap_chain_gdb.h +++ b/modules/cellframe-sdk/gdb/include/wrapping_dap_chain_gdb.h @@ -19,54 +19,7 @@ PyObject* dap_chain_gdb_new_py(PyObject* self, PyObject *args); PyObject *dap_chain_gdb_delete_py(PyObject *self, PyObject *args); PyObject *dap_chain_gdb_get_group_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainGDBMethod[] = { - {"new", (PyCFunction)dap_chain_gdb_new_py, METH_VARARGS | METH_STATIC, ""}, - {"delete", (PyCFunction)dap_chain_gdb_delete_py, METH_VARARGS | METH_STATIC, ""}, - {"getGroup", (PyCFunction)dap_chain_gdb_get_group_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainGDBObject_DapChainGDBType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainGDB", /* tp_name */ - sizeof(PyDapChainGDBObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain gdb object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainGDBMethod, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainGDBObject_DapChainGDBType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/gdb/src/wrapping_dap_chain_gdb.c b/modules/cellframe-sdk/gdb/src/wrapping_dap_chain_gdb.c index 5bf53efab530d8aeab89d39b269c95c14159a641..54edb145f9963b358c035e91f05dbef53c272274 100644 --- a/modules/cellframe-sdk/gdb/src/wrapping_dap_chain_gdb.c +++ b/modules/cellframe-sdk/gdb/src/wrapping_dap_chain_gdb.c @@ -4,6 +4,55 @@ int dap_chain_gdb_init_py(void){ return dap_chain_gdb_init(); } +PyMethodDef DapChainGDBMethod[] = { + {"new", (PyCFunction)dap_chain_gdb_new_py, METH_VARARGS | METH_STATIC, ""}, + {"delete", (PyCFunction)dap_chain_gdb_delete_py, METH_VARARGS | METH_STATIC, ""}, + {"getGroup", (PyCFunction)dap_chain_gdb_get_group_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainGDBObject_DapChainGDBType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainGDB", /* tp_name */ + sizeof(PyDapChainGDBObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain gdb object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainGDBMethod, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject* dap_chain_gdb_new_py(PyObject* self, PyObject *args){ PyObject *obj_chain; if (!PyArg_ParseTuple(args, "O", &obj_chain)) diff --git a/modules/cellframe-sdk/net/include/libdap_chain_net_python.h b/modules/cellframe-sdk/net/include/libdap_chain_net_python.h index d3045eaaee18c5f541ef5ba4900ad93061378481..b5cd8590aa1536e6f4c9ae0ecc5e939618ea1165 100644 --- a/modules/cellframe-sdk/net/include/libdap_chain_net_python.h +++ b/modules/cellframe-sdk/net/include/libdap_chain_net_python.h @@ -48,6 +48,8 @@ typedef struct PyDapChainNet{ int dap_chain_net_init_py(void); void dap_chain_net_deinit_py(void); +PyObject* PyDapChainNet_str(PyObject *self); + PyObject *dap_chain_net_load_all_py(PyObject *self, PyObject *args); PyObject *dap_chain_net_state_go_to_py(PyObject *self, PyObject *args); PyObject *dap_chain_net_start_py(PyObject *self, PyObject *args); @@ -76,85 +78,13 @@ PyObject *dap_chain_net_links_connect_py(PyObject *self, PyObject *args); PyObject *dap_chain_net_get_chain_by_chain_type_py(PyObject *self, PyObject *args); PyObject *dap_chain_net_get_ledger_py(PyObject *self, PyObject *args); PyObject *dap_chain_net_get_name_py(PyObject *self, PyObject *args); - -static PyMethodDef DapChainNetMethods[] = { - {"loadAll", dap_chain_net_load_all_py, METH_NOARGS | METH_STATIC, ""}, - {"stateGoTo", dap_chain_net_state_go_to_py, METH_VARARGS, ""}, - {"start", dap_chain_net_start_py, METH_VARARGS, ""}, - {"stop", dap_chain_net_stop_py, METH_VARARGS, ""}, - {"linksEstablish", dap_chain_net_links_establish_py, METH_VARARGS, ""}, - {"syncChains", dap_chain_net_sync_all_py, METH_VARARGS, ""}, - {"syncGdb", dap_chain_net_sync_gdb_py, METH_VARARGS, ""}, - {"syncAll", dap_chain_net_sync_all_py, METH_VARARGS, ""}, - {"procDatapool", dap_chain_net_proc_datapool_py, METH_VARARGS, ""}, - {"byName", dap_chain_net_by_name_py, METH_VARARGS | METH_STATIC, ""}, - {"byId", dap_chain_net_by_id_py, METH_VARARGS | METH_STATIC, ""}, - {"idByName", dap_chain_net_id_by_name_py, METH_VARARGS | METH_STATIC, ""}, - {"ledgerByNetName", dap_chain_ledger_by_net_name_py, METH_VARARGS | METH_STATIC, ""}, - {"getChainByName", dap_chain_net_get_chain_by_name_py, METH_VARARGS, ""}, - {"getCurAddr", dap_chain_net_get_cur_addr_py, METH_VARARGS, ""}, - {"getCurCell", dap_chain_net_get_cur_cell_py, METH_VARARGS, ""}, - {"getGdbGroupMempool", dap_chain_net_get_gdb_group_mempool_py, METH_VARARGS | METH_STATIC, ""}, - {"getGdbGroupMempoolByChainType", dap_chain_net_get_gdb_group_mempool_by_chain_type_py, METH_VARARGS, ""}, - {"linksConnect", dap_chain_net_links_connect_py, METH_VARARGS, ""}, - {"getChainByChainType", dap_chain_net_get_chain_by_chain_type_py, METH_VARARGS, ""}, - {"getLedger", dap_chain_net_get_ledger_py, METH_NOARGS, ""}, - {"getName", dap_chain_net_get_name_py, METH_NOARGS, ""}, - {NULL, NULL, 0, NULL} -}; - PyObject *dap_chain_net_python_get_id(PyObject *self, void *closure); +PyObject *dap_chain_net_add_notify_py(PyObject *self, PyObject *args); + +extern PyTypeObject DapChainNetObject_DapChainNetObjectType; -static PyGetSetDef DapChainNetGetsSetsDef[] = { - {"id", (getter)dap_chain_net_python_get_id, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainNetObject_DapChainNetObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNet", /* tp_name */ - sizeof(PyDapChainNetObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetMethods, /* tp_methods */ - 0, /* tp_members */ - DapChainNetGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - -static bool PyDapChainNet_Check(PyDapChainNetObject *pyNet) -{ - return !PyObject_TypeCheck(pyNet, &DapChainNetObject_DapChainNetObjectType); +static bool PyDapChainNet_Check(PyObject *self){ + return PyObject_TypeCheck(self, &DapChainNetObject_DapChainNetObjectType); } #ifdef __cplusplus diff --git a/modules/cellframe-sdk/net/include/wrapping_dap_app_cli_server.h b/modules/cellframe-sdk/net/include/wrapping_dap_app_cli_server.h index c7322598de1ff58d893976ee40694e180deb3af7..5b7b69b7b1b110c2ed94e2138b17d3dc6c5378c6 100644 --- a/modules/cellframe-sdk/net/include/wrapping_dap_app_cli_server.h +++ b/modules/cellframe-sdk/net/include/wrapping_dap_app_cli_server.h @@ -54,54 +54,7 @@ PyObject *dap_chain_node_cli_set_reply_text_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_addr_get_by_alias_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainNodeCliMethods[] = { - {"cmdItemCreate", dap_chain_node_cli_cmd_item_create_py, METH_VARARGS| METH_STATIC, ""}, - {"setReplyText", dap_chain_node_cli_set_reply_text_py, METH_VARARGS| METH_STATIC, ""}, - {"getByAlias", dap_chain_node_addr_get_by_alias_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNodeCliObject_DapChainNodeCliObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "AppCliServer", /* tp_name */ - sizeof(PyDapAppCliServerObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net node cli object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNodeCliMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - DapChainNodeCliObject_new, /* tp_new */ -}; +extern PyTypeObject DapChainNodeCliObject_DapChainNodeCliObjectType; char **PyListToString(PyObject *list); //PyObject *stringToPyList(char **list); diff --git a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node.h b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node.h index 34fbb96260902ebe2ebfc65ce44e44ac2ad9e944..6d7d0820f8164118ca95887d88563de7d28480bc 100644 --- a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node.h +++ b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node.h @@ -16,55 +16,6 @@ PyObject *dap_chain_node_alias_find_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_alias_register_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_alias_delete_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetNodeMethods[] = { - {"genAddr", dap_chain_node_gen_addr_py, METH_VARARGS | METH_STATIC, ""}, - {"checkAddr", dap_chain_node_check_addr_py, METH_VARARGS | METH_STATIC, ""}, - {"aliasFind", dap_chain_node_alias_find_py, METH_VARARGS | METH_STATIC, ""}, - {"aliasRegister", dap_chain_node_alias_register_py, METH_VARARGS | METH_STATIC, ""}, - {"aliasDelete", dap_chain_node_alias_delete_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetNodeObject_DapChainNetNodeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Node", /* tp_name */ - sizeof(PyDapChainNodeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net node object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetNodeMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetNodeObject_DapChainNetNodeObjectType; #endif //_WRAPPING_DAP_CHAIN_NET_NODE_ diff --git a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_client.h b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_client.h index c940a7a4a9083d0814b5a80225642775a0d78efa..17e1833bdb97a3072eaea37b44b83bae52d80ea2 100644 --- a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_client.h +++ b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_client.h @@ -26,57 +26,7 @@ PyObject *dap_chain_node_client_send_ch_pkt_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_client_wait_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_client_set_callbacks_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainNodeClientMethods[] = { - {"clientConnect", dap_chain_client_connect_py, METH_VARARGS | METH_STATIC, ""}, - {"nodeClientConnect", (PyCFunction)dap_chain_node_client_connect_py, METH_VARARGS | METH_STATIC, ""}, - {"close", (PyCFunction)dap_chain_node_client_close_py, METH_VARARGS, ""}, - {"sendChPkt", (PyCFunction)dap_chain_node_client_send_ch_pkt_py, METH_VARARGS, ""}, - {"wait", (PyCFunction)dap_chain_node_client_wait_py, METH_VARARGS, ""}, - {"setCallbacks", (PyCFunction)dap_chain_node_client_set_callbacks_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNodeClientObject_DapChainNodeClientObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Node.Client", /* tp_name */ - sizeof(PyDapChainNodeClientObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net node client object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNodeClientMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNodeClientObject_DapChainNodeClientObjectType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_info.h b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_info.h index aa49697ed63a7c97a3372da74c5d4dc4447dbe59..c3145f6279dd2894c2bfd10ad865e89a10792fc1 100644 --- a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_info.h +++ b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_node_info.h @@ -17,53 +17,7 @@ typedef struct PyDapChainNodeInfo{ PyObject *dap_chain_node_info_save_py(PyObject *self, PyObject *args); PyObject *dap_chain_node_info_read_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetNodeInfoMethods[] = { - {"save", dap_chain_node_info_save_py, METH_VARARGS, ""}, - {"read", dap_chain_node_info_read_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNodeInfoObject_DapChainNodeInfoObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Chain.Node.Info", /* tp_name */ - sizeof(PyDapChainNodeInfoObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net node info object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetNodeInfoMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNodeInfoObject_DapChainNodeInfoObjectType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_state.h b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_state.h index 880a4f51640720bc6159560183740ad046955323..fefdf73c03fb7b177bab9b5475cfc56ba649bf72 100644 --- a/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_state.h +++ b/modules/cellframe-sdk/net/include/wrapping_dap_chain_net_state.h @@ -21,62 +21,7 @@ PyObject *NET_STATE_ONLINE_PY(void); PyObject *NET_STATE_SYNC_GDB_PY(void); PyObject *NET_STATE_SYNC_CHAINS_PY(void); -static PyMethodDef PyDapChainNetStateMethods[] = { - {"NET_STATE_OFFLINE", (PyCFunction)NET_STATE_OFFLINE_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_LINKS_PREPARE", (PyCFunction)NET_STATE_LINKS_PREPARE_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_LINKS_CONNECTING", (PyCFunction)NET_STATE_LINKS_CONNECTING_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_LINKS_ESTABLISHED", (PyCFunction)NET_STATE_LINKS_ESTABLISHED_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_ADDR_REQUEST", (PyCFunction)NET_STATE_ADDR_REQUEST_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_SYNC_GDB", (PyCFunction)NET_STATE_SYNC_GDB_PY, METH_NOARGS | METH_STATIC, ""}, - {"NET_STATE_SYNC_CHAINS", (PyCFunction)NET_STATE_SYNC_CHAINS_PY, METH_NOARGS | METH_STATIC, ""}, - /*{"csAdd", (PyCFunction)dap_chain_cs_add_py, METH_VARARGS, ""}, - {"csCreate", (PyCFunction)dap_chain_cs_create_py, METH_VARARGS, ""}, - {"classAdd", (PyCFunction)dap_chain_class_add_py, METH_VARARGS, ""}, - {"classCreate", (PyCFunction)dap_chain_class_create_py, METH_VARARGS, ""},*/ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetStateObject_DapChainNetStateObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetState", /* tp_name */ - sizeof(PyDapChainNetStateObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net staties object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainNetStateMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetStateObject_DapChainNetStateObjectType; #ifdef __cplusplus } diff --git a/modules/cellframe-sdk/net/src/libdap_chain_net_python.c b/modules/cellframe-sdk/net/src/libdap_chain_net_python.c index 3f83e3165f5da189eae0cb5fa547189740ddcfe4..a9396ea63fc46086b3dc7fa824d282a4b0e125cb 100644 --- a/modules/cellframe-sdk/net/src/libdap_chain_net_python.c +++ b/modules/cellframe-sdk/net/src/libdap_chain_net_python.c @@ -1,5 +1,79 @@ #include "libdap_chain_net_python.h" +PyMethodDef DapChainNetMethods[] = { + {"loadAll", dap_chain_net_load_all_py, METH_NOARGS | METH_STATIC, ""}, + {"stateGoTo", dap_chain_net_state_go_to_py, METH_VARARGS, ""}, + {"start", dap_chain_net_start_py, METH_VARARGS, ""}, + {"stop", dap_chain_net_stop_py, METH_VARARGS, ""}, + {"linksEstablish", dap_chain_net_links_establish_py, METH_VARARGS, ""}, + {"syncChains", dap_chain_net_sync_all_py, METH_VARARGS, ""}, + {"syncGdb", dap_chain_net_sync_gdb_py, METH_VARARGS, ""}, + {"syncAll", dap_chain_net_sync_all_py, METH_VARARGS, ""}, + {"procDatapool", dap_chain_net_proc_datapool_py, METH_VARARGS, ""}, + {"byName", dap_chain_net_by_name_py, METH_VARARGS | METH_STATIC, ""}, + {"byId", dap_chain_net_by_id_py, METH_VARARGS | METH_STATIC, ""}, + {"idByName", dap_chain_net_id_by_name_py, METH_VARARGS | METH_STATIC, ""}, + {"ledgerByNetName", dap_chain_ledger_by_net_name_py, METH_VARARGS | METH_STATIC, ""}, + {"getChainByName", dap_chain_net_get_chain_by_name_py, METH_VARARGS, ""}, + {"getCurAddr", dap_chain_net_get_cur_addr_py, METH_VARARGS, ""}, + {"getCurCell", dap_chain_net_get_cur_cell_py, METH_VARARGS, ""}, + {"getGdbGroupMempool", dap_chain_net_get_gdb_group_mempool_py, METH_VARARGS | METH_STATIC, ""}, + {"getGdbGroupMempoolByChainType", dap_chain_net_get_gdb_group_mempool_by_chain_type_py, METH_VARARGS, ""}, + {"linksConnect", dap_chain_net_links_connect_py, METH_VARARGS, ""}, + {"getChainByChainType", dap_chain_net_get_chain_by_chain_type_py, METH_VARARGS, ""}, + {"getLedger", dap_chain_net_get_ledger_py, METH_NOARGS, ""}, + {"getName", dap_chain_net_get_name_py, METH_NOARGS, ""}, + {"addNotify", (PyCFunction)dap_chain_net_add_notify_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef DapChainNetGetsSetsDef[] = { + {"id", (getter)dap_chain_net_python_get_id, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainNetObject_DapChainNetObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNet", /* tp_name */ + sizeof(PyDapChainNetObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapChainNet_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetMethods, /* tp_methods */ + 0, /* tp_members */ + DapChainNetGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + int dap_chain_net_init_py(void){ int res = dap_chain_net_init(); return res; @@ -8,6 +82,10 @@ void dap_chain_net_deinit_py(void){ dap_chain_net_deinit(); } +PyObject* PyDapChainNet_str(PyObject *self){ + return Py_BuildValue("s", ((PyDapChainNetObject*)self)->chain_net->pub.name); +} + PyObject *dap_chain_net_load_all_py(PyObject *self, PyObject *args){ dap_chain_net_load_all(); return PyLong_FromLong(0); @@ -175,3 +253,58 @@ PyObject *dap_chain_net_get_name_py(PyObject *self, PyObject *args){ PyObject *obj_name = PyUnicode_FromString(((PyDapChainNetObject*)self)->chain_net->pub.name); return obj_name; } + +typedef struct pvt_wrapping_dap_chain_net_notify_callback_list{ + dap_chain_net_t *net; + PyObject *func; + struct pvt_wrapping_dap_chain_net_notify_callback_list *next; +}pvt_wrapping_dap_chain_net_notify_callback_list_t; + +pvt_wrapping_dap_chain_net_notify_callback_list_t *pvt_list_notify = NULL; + +void pvt_dap_chain_net_py_notify_handler(void * a_arg, const char a_op_code, const char * a_group, + const char * a_key, const void * a_value, const size_t a_value_len){ + PyGILState_STATE state = PyGILState_Ensure(); + PyObject *l_obj_value = NULL; + char *l_op_code = DAP_NEW_Z_SIZE(char, 1); + l_op_code[0] = a_op_code; + if (a_value == NULL || a_value_len == 0){ + l_obj_value = Py_None; + } else { + l_obj_value = PyBytes_FromStringAndSize(a_value, (Py_ssize_t)a_value_len); + } + PyObject *argv = Py_BuildValue("sssO", l_op_code, a_group, a_key, l_obj_value); + Py_INCREF(argv); + for (pvt_wrapping_dap_chain_net_notify_callback_list_t *pvt = pvt_list_notify; pvt != NULL; pvt = pvt->next){ + if (pvt->net == a_arg){ + Py_INCREF(pvt->func); + PyEval_CallObject(pvt->func, argv); + Py_XDECREF(pvt->func); + } + } + Py_XDECREF(argv); + DAP_FREE(l_op_code); + PyGILState_Release(state); +} + +PyObject *dap_chain_net_add_notify_py(PyObject *self, PyObject *args){ + PyObject *obj_func = NULL; + if (!PyArg_ParseTuple(args, "O", &obj_func)){ + return NULL; + } + if (!PyCallable_Check(obj_func)){ + PyErr_SetString(PyExc_AttributeError, "The argument passed is not a function that can be called."); + return NULL; + } + for(pvt_wrapping_dap_chain_net_notify_callback_list_t *list = pvt_list_notify; list != NULL; list = list->next){ + if (list->net == ((PyDapChainNetObject*)self)->chain_net) + break; + dap_chain_net_add_notify_callback(((PyDapChainNetObject*)self)->chain_net, pvt_dap_chain_net_py_notify_handler); + } + pvt_wrapping_dap_chain_net_notify_callback_list_t *l_element = DAP_NEW(pvt_wrapping_dap_chain_net_notify_callback_list_t); + l_element->net = ((PyDapChainNetObject*)self)->chain_net; + l_element->func = obj_func; + Py_INCREF(obj_func); + LL_APPEND(pvt_list_notify, l_element); + return Py_None; +} diff --git a/modules/cellframe-sdk/net/src/wrapping_dap_app_cli_server.c b/modules/cellframe-sdk/net/src/wrapping_dap_app_cli_server.c index b98191cd5750cd4af5263a810a79330dd4926376..e56215319562d11fc5826d3b6727cfd16cf80b86 100644 --- a/modules/cellframe-sdk/net/src/wrapping_dap_app_cli_server.c +++ b/modules/cellframe-sdk/net/src/wrapping_dap_app_cli_server.c @@ -2,6 +2,55 @@ #define LOG_TAG "wrapping_dap_app_cli_server" +PyMethodDef DapChainNodeCliMethods[] = { + {"cmdItemCreate", dap_chain_node_cli_cmd_item_create_py, METH_VARARGS| METH_STATIC, ""}, + {"setReplyText", dap_chain_node_cli_set_reply_text_py, METH_VARARGS| METH_STATIC, ""}, + {"getByAlias", dap_chain_node_addr_get_by_alias_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNodeCliObject_DapChainNodeCliObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "AppCliServer", /* tp_name */ + sizeof(PyDapAppCliServerObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net node cli object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNodeCliMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + DapChainNodeCliObject_new, /* tp_new */ +}; + int dap_chain_node_cli_init_py(dap_config_t *g_config){ log_it(L_DEBUG, "Init app cli server"); dap_chain_node_cli_init(g_config); @@ -100,6 +149,7 @@ void element_py_func_del_all(){ } static int wrapping_cmdfunc(int argc, char **argv, char **str_reply){ + PyGILState_STATE l_state = PyGILState_Ensure(); size_t id_str_replay = elements_str_reply_add(str_reply); PyObject *obj_argv = stringToPyList(argc, argv); PyObject *obj_id_str_replay = PyLong_FromSize_t(id_str_replay); @@ -113,6 +163,7 @@ static int wrapping_cmdfunc(int argc, char **argv, char **str_reply){ } Py_XDECREF(arglist); Py_XDECREF(obj_argv); + PyGILState_Release(l_state); elements_str_reply_delete(id_str_replay); return 0; } diff --git a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node.c b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node.c index c302deb8d9d3f6941ea759689da9f340e8b63f14..f7e79d908c6b4c17344638c59b81562bf213e55a 100644 --- a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node.c +++ b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node.c @@ -1,5 +1,56 @@ #include "wrapping_dap_chain_net_node.h" +PyMethodDef DapChainNetNodeMethods[] = { + {"genAddr", dap_chain_node_gen_addr_py, METH_VARARGS | METH_STATIC, ""}, + {"checkAddr", dap_chain_node_check_addr_py, METH_VARARGS | METH_STATIC, ""}, + {"aliasFind", dap_chain_node_alias_find_py, METH_VARARGS | METH_STATIC, ""}, + {"aliasRegister", dap_chain_node_alias_register_py, METH_VARARGS | METH_STATIC, ""}, + {"aliasDelete", dap_chain_node_alias_delete_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetNodeObject_DapChainNetNodeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Node", /* tp_name */ + sizeof(PyDapChainNodeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net node object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetNodeMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_chain_node_gen_addr_py(PyObject *self, PyObject *args){ PyObject *obj_net; PyObject *obj_cell_id; diff --git a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_client.c b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_client.c index b4a1593ee812f1d74918b5b5842cca175c981946..fc3772ad6c9a7df06db335f8e102365d6ce40a4d 100644 --- a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_client.c +++ b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_client.c @@ -7,6 +7,58 @@ void dap_chain_node_client_deinit_py(void){ dap_chain_node_client_deinit(); } +PyMethodDef DapChainNodeClientMethods[] = { + {"clientConnect", dap_chain_client_connect_py, METH_VARARGS | METH_STATIC, ""}, + {"nodeClientConnect", (PyCFunction)dap_chain_node_client_connect_py, METH_VARARGS | METH_STATIC, ""}, + {"close", (PyCFunction)dap_chain_node_client_close_py, METH_VARARGS, ""}, + {"sendChPkt", (PyCFunction)dap_chain_node_client_send_ch_pkt_py, METH_VARARGS, ""}, + {"wait", (PyCFunction)dap_chain_node_client_wait_py, METH_VARARGS, ""}, + {"setCallbacks", (PyCFunction)dap_chain_node_client_set_callbacks_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNodeClientObject_DapChainNodeClientObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Node.Client", /* tp_name */ + sizeof(PyDapChainNodeClientObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net node client object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNodeClientMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_chain_client_connect_py(PyObject *self, PyObject *args){ PyObject *obj_net; PyObject *obj_node_info; diff --git a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_info.c b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_info.c index 36e1915a3f1ca5d2178d0efe0ee7a45f5b521203..91de94dbc93be6421ccd44a8a93bb1c2f4046328 100644 --- a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_info.c +++ b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_node_info.c @@ -1,5 +1,53 @@ #include "wrapping_dap_chain_net_node_info.h" +PyMethodDef DapChainNetNodeInfoMethods[] = { + {"save", dap_chain_node_info_save_py, METH_VARARGS, ""}, + {"read", dap_chain_node_info_read_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNodeInfoObject_DapChainNodeInfoObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Chain.Node.Info", /* tp_name */ + sizeof(PyDapChainNodeInfoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net node info object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetNodeInfoMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_chain_node_info_save_py(PyObject *self, PyObject *args){ PyObject *obj_net; if (!PyArg_ParseTuple(args, "O", &obj_net)) diff --git a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_state.c b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_state.c index 1042393fe4411d0da97437332de294f709eb26b4..d86783b6d03bfc3da659027c24f48cf09880fe89 100644 --- a/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_state.c +++ b/modules/cellframe-sdk/net/src/wrapping_dap_chain_net_state.c @@ -1,5 +1,62 @@ #include "wrapping_dap_chain_net_state.h" +PyMethodDef PyDapChainNetStateMethods[] = { + {"NET_STATE_OFFLINE", (PyCFunction)NET_STATE_OFFLINE_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_LINKS_PREPARE", (PyCFunction)NET_STATE_LINKS_PREPARE_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_LINKS_CONNECTING", (PyCFunction)NET_STATE_LINKS_CONNECTING_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_LINKS_ESTABLISHED", (PyCFunction)NET_STATE_LINKS_ESTABLISHED_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_ADDR_REQUEST", (PyCFunction)NET_STATE_ADDR_REQUEST_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_SYNC_GDB", (PyCFunction)NET_STATE_SYNC_GDB_PY, METH_NOARGS | METH_STATIC, ""}, + {"NET_STATE_SYNC_CHAINS", (PyCFunction)NET_STATE_SYNC_CHAINS_PY, METH_NOARGS | METH_STATIC, ""}, + /*{"csAdd", (PyCFunction)dap_chain_cs_add_py, METH_VARARGS, ""}, + {"csCreate", (PyCFunction)dap_chain_cs_create_py, METH_VARARGS, ""}, + {"classAdd", (PyCFunction)dap_chain_class_add_py, METH_VARARGS, ""}, + {"classCreate", (PyCFunction)dap_chain_class_create_py, METH_VARARGS, ""},*/ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetStateObject_DapChainNetStateObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetState", /* tp_name */ + sizeof(PyDapChainNetStateObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net staties object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainNetStateMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *NET_STATE_OFFLINE_PY(void){ PyObject *obj = _PyObject_New(&DapChainNetStateObject_DapChainNetStateObjectType); ((PyDapChainNetStateObject*)obj)->state = NET_STATE_OFFLINE; diff --git a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv.h b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv.h index a1364fe48f7b419297334ea6abe9ef33391c1a1c..f8258ebfe74bbf5a22fa7bc5b31b357f82b5b9cd 100644 --- a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv.h +++ b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv.h @@ -30,54 +30,4 @@ PyObject *wrapping_dap_chain_net_srv_get_grace_period(PyObject *self, void *clos PyObject *wrapping_dap_chain_net_srv_set_callback_channel(PyObject *self, PyObject *args); //PyObject *wrapping_dap_chain_net_srv_issue_receipt(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetSrvMethods[]={ - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef DapChaiNetSrvGetsSets[] = { - {"uid", (getter)wrapping_dap_chain_net_srv_get_uid, NULL, NULL, NULL}, - {"gracePeriod", (getter)wrapping_dap_chain_net_srv_get_grace_period, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainNetSrvObject_DapChainNetSrvObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrv", /* tp_name */ - sizeof(PyDapChainNetSrvObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net service object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetSrvMethods, /* tp_methods */ - 0, /* tp_members */ - DapChaiNetSrvGetsSets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PyDapChainNetSrv_init, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetSrvObject_DapChainNetSrvObjectType; diff --git a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client.h b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client.h index 2051f1b967b35e97833ad5b12fd76e1b70566a29..0f0f53a3b8f2be43607f695255f1eb9492242a49 100644 --- a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client.h +++ b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client.h @@ -22,51 +22,4 @@ PyObject *wrapping_dap_chain_net_srv_client_check(PyObject *self, PyObject *args PyObject *wrapping_dap_chain_net_srv_client_request(PyObject *self, PyObject *args); PyObject *wrapping_dap_chain_net_srv_client_write(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetSrvClientMethods[]={ - {"check", (PyCFunction)wrapping_dap_chain_net_srv_client_check, METH_VARARGS, ""}, - {"request", (PyCFunction)wrapping_dap_chain_net_srv_client_request, METH_VARARGS, ""}, - {"write", (PyCFunction)wrapping_dap_chain_net_srv_client_write, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetSrvClientObject_DapChainNetSrvClientObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrvClient", /* tp_name */ - sizeof(PyDapChainNetSrvClientObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net service client object",/* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetSrvClientMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)PyDapChainNetSrvClient_init, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetSrvClientObject_DapChainNetSrvClientObjectType; diff --git a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client_remote.h b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client_remote.h index d8b8d19afae6b4a9b762a60d34cc418ca483a457..40ce0b336788bc1eb1e6adbd997968b56127092f 100644 --- a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client_remote.h +++ b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_client_remote.h @@ -24,62 +24,7 @@ PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_send(PyObject *self //PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_prev(PyObject *self, void *closure); //PyObject *wrapping_dap_chain_net_srv_client_remote_get_bytes_next(PyObject *self, void *closure); -static PyMethodDef DapChainNetSrvClientRemoteMethods[]={ - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef DapChaiNetSrvClientRemoteGetsSets[] = { - {"ch", (getter)wrapping_dap_chain_net_srv_client_remote_get_ch, NULL, NULL, NULL}, - {"tsCreated", (getter)wrapping_dap_chain_net_srv_client_remote_get_ts_created, NULL, NULL, NULL}, - {"created", (getter)wrapping_dap_chain_net_srv_client_remote_get_created, NULL, NULL, NULL}, - {"streamWorker", (getter)wrapping_dap_chain_net_srv_client_remote_get_stream_worker, NULL, NULL, NULL}, - {"sessionId", (getter)wrapping_dap_chain_net_srv_client_remote_get_session_id, NULL, NULL, NULL}, - {"bytesReceived", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_received, NULL, NULL, NULL}, - {"bytesSend", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_send, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainNetSrvClientRemoteObject_DapChainNetSrvClientRemoteObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrvClientRemote", /* tp_name */ - sizeof(PyDapChainNetSrvClientRemoteObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net service client remote object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetSrvClientRemoteMethods, /* tp_methods */ - 0, /* tp_members */ - DapChaiNetSrvClientRemoteGetsSets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetSrvClientRemoteObject_DapChainNetSrvClientRemoteObjectType; #endif //WRAPPING_DAP_CHAIN_NET_SRV_CLIENT_REMOTE_H diff --git a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_common.h b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_common.h new file mode 100644 index 0000000000000000000000000000000000000000..889d37d568777dc91f199e28460982a144ce5a41 --- /dev/null +++ b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_common.h @@ -0,0 +1,36 @@ +#pragma once + +#include "Python.h" +#include "dap_chain_net_srv.h" +#include "wrapping_dap_chain_common.h" +#include "libdap_chain_net_python.h" + +/*wrapping dap_chain_net_srv_price*/ +typedef struct PyDapChainNetSrvPrice{ + PyObject_HEAD + dap_chain_net_srv_price_t price; +}PyDapChainNetSrvPriceObject; + +PyObject *wrapping_dap_chain_net_srv_get_wallet(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_net_name(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_net(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_value_datoshi(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_token(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_units(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_get_units_uid(PyObject *self, void *closure); + +extern PyTypeObject DapChainNetSrvPriceObject_DapChainNetSrvPriceObjectType; + +/*wrapping dap_chain_net_srv_order_direction*/ +typedef struct PyDapChainNetSrvOrderDirection{ + PyObject_HEAD + dap_chain_net_srv_order_direction_t direction; +}PyDapChainNetSrvOrderDirectionObject; + +PyObject *DapChainNetSrvOrderDirection_str(PyObject *self); + +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined(PyObject *self, PyObject *args); + +extern PyTypeObject DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType; diff --git a/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_order.h b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_order.h new file mode 100644 index 0000000000000000000000000000000000000000..40d03fc2c292ae74a29218595187382f37ae26ed --- /dev/null +++ b/modules/cellframe-sdk/net/srv/include/wrapping_dap_chain_net_srv_order.h @@ -0,0 +1,53 @@ +#pragma once + +#include "Python.h" +#include "dap_chain_net_srv_order.h" +#include "wrapping_dap_chain_common.h" +#include "libdap_chain_net_python.h" +#include "wrapping_dap_chain_net_srv_common.h" +#include "datetime.h" +#include "libdap_crypto_key_python.h" + +typedef struct PyDapChainNetSrvOrder{ + PyObject_HEAD + dap_chain_net_srv_order_t *order; + dap_chain_net_srv_order_old_t *order_old; +}PyDapChainNetSrvOrderObject; + +//constructor +int PyDapChainNetSrvOrder_init(PyDapChainNetSrvOrderObject *self, PyObject *args, PyObject *kwds); + +//Attributes +PyObject *wrapping_dap_chain_net_srv_order_get_version(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_uid(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_direction(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_node_addr(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_unit(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_created(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_expires(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_ticker(PyObject *self, void *closure); +//PyObject *wrapping_dap_chain_net_srv_order_get_srv_free_space(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_size(PyObject *self, void *closure); +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign(PyObject *self, void *closure); +//Functions +PyObject *wrapping_dap_chain_net_srv_order_get_size(PyObject *self, PyObject *args); +//PyObject *wrapping_dap_chain_net_srv_order_set_continent_region(PyObject *self, PyObject *args); +//PyObject *wrapping_dap_chain_net_srv_order_get_continent_region(PyObject *self, PyObject *args); + +//PyObject *wrapping_dap_chain_net_srv_order_get_country_code(PyObject *self, PyObject *args); +//PyObject *wrapping_dap_chain_net_srv_order_continents_count(PyObject *self, PyObject *args); +//PyObject *wrapping_dap_chain_net_srv_order_continent_to_str(PyObject *self, PyObject *args); +//PyObject *wrapping_dap_chain_net_srv_order_continent_to_num(PyObject *self, PyObject *args); + +PyObject *wrapping_dap_chain_net_srv_order_find(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_delete(PyObject *self, PyObject *args); + +PyObject *wrapping_dap_chain_net_srv_order_find_all_by(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_save(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_get_gdb_group(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_get_nodelist_group(PyObject *self, PyObject *args); +PyObject *wrapping_dap_chain_net_srv_order_add_notify_callback(PyObject *self, PyObject *args); + +extern PyTypeObject DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType; diff --git a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv.c b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv.c index eda941815deb1c05801f2ceec334115628dc2c30..64c4436e26b21b6bad86e26cec98ad1df1879fb8 100644 --- a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv.c +++ b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv.c @@ -2,6 +2,58 @@ #define LOG_TAG "wrapping_dap_chain_net_srv" +PyMethodDef DapChainNetSrvMethods[]={ + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef DapChaiNetSrvGetsSets[] = { + {"uid", (getter)wrapping_dap_chain_net_srv_get_uid, NULL, NULL, NULL}, + {"gracePeriod", (getter)wrapping_dap_chain_net_srv_get_grace_period, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainNetSrvObject_DapChainNetSrvObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrv", /* tp_name */ + sizeof(PyDapChainNetSrvObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net service object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvMethods, /* tp_methods */ + 0, /* tp_members */ + DapChaiNetSrvGetsSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PyDapChainNetSrv_init, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *_wrapping_dac_chain_callback_data_t_get_tuple( dap_chain_net_srv_t *a_srv, uint32_t a_usage_id, diff --git a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client.c b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client.c index 88623a3450921ad5936e73d9c2ef1e8de4988af1..c927d9a73ba3e4d9532bdd755253d1c67ceaa814 100644 --- a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client.c +++ b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client.c @@ -2,6 +2,55 @@ #define LOG_TAG "wrapping_dap_chain_net_srv_client" +PyMethodDef DapChainNetSrvClientMethods[]={ + {"check", (PyCFunction)wrapping_dap_chain_net_srv_client_check, METH_VARARGS, ""}, + {"request", (PyCFunction)wrapping_dap_chain_net_srv_client_request, METH_VARARGS, ""}, + {"write", (PyCFunction)wrapping_dap_chain_net_srv_client_write, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetSrvClientObject_DapChainNetSrvClientObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvClient", /* tp_name */ + sizeof(PyDapChainNetSrvClientObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net service client object",/* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvClientMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PyDapChainNetSrvClient_init, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + static void _wrapping_dap_chain_net_srv_client_callback_connected(dap_chain_net_srv_client_t* a_client, void *a_arg){ PyDapChainNetSrvClientObject *py_client = (PyDapChainNetSrvClientObject *)a_client->_inheritor; PyObject *l_call = py_client->callback_connected; diff --git a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client_remote.c b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client_remote.c index d57b3a0fad4e384db03b92337296590aedfc7450..20e1bf60a0f2572ec60aaf5ca6583e92cce48332 100644 --- a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client_remote.c +++ b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_client_remote.c @@ -4,6 +4,63 @@ #define WRAPPING_DAP_CHAIN_NET_SRV_CLIENT(a) ((dap_chain_net_srv_client_remote_t*)((PyDapPyDapChainNetSrvClientObject*)a)->srv_client) #define _PyDapChainNetSrvClient(a) ((PyDapChainNetSrvClient*)a) +PyMethodDef DapChainNetSrvClientRemoteMethods[]={ + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef DapChaiNetSrvClientRemoteGetsSets[] = { + {"ch", (getter)wrapping_dap_chain_net_srv_client_remote_get_ch, NULL, NULL, NULL}, + {"tsCreated", (getter)wrapping_dap_chain_net_srv_client_remote_get_ts_created, NULL, NULL, NULL}, + {"created", (getter)wrapping_dap_chain_net_srv_client_remote_get_created, NULL, NULL, NULL}, + {"streamWorker", (getter)wrapping_dap_chain_net_srv_client_remote_get_stream_worker, NULL, NULL, NULL}, + {"sessionId", (getter)wrapping_dap_chain_net_srv_client_remote_get_session_id, NULL, NULL, NULL}, + {"bytesReceived", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_received, NULL, NULL, NULL}, + {"bytesSend", (getter)wrapping_dap_chain_net_srv_client_remote_get_bytes_send, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainNetSrvClientRemoteObject_DapChainNetSrvClientRemoteObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvClientRemote", /* tp_name */ + sizeof(PyDapChainNetSrvClientRemoteObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net service client remote object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvClientRemoteMethods, /* tp_methods */ + 0, /* tp_members */ + DapChaiNetSrvClientRemoteGetsSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_net_srv_client_remote_get_ch(PyObject *self, void *closure){ (void)closure; //TODO diff --git a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_common.c b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_common.c new file mode 100644 index 0000000000000000000000000000000000000000..26030ed8b13f8765bffd1d9463682d4eaa612d9c --- /dev/null +++ b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_common.c @@ -0,0 +1,189 @@ +#include "wrapping_dap_chain_net_srv_common.h" + +/* Attribute for ChainNetSrvPrice */ +#define WRAPPING_DAP_CHAIN_NET_SRV_PRICE(a) ((PyDapChainNetSrvPriceObject*) a) + +PyGetSetDef DapChainNetSrvPrice_GetsSetsDef[] = { + {"wallet", (getter)wrapping_dap_chain_net_srv_get_wallet, NULL, NULL, NULL}, + {"netName", (getter)wrapping_dap_chain_net_srv_get_net_name, NULL, NULL, NULL}, + {"net", (getter)wrapping_dap_chain_net_srv_get_net, NULL, NULL, NULL}, + {"valueDatoshi", (getter)wrapping_dap_chain_net_srv_get_value_datoshi, NULL, NULL, NULL}, + {"token", (getter)wrapping_dap_chain_net_srv_get_token, NULL, NULL, NULL}, + {"units", (getter)wrapping_dap_chain_net_srv_get_units, NULL, NULL, NULL}, + {"unitsUid", (getter)wrapping_dap_chain_net_srv_get_units_uid, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainNetSrvPriceObject_DapChainNetSrvPriceObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvPrice", /* tp_name */ + sizeof(PyDapChainNetSrvPriceObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv price object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapChainNetSrvPrice_GetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +PyObject *wrapping_dap_chain_net_srv_get_wallet(PyObject *self, void *closure){ + (void)closure; + +} +PyObject *wrapping_dap_chain_net_srv_get_net_name(PyObject *self, void *closure){ + (void)closure; + return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.net_name); +} +PyObject *wrapping_dap_chain_net_srv_get_net(PyObject *self, void *closure){ + (void)closure; + PyDapChainNetObject *l_obj_net = PyObject_New(PyDapChainNetObject, &DapChainNetObject_DapChainNetObjectType); + PyObject_Dir((PyObject*)l_obj_net); + l_obj_net->chain_net = WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.net; + return (PyObject*)l_obj_net; +} +PyObject *wrapping_dap_chain_net_srv_get_value_datoshi(PyObject *self, void *closure){ + (void)closure; + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.value_datoshi); +} +PyObject *wrapping_dap_chain_net_srv_get_token(PyObject *self, void *closure){ + (void)closure; + return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.token); +} +PyObject *wrapping_dap_chain_net_srv_get_units(PyObject *self, void *closure){ + (void)closure; + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.units); +} +PyObject *wrapping_dap_chain_net_srv_get_units_uid(PyObject *self, void *closure){ + (void)closure; + PyDapChainNetSrvPriceUnitUIDObject *l_price_unit_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)l_price_unit_uid); + l_price_unit_uid->price_unit_uid = WRAPPING_DAP_CHAIN_NET_SRV_PRICE(self)->price.units_uid; + return (PyObject*)l_price_unit_uid; +} + +/* wrapping dap_chain_net_srv_order_direction */ +PyMethodDef DapChainNetSrvOrderDirection_Methods[] = { + {"getDirBuy", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy, METH_NOARGS | METH_STATIC, ""}, + {"getDirSell", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell, METH_NOARGS | METH_STATIC, ""}, + {"getDirUndefined", (PyCFunction)wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined, METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvOrderDirection", /* tp_name */ + sizeof(PyDapChainNetSrvOrderDirectionObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + DapChainNetSrvOrderDirection_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv order direction object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvOrderDirection_Methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +PyObject *DapChainNetSrvOrderDirection_str(PyObject *self){ + char *ret; + switch (((PyDapChainNetSrvOrderDirectionObject*)self)->direction) { + case 1: + ret = "SERV_DIR_BUY"; + break; + case 2: + ret = "SERV_DIR_SELL"; + break; + default: + ret = "SERV_DIR_UNDEFINED"; + break; + } + return Py_BuildValue("s", ret); +} + +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_buy(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New( + PyDapChainNetSrvOrderDirectionObject, + &DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType); + PyObject_Dir((PyObject*)l_obj); + l_obj->direction = SERV_DIR_BUY; + return (PyObject*)l_obj; +} +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_sell(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New( + PyDapChainNetSrvOrderDirectionObject, + &DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType); + PyObject_Dir((PyObject*)l_obj); + l_obj->direction = SERV_DIR_SELL; + return (PyObject*)l_obj; +} +PyObject *wrapping_dap_chain_net_srv_order_direction_get_serv_dir_undefined(PyObject *self, PyObject *args){ + (void)self; + (void)args; + PyDapChainNetSrvOrderDirectionObject *l_obj = PyObject_New( + PyDapChainNetSrvOrderDirectionObject, + &DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType); + PyObject_Dir((PyObject*)l_obj); + l_obj->direction = SERV_DIR_UNDEFINED; + return (PyObject*)l_obj; +} diff --git a/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_order.c b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_order.c new file mode 100644 index 0000000000000000000000000000000000000000..2526ce34e21641bf227289300dbdc4ab610cd32b --- /dev/null +++ b/modules/cellframe-sdk/net/srv/src/wrapping_dap_chain_net_srv_order.c @@ -0,0 +1,466 @@ +#include "wrapping_dap_chain_net_srv_order.h" + +#define WRAPPING_DAP_CHAIN_NET_SRV_ORDER(a) ((PyDapChainNetSrvOrderObject*)a) + +PyMethodDef DapChainNetSrvOrderMethods[]={ + {"size", (PyCFunction)wrapping_dap_chain_net_srv_order_get_size, METH_VARARGS, ""}, + {"find", (PyCFunction)wrapping_dap_chain_net_srv_order_find, METH_VARARGS | METH_STATIC, ""}, + {"delete", (PyCFunction)wrapping_dap_chain_net_srv_order_delete, METH_VARARGS | METH_STATIC, ""}, + {"save", (PyCFunction)wrapping_dap_chain_net_srv_order_save, METH_VARARGS, ""}, + {"getGdbGroup", (PyCFunction)wrapping_dap_chain_net_srv_order_get_gdb_group, METH_VARARGS | METH_STATIC, ""}, + {"getNodelistGroup", (PyCFunction)wrapping_dap_chain_net_srv_order_get_nodelist_group, METH_VARARGS | METH_STATIC, ""}, + {"addNotify", (PyCFunction)wrapping_dap_chain_net_srv_order_add_notify_callback, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef DapChaiNetSrvOrderGetsSets[] = { + {"version", (getter)wrapping_dap_chain_net_srv_order_get_version, NULL, NULL, NULL}, + {"uid", (getter)wrapping_dap_chain_net_srv_order_get_srv_uid, NULL, NULL, NULL}, + {"direction", (getter)wrapping_dap_chain_net_srv_order_get_srv_direction, NULL, NULL, NULL}, + {"nodeAddr", (getter)wrapping_dap_chain_net_srv_order_get_srv_node_addr, NULL, NULL, NULL}, + {"condHash", (getter)wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash, NULL, NULL, NULL}, + {"priceUnit", (getter)wrapping_dap_chain_net_srv_order_get_srv_price_unit, NULL, NULL, NULL}, + {"tsCreated", (getter)wrapping_dap_chain_net_srv_order_get_srv_ts_created, NULL, NULL, NULL}, + {"tsExpires", (getter)wrapping_dap_chain_net_srv_order_get_srv_ts_expires, NULL, NULL, NULL}, + {"srvPrice", (getter)wrapping_dap_chain_net_srv_order_get_srv_price, NULL, NULL, NULL}, + {"srvPriceTicker", (getter)wrapping_dap_chain_net_srv_order_get_srv_price_ticker, NULL, NULL, NULL}, + {"extSize", (getter)wrapping_dap_chain_net_srv_order_get_srv_ext_size, NULL, NULL, NULL}, + {"extSign", (getter)wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvOrder", /* tp_name */ + sizeof(PyDapChainNetSrvOrderObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv client object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvOrderMethods, /* tp_methods */ + 0, /* tp_members */ + DapChaiNetSrvOrderGetsSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)PyDapChainNetSrvOrder_init, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + + +typedef struct _wrapping_list_func_callables{ + PyObject *func; + struct _wrapping_list_func_callables *next; +}_wrapping_list_func_callables_t; + +_wrapping_list_func_callables_t *_s_callbacks = NULL; + +void _wrapping_handler_add_order_notify(void * a_arg, const char a_op_code, const char * a_group, + const char * a_key, const void * a_value, const size_t a_value_len){ + PyObject *l_obj_order = Py_None; + if (a_value_len != 0) { + PyDapChainNetSrvOrderObject *l_obj_order_tmp = PyObject_New(PyDapChainNetSrvOrderObject, + &DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType); + PyObject_Dir((PyObject *) l_obj_order_tmp); + l_obj_order_tmp->order = DAP_NEW_Z_SIZE(void, a_value_len); + memcpy(l_obj_order_tmp->order, a_value, a_value_len); + l_obj_order = (PyObject*)l_obj_order_tmp; + } + char *l_op_code = DAP_NEW_Z_SIZE(char, 2); + l_op_code[0] = a_op_code; + l_op_code[1] = '\0'; + char *l_group = dap_strdup(a_group); + char *l_key = dap_strdup(a_key); + PyObject *l_args = Py_BuildValue("sssO", l_op_code, l_group, l_key, l_obj_order); + Py_INCREF(l_args); + _wrapping_list_func_callables_t *callbacks = NULL; + PyGILState_STATE state = PyGILState_Ensure(); + LL_FOREACH(_s_callbacks, callbacks){ + PyObject *l_call = callbacks->func; + Py_INCREF(l_call); + PyEval_CallObject(l_call, l_args); + Py_XDECREF(l_call); + } + PyGILState_Release(state); + Py_DECREF(l_args); +} + +int PyDapChainNetSrvOrder_init(PyDapChainNetSrvOrderObject *self, PyObject *args, PyObject *kwds){ + const char *kwlist[] = { + "net", + "direction", + "srvUID", + "nodeAddr", + "txCondHash", + "price", + "priceUnit", + "priceTicker", + "expires", + "ext", +// "extSize", +// "region", +// "continentNum", + "key", + NULL + }; + PyObject *obj_net, *obj_direction, *obj_srv_uid, *obj_node_addr, *obj_tx_cond_hash, *obj_price_unit; + uint64_t price; + char *price_ticker; + unsigned long expires; + PyObject *obj_ext, *obj_key; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOOOOkOsOOO", kwlist, &obj_net, &obj_direction, &obj_srv_uid, + &obj_node_addr, &obj_tx_cond_hash, &price, &obj_price_unit, &price_ticker, + &expires, &obj_ext, &obj_key)){ + return -1; + } + if (!PyDapChainNet_Check(obj_net)){ + return -1; + } + void* l_ext = (void*)PyBytes_AsString(obj_ext); + size_t l_ext_size = PyBytes_Size(obj_ext); + uint256_t l_price = dap_chain_uint256_from(price); +// dap_chain_net_srv_order_direction_t l_direction = ; +// dap_chain_net_t *l_net = ; +// dap_chain_net_srv_order_compose() +// dap_chain_node_addr_t l_addr = ; + if (obj_tx_cond_hash == Py_None){ + dap_chain_hash_fast_t l_hf = {0}; + self->order = dap_chain_net_srv_order_compose( + ((PyDapChainNetObject *) obj_net)->chain_net, + ((PyDapChainNetSrvOrderDirectionObject *) obj_direction)->direction, + ((PyDapChainNetSrvUIDObject *) obj_srv_uid)->net_srv_uid, + *((PyDapChainNodeAddrObject *) obj_node_addr)->node_addr, + l_hf, + l_price, + ((PyDapChainNetSrvPriceUnitUIDObject *) obj_price_unit)->price_unit_uid, + price_ticker, + (time_t) expires, + l_ext, + l_ext_size, + "", + 0, + ((PyCryptoKeyObject *) obj_key)->key + ); + } else { + self->order = dap_chain_net_srv_order_compose( + ((PyDapChainNetObject *) obj_net)->chain_net, + ((PyDapChainNetSrvOrderDirectionObject *) obj_direction)->direction, + ((PyDapChainNetSrvUIDObject *) obj_srv_uid)->net_srv_uid, + *((PyDapChainNodeAddrObject *) obj_node_addr)->node_addr, + *((PyDapHashFastObject *) obj_tx_cond_hash)->hash_fast, + l_price, + ((PyDapChainNetSrvPriceUnitUIDObject *) obj_price_unit)->price_unit_uid, + price_ticker, + (time_t) expires, + l_ext, + l_ext_size, + "", + 0, + ((PyCryptoKeyObject *) obj_key)->key + ); + } + return 0; +} + +PyObject *wrapping_dap_chain_net_srv_order_get_version(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("H", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->version); + }else{ + return Py_BuildValue("H", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->version); + } +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_uid(PyObject *self, void *closure){ + (void)closure; + PyDapChainNetSrvUIDObject *obj_srv_uid = PyObject_New(PyDapChainNetSrvUIDObject, &DapChainNetSrvUIDObject_DapChainNetSrvUIDObjectType); + PyObject_Dir((PyObject*)obj_srv_uid); + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + obj_srv_uid->net_srv_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->srv_uid; + }else{ + obj_srv_uid->net_srv_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->srv_uid; + } + return (PyObject*)obj_srv_uid; +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_direction(PyObject *self, void *closure){ + (void)closure; + PyDapChainNetSrvOrderDirectionObject *srv_direction = PyObject_New(PyDapChainNetSrvOrderDirectionObject, &DapChainNetSrvOrderDirectionObject_DapChainNetSrvOrderDirectionObjectType); + PyObject_Dir((PyObject*)srv_direction); + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + srv_direction->direction = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->direction; + }else{ + srv_direction->direction = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->direction; + } + return (PyObject*)srv_direction; +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_node_addr(PyObject *self, void *closure){ + (void)closure; + PyDapChainNodeAddrObject *l_obj_node_addr = PyObject_New(PyDapChainNodeAddrObject, &DapChainNodeAddrObject_DapChainNodeAddrObjectType); + PyObject_Dir((PyObject*)l_obj_node_addr); + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + l_obj_node_addr->node_addr = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->node_addr; + }else{ + l_obj_node_addr->node_addr = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->node_addr; + } + return (PyObject*)l_obj_node_addr; +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_tx_cond_hash(PyObject *self, void *closure){ + (void)closure; + PyDapHashFastObject *l_obj_hf = PyObject_New(PyDapHashFastObject, &DapHashFastObject_DapHashFastObjectType); + PyObject_Dir((PyObject*)l_obj_hf); + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + l_obj_hf->hash_fast = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->tx_cond_hash; + }else{ + l_obj_hf->hash_fast = &WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->tx_cond_hash; + } + return (PyObject*)l_obj_hf; +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_unit(PyObject *self, void *closure){ + (void)closure; + PyDapChainNetSrvPriceUnitUIDObject *l_obj_srv_price_uid = PyObject_New(PyDapChainNetSrvPriceUnitUIDObject, &DapChainNetSrvPriceUnitUIDObject_DapChainNetSrvPriceUnitUIDObjectType); + PyObject_Dir((PyObject*)l_obj_srv_price_uid); + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + l_obj_srv_price_uid->price_unit_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->price_unit; + }else{ + l_obj_srv_price_uid->price_unit_uid = WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price_unit; + } + return (PyObject*)l_obj_srv_price_uid; +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_created(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->ts_created); + }else{ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ts_created); + } +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ts_expires(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->ts_expires); + }else{ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ts_expires); + } +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->price); + }else{ + return Py_BuildValue("k", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price); + } +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_price_ticker(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old->price_ticker); + }else{ + return Py_BuildValue("s", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->price_ticker); + } +} +//PyObject *wrapping_dap_chain_net_srv_order_get_srv_free_space(PyObject *self, void *closure){} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_size(PyObject *self, void *closure){ + (void)closure; + if(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("I", 0); + }else{ + return Py_BuildValue("I", WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext_size); + } +} +PyObject *wrapping_dap_chain_net_srv_order_get_srv_ext_n_sign(PyObject *self, void *closure) { + (void) closure; + if (WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order != NULL) { + dap_sign_t *l_sign = (dap_sign_t*)&WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext_n_sign[WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order->ext_size]; + PyDapSignObject *obj_sign = PyObject_New(PyDapSignObject, &DapSignObject_DapSignObjectType); + PyObject_Dir((PyObject *) obj_sign); + obj_sign->sign = l_sign; + return (PyObject *) obj_sign; + } + return Py_None; +} + +//Functions +PyObject *wrapping_dap_chain_net_srv_order_get_size(PyObject *self, PyObject *args){ + (void)args; + if (WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order == NULL){ + return Py_BuildValue("n", dap_chain_net_srv_order_get_size(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order_old)); + }else { + return Py_BuildValue("n", dap_chain_net_srv_order_get_size(WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order)); + } +} +//PyObject *wrapping_dap_chain_net_srv_order_set_continent_region(PyObject *self, PyObject *args){} +//PyObject *wrapping_dap_chain_net_srv_order_get_continent_region(PyObject *self, PyObject *args){} + +//PyObject *wrapping_dap_chain_net_srv_order_get_country_code(PyObject *self, PyObject *args){} +//PyObject *wrapping_dap_chain_net_srv_order_continents_count(PyObject *self, PyObject *args){} +//PyObject *wrapping_dap_chain_net_srv_order_continent_to_str(PyObject *self, PyObject *args){} +//PyObject *wrapping_dap_chain_net_srv_order_continent_to_num(PyObject *self, PyObject *args){} + +PyObject *wrapping_dap_chain_net_srv_order_find(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_net; + PyObject *obj_order_hash; + if (!PyArg_ParseTuple(args, "OO", &obj_net, &obj_order_hash)){ + PyErr_SetString(PyExc_ValueError, "This function must take two arguments. "); + return NULL; + } + dap_chain_net_srv_order_t *l_order = NULL; + if(!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes " + "an instance of an object of type ChainNet."); + return NULL; + } + if (PyUnicode_Check(obj_order_hash)){ + const char *l_str = PyUnicode_AsUTF8(obj_order_hash); + l_order = dap_chain_net_srv_order_find_by_hash_str(((PyDapChainNetObject*)obj_net)->chain_net, l_str); + if (l_order == NULL){ + return Py_None; + } + PyDapChainNetSrvOrderObject *l_obj_order = PyObject_New(PyDapChainNetSrvOrderObject, &DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType); + PyObject_Dir((PyObject *)l_obj_order); + l_obj_order->order = l_order; + return (PyObject*)l_obj_order; + } + if (PyDapHashFast_Check(obj_order_hash)){ + l_order = dap_chain_net_srv_order_find_by_hash(((PyDapChainNetObject*)obj_net)->chain_net, + ((PyDapHashFastObject*)obj_order_hash)->hash_fast); + if (l_order == NULL){ + return Py_None; + } + PyDapChainNetSrvOrderObject *l_obj_order = PyObject_New(PyDapChainNetSrvOrderObject, &DapChainNetSrvOrderObject_DapChainNetSrvOrderObjectType); + PyObject_Dir((PyObject *)l_obj_order); + l_obj_order->order = l_order; + return (PyObject*)l_obj_order; + } + PyErr_SetString(PyExc_ValueError, "An invalid argument type was passed to this function. " + "This function can take a string or an object of the HashFast type " + "as the second argument. "); + return NULL; +} + +PyObject *wrapping_dap_chain_net_srv_order_delete(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_net; + PyObject *obj_order_hash; + if (!PyArg_ParseTuple(args, "OO", &obj_net, &obj_order_hash)){ + PyErr_SetString(PyExc_ValueError, "This function must take two arguments. "); + return NULL; + } + if(!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes " + "an instance of an object of type ChainNet."); + return NULL; + } + int res = -1; + if (PyUnicode_Check(obj_order_hash)){ + const char *l_str = PyUnicode_AsUTF8(obj_order_hash); + res = dap_chain_net_srv_order_delete_by_hash_str(((PyDapChainNetObject*)obj_net)->chain_net, + l_str); + return Py_BuildValue("i", res); + } + if (PyDapHashFast_Check(obj_order_hash)) { + res =dap_chain_net_srv_order_delete_by_hash(((PyDapChainNetObject*)obj_net)->chain_net, + ((PyDapHashFastObject*)obj_order_hash)->hash_fast); + return Py_BuildValue("i", res); + } + PyErr_SetString(PyExc_ValueError, "An invalid argument type was passed to this function. " + "This function can take a string or an object of the HashFast type " + "as the second argument. "); + return NULL; +} + +PyObject *wrapping_dap_chain_net_srv_order_find_all_by(PyObject *self, PyObject *args){} +PyObject *wrapping_dap_chain_net_srv_order_save(PyObject *self, PyObject *args){ + PyObject *obj_net; + if(!PyArg_ParseTuple(args, "O", &obj_net)){ + PyErr_SetString(PyExc_ValueError, "This function must take one arguments. "); + return NULL; + } + if(!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes " + "an instance of an object of type ChainNet."); + return NULL; + } + char* res = NULL; + dap_chain_net_t *l_net = ((PyDapChainNetObject*)obj_net)->chain_net; + res = dap_chain_net_srv_order_save(l_net, + WRAPPING_DAP_CHAIN_NET_SRV_ORDER(self)->order); + if (res == NULL) + return Py_None; + return Py_BuildValue("s", res); +} +PyObject *wrapping_dap_chain_net_srv_order_get_gdb_group(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_net; + if(!PyArg_ParseTuple(args, "O", &obj_net)){ + PyErr_SetString(PyExc_ValueError, "This function must take one arguments. "); + return NULL; + } + if(!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes " + "an instance of an object of type ChainNet."); + return NULL; + } + return Py_BuildValue("s", dap_chain_net_srv_order_get_gdb_group(((PyDapChainNetObject*)obj_net)->chain_net)); +} +PyObject *wrapping_dap_chain_net_srv_order_get_nodelist_group(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_net; + if(!PyArg_ParseTuple(args, "O", &obj_net)){ + PyErr_SetString(PyExc_ValueError, "This function must take one arguments. "); + return NULL; + } + if(!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_ValueError, "As the first argument, this function takes " + "an instance of an object of type ChainNet."); + return NULL; + } + return Py_BuildValue("s", + dap_chain_net_srv_order_get_nodelist_group(((PyDapChainNetObject*)obj_net)->chain_net)); +} + +PyObject *wrapping_dap_chain_net_srv_order_add_notify_callback(PyObject *self, PyObject *args){ + (void)self; + PyObject *obj_net; + PyObject *func_call; + if (!PyArg_ParseTuple(args, "OO", &obj_net, &func_call)){ + return NULL; + } + if (!PyDapChainNet_Check(obj_net)){ + PyErr_SetString(PyExc_AttributeError, "The first argument must be ChainNet object"); + return NULL; + } + if (!PyCallable_Check(func_call)){ + PyErr_SetString(PyExc_AttributeError, "The second argument must be a callable"); + return NULL; + } + _wrapping_list_func_callables_t *callback = DAP_NEW(_wrapping_list_func_callables_t); + callback->func = func_call; + dap_chain_net_srv_order_add_notify_callback(((PyDapChainNetObject*)obj_net)->chain_net, + _wrapping_handler_add_order_notify); + LL_APPEND(_s_callbacks, callback); + return Py_None; +} diff --git a/modules/cellframe-sdk/services/datum/include/wrapping_dap_chain_net_srv_datum.h b/modules/cellframe-sdk/services/datum/include/wrapping_dap_chain_net_srv_datum.h index 41c6092602f49e6a1dc7856a26ca365b427bcc66..61489f32c3a3d27b089aab8a914752f781512949 100644 --- a/modules/cellframe-sdk/services/datum/include/wrapping_dap_chain_net_srv_datum.h +++ b/modules/cellframe-sdk/services/datum/include/wrapping_dap_chain_net_srv_datum.h @@ -11,50 +11,4 @@ typedef struct PyDapChainNetSrvDatum{ PyObject *wrapping_dap_chain_net_srv_datum_create(PyObject *self, PyObject *args); PyObject *wrapping_dap_chain_net_srv_datum_read(PyObject *self, PyObject *args); -static PyMethodDef DapChainNetSrvDatum_method[] = { - {"create", (PyCFunction) wrapping_dap_chain_net_srv_datum_create, METH_VARARGS | METH_STATIC, ""}, - {"read", (PyCFunction) wrapping_dap_chain_net_srv_datum_read, METH_VARARGS|METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainNetSrvDatumObject_DapChainNetSrvDatumObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainNetSrvDatum", /* tp_name */ - sizeof(PyDapChainNetSrvDatumObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain net srv datum object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainNetSrvDatum_method, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainNetSrvDatumObject_DapChainNetSrvDatumObjectType; diff --git a/modules/cellframe-sdk/services/datum/src/wrapping_dap_chain_net_srv_datum.c b/modules/cellframe-sdk/services/datum/src/wrapping_dap_chain_net_srv_datum.c index f8564da0c0af08332af38fd3195673a1dff73b8f..481417790383379370c9a14d5018ff31727b594f 100644 --- a/modules/cellframe-sdk/services/datum/src/wrapping_dap_chain_net_srv_datum.c +++ b/modules/cellframe-sdk/services/datum/src/wrapping_dap_chain_net_srv_datum.c @@ -1,5 +1,53 @@ #include "wrapping_dap_chain_net_srv_datum.h" +PyMethodDef DapChainNetSrvDatum_method[] = { + {"create", (PyCFunction) wrapping_dap_chain_net_srv_datum_create, METH_VARARGS | METH_STATIC, ""}, + {"read", (PyCFunction) wrapping_dap_chain_net_srv_datum_read, METH_VARARGS|METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainNetSrvDatumObject_DapChainNetSrvDatumObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainNetSrvDatum", /* tp_name */ + sizeof(PyDapChainNetSrvDatumObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain net srv datum object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainNetSrvDatum_method, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_net_srv_datum_read(PyObject *self, PyObject *args){ (void)self; char *str_path; diff --git a/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag.h b/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag.h index c978669c81ab073b5baf88fe88c09c2e5c4ca159..ebf948ecce490ed2e2bcd570a218b5e63b425d07 100644 --- a/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag.h +++ b/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag.h @@ -18,52 +18,7 @@ typedef struct PyDapChainCsDag { PyObject *dap_chain_cs_dag_find_event_by_hash_py(PyObject *self, PyObject *args); -static PyMethodDef DapChainCsDagMethods[] = { - {"findByHash", (PyCFunction)dap_chain_cs_dag_find_event_by_hash_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainCsDag_DapChainCsDagType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainCsDag", /* tp_name */ - sizeof(PyDapChainCsDagObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cs dag objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapChainCsDagMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainCsDag_DapChainCsDagType; #ifdef __cplusplus }; diff --git a/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag_event.h b/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag_event.h index e4c1dfb58b5f72d1d900861c35cce549fb96dbd7..63a998fe640adf97f8537515c8f7d70725fe73a6 100644 --- a/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag_event.h +++ b/modules/cellframe-sdk/type/dag/include/wrapping_dap_chain_cs_dag_event.h @@ -24,62 +24,4 @@ PyObject *wrapping_dap_chain_cs_dag_event_get_links(PyObject *self, void *closur PyObject *wrapping_dap_chain_cs_dag_event_get_datum(PyObject *self, void *closure); PyObject *wrapping_dap_chain_cs_dag_event_get_signs(PyObject *self, void *closure); -static PyMethodDef PyDapChainCsDagEventMethodsDef[] = { - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef PyDapChainCsDagEventGetsSetsDef[] = { - {"version", (getter)wrapping_dap_chain_cs_dag_event_get_version, NULL, NULL, NULL}, - {"roundId", (getter)wrapping_dap_chain_cs_dag_event_get_round_id, NULL, NULL, NULL}, - {"created", (getter)wrapping_dap_chain_cs_dag_event_get_ts_created, NULL, NULL, NULL}, - {"chainId", (getter)wrapping_dap_chain_cs_dag_event_get_chain_id, NULL, NULL, NULL}, - {"cellId", (getter)wrapping_dap_chain_cs_dag_event_get_cell_id, NULL, NULL, NULL}, - {"hashCount", (getter)wrapping_dap_chain_cs_dag_event_get_hash_count, NULL, NULL, NULL}, - {"signsCount", (getter)wrapping_dap_chain_cs_dag_event_get_signs_count, NULL, NULL, NULL}, - {"links", (getter)wrapping_dap_chain_cs_dag_event_get_links, NULL, NULL, NULL}, - {"datum", (getter)wrapping_dap_chain_cs_dag_event_get_datum, NULL, NULL, NULL}, - {"signs", (getter)wrapping_dap_chain_cs_dag_event_get_signs, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapChainCsDagEvent_DapChainCsDagEventType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ChainCsDagEvent", /* tp_name */ - sizeof(PyDapChainCsDagEventObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain cs dag event objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapChainCsDagEventMethodsDef, /* tp_methods */ - 0, /* tp_members */ - PyDapChainCsDagEventGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapChainCsDagEvent_DapChainCsDagEventType; diff --git a/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag.c b/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag.c index f555d01b7d3498580884f689fc2a360e73d18f04..61eb6f72da7ee5b8c5031f4785ecf043ab24e6d7 100644 --- a/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag.c +++ b/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag.c @@ -1,6 +1,53 @@ #include "wrapping_dap_chain_cs_dag.h" #include "dap_chain_cell.h" +PyMethodDef DapChainCsDagMethods[] = { + {"findByHash", (PyCFunction)dap_chain_cs_dag_find_event_by_hash_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainCsDag_DapChainCsDagType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainCsDag", /* tp_name */ + sizeof(PyDapChainCsDagObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cs dag objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapChainCsDagMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_chain_cs_dag_find_event_by_hash_py(PyObject *self, PyObject *args){ PyObject *obj_hash; PyObject *obj_atom_iter; diff --git a/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag_event.c b/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag_event.c index ec6c6ed942fa194dd9fc841d21d16946d466a959..6b32087f53f1a7c05a0b7d8e636a0a443edaaf14 100644 --- a/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag_event.c +++ b/modules/cellframe-sdk/type/dag/src/wrapping_dap_chain_cs_dag_event.c @@ -1,5 +1,65 @@ #include "wrapping_dap_chain_cs_dag_event.h" +PyMethodDef PyDapChainCsDagEventMethodsDef[] = { + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef PyDapChainCsDagEventGetsSetsDef[] = { + {"version", (getter)wrapping_dap_chain_cs_dag_event_get_version, NULL, NULL, NULL}, + {"roundId", (getter)wrapping_dap_chain_cs_dag_event_get_round_id, NULL, NULL, NULL}, + {"created", (getter)wrapping_dap_chain_cs_dag_event_get_ts_created, NULL, NULL, NULL}, + {"chainId", (getter)wrapping_dap_chain_cs_dag_event_get_chain_id, NULL, NULL, NULL}, + {"cellId", (getter)wrapping_dap_chain_cs_dag_event_get_cell_id, NULL, NULL, NULL}, + {"hashCount", (getter)wrapping_dap_chain_cs_dag_event_get_hash_count, NULL, NULL, NULL}, + {"signsCount", (getter)wrapping_dap_chain_cs_dag_event_get_signs_count, NULL, NULL, NULL}, + {"links", (getter)wrapping_dap_chain_cs_dag_event_get_links, NULL, NULL, NULL}, + {"datum", (getter)wrapping_dap_chain_cs_dag_event_get_datum, NULL, NULL, NULL}, + {"signs", (getter)wrapping_dap_chain_cs_dag_event_get_signs, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapChainCsDagEvent_DapChainCsDagEventType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ChainCsDagEvent", /* tp_name */ + sizeof(PyDapChainCsDagEventObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain cs dag event objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapChainCsDagEventMethodsDef, /* tp_methods */ + 0, /* tp_members */ + PyDapChainCsDagEventGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_chain_cs_dag_event_get_version(PyObject *self, void *closure){ (void)closure; return Py_BuildValue("H", ((PyDapChainCsDagEventObject*)self)->event->header.version); diff --git a/modules/cellframe-sdk/wallet/include/dap_chain_wallet_python.h b/modules/cellframe-sdk/wallet/include/dap_chain_wallet_python.h index d0b43398dbd38190121524277b5343c9b58f3a57..a0e333ab7acde3dd419388ea1b40dca82bc2e7ca 100644 --- a/modules/cellframe-sdk/wallet/include/dap_chain_wallet_python.h +++ b/modules/cellframe-sdk/wallet/include/dap_chain_wallet_python.h @@ -42,71 +42,7 @@ PyObject *dap_chain_wallet_get_key_py(PyObject *self, PyObject *argv); //PyObject *dap_chain_wallet_save_file_py(PyObject *self, PyObject *argv); -static PyMethodDef ChainWalletMethods[] = { - {"getPath", (PyCFunction)dap_chain_wallet_get_path_py, METH_VARARGS | METH_STATIC, ""}, - {"createWithSeed", (PyCFunction)dap_chain_wallet_create_with_seed_py, METH_VARARGS | METH_STATIC, ""}, - {"openFile", (PyCFunction)dap_chain_wallet_open_file_py, METH_VARARGS | METH_STATIC, ""}, - {"open", (PyCFunction)dap_chain_wallet_open_py, METH_VARARGS | METH_STATIC, ""}, - {"save", (PyCFunction)dap_chain_wallet_save_py, METH_NOARGS, ""}, - {"certToAddr", (PyCFunction)dap_cert_to_addr_py, METH_VARARGS | METH_STATIC, ""}, - {"getAddr", (PyCFunction)dap_chain_wallet_get_addr_py, METH_VARARGS, ""}, - {"getCertsNumber", (PyCFunction)dap_chain_wallet_get_certs_number_py, METH_NOARGS, ""}, - {"getPKey", (PyCFunction)dap_chain_wallet_get_pkey_py, METH_VARARGS, ""}, - {"getKey", (PyCFunction)dap_chain_wallet_get_key_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapChainWallet_dapChainWalletType = { - PyVarObject_HEAD_INIT(NULL, 0) - "ChainWallet", /* tp_name */ - sizeof(PyDapChainWalletObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)dap_chain_wallet_close_py, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Chain wallet object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ChainWalletMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - dap_chain_wallet_create_py,/* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc*/ - 0, /* tp_bases*/ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ - 0, /* tp_del */ - 0, /* tp_version_tag*/ - 0, /* tp_finalize*/ -}; +extern PyTypeObject DapChainWallet_dapChainWalletType; #ifdef __cplusplus diff --git a/modules/cellframe-sdk/wallet/src/dap_chain_wallet_python.c b/modules/cellframe-sdk/wallet/src/dap_chain_wallet_python.c index bea9ed3ecb26b375a7fae3d0c28354fac67224b9..e49b336ef4ddd31abfdc9646c6bf3ea0c735f0a8 100644 --- a/modules/cellframe-sdk/wallet/src/dap_chain_wallet_python.c +++ b/modules/cellframe-sdk/wallet/src/dap_chain_wallet_python.c @@ -8,11 +8,77 @@ void dap_chain_wallet_deinit_py(void){ dap_chain_wallet_deinit(); } +PyMethodDef ChainWalletMethods[] = { + {"getPath", (PyCFunction)dap_chain_wallet_get_path_py, METH_VARARGS | METH_STATIC, ""}, + {"createWithSeed", (PyCFunction)dap_chain_wallet_create_with_seed_py, METH_VARARGS | METH_STATIC, ""}, + {"openFile", (PyCFunction)dap_chain_wallet_open_file_py, METH_VARARGS | METH_STATIC, ""}, + {"open", (PyCFunction)dap_chain_wallet_open_py, METH_VARARGS | METH_STATIC, ""}, + {"save", (PyCFunction)dap_chain_wallet_save_py, METH_NOARGS, ""}, + {"certToAddr", (PyCFunction)dap_cert_to_addr_py, METH_VARARGS | METH_STATIC, ""}, + {"getAddr", (PyCFunction)dap_chain_wallet_get_addr_py, METH_VARARGS, ""}, + {"getCertsNumber", (PyCFunction)dap_chain_wallet_get_certs_number_py, METH_NOARGS, ""}, + {"getPKey", (PyCFunction)dap_chain_wallet_get_pkey_py, METH_VARARGS, ""}, + {"getKey", (PyCFunction)dap_chain_wallet_get_key_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapChainWallet_dapChainWalletType = { + PyVarObject_HEAD_INIT(NULL, 0) + "ChainWallet", /* tp_name */ + sizeof(PyDapChainWalletObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)dap_chain_wallet_close_py, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Chain wallet object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ChainWalletMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + dap_chain_wallet_create_py,/* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc*/ + 0, /* tp_bases*/ + 0, /* tp_mro */ + 0, /* tp_cache */ + 0, /* tp_subclasses */ + 0, /* tp_weaklist */ + 0, /* tp_del */ + 0, /* tp_version_tag*/ + 0, /* tp_finalize*/ +}; + PyObject *dap_chain_wallet_get_path_py(PyObject *self, PyObject *argv){ (void)self; (void)argv; const char *path = dap_chain_wallet_get_path(g_config); - return Py_BuildValue("(s)", path); + return Py_BuildValue("s", path); } PyObject *dap_chain_wallet_create_with_seed_py(PyObject *self, PyObject *argv){ @@ -30,13 +96,14 @@ PyObject *dap_chain_wallet_create_with_seed_py(PyObject *self, PyObject *argv){ void *seed = (void *)PyBytes_AsString(obj_seed); size_t seed_size = PyBytes_Size(obj_seed); PyObject *obj_wallet = _PyObject_New(&DapChainWallet_dapChainWalletType); + PyObject_Dir(obj_wallet); ((PyDapChainWalletObject*)obj_wallet)->wallet = dap_chain_wallet_create_with_seed( wallet_name, path_wallets, *((PyDapSignTypeObject*)obj_sig_type)->sign_type, seed, seed_size); - return Py_BuildValue("(O)", obj_wallet); + return Py_BuildValue("O", obj_wallet); } PyObject *dap_chain_wallet_create_py(PyTypeObject *type, PyObject *argv, PyObject *kwds){ (void)kwds; @@ -62,8 +129,9 @@ PyObject *dap_chain_wallet_open_file_py(PyObject *self, PyObject *argv){ if (!PyArg_ParseTuple(argv, "s", &file_path)) return NULL; PyObject *obj_wallet = _PyObject_New(&DapChainWallet_dapChainWalletType); + PyObject_Dir(obj_wallet); ((PyDapChainWalletObject*)obj_wallet)->wallet = dap_chain_wallet_open_file(file_path); - return Py_BuildValue("(O)", obj_wallet); + return Py_BuildValue("O", obj_wallet); } PyObject *dap_chain_wallet_open_py(PyObject *self, PyObject *argv){ (void)self; @@ -72,8 +140,9 @@ PyObject *dap_chain_wallet_open_py(PyObject *self, PyObject *argv){ if (!PyArg_ParseTuple(argv, "ss", &wallet_name, &wallet_path)) return NULL; PyObject *obj_wallet = _PyObject_New(&DapChainWallet_dapChainWalletType); + PyObject_Dir(obj_wallet); ((PyDapChainWalletObject*)obj_wallet)->wallet = dap_chain_wallet_open(wallet_name, wallet_path); - return Py_BuildValue("(O)", obj_wallet); + return Py_BuildValue("O", obj_wallet); } PyObject *dap_chain_wallet_save_py(PyObject *self, PyObject *argv){ (void)argv; @@ -93,11 +162,12 @@ PyObject *dap_cert_to_addr_py(PyObject *self, PyObject *argv){ if (!PyArg_ParseTuple(argv, "OO", &obj_cert, &obj_net_id)) return NULL; PyObject *obj_addr = _PyObject_New(&DapChainAddrObject_DapChainAddrObjectType); + PyObject_Dir(obj_addr); ((PyDapChainAddrObject*)obj_addr)->addr = dap_cert_to_addr( ((PyCryptoCertObject*)obj_cert)->cert, ((PyDapChainNetIdObject*)obj_net_id)->net_id ); - return Py_BuildValue("(O)", obj_addr); + return Py_BuildValue("O", obj_addr); } PyObject *dap_chain_wallet_get_addr_py(PyObject *self, PyObject *argv){ @@ -105,11 +175,12 @@ PyObject *dap_chain_wallet_get_addr_py(PyObject *self, PyObject *argv){ if (!PyArg_ParseTuple(argv, "O", &obj_net_id)) return NULL; PyObject *obj_addr = _PyObject_New(&DapChainAddrObject_DapChainAddrObjectType); + PyObject_Dir(obj_addr); ((PyDapChainAddrObject*)obj_addr)->addr = dap_chain_wallet_get_addr( ((PyDapChainWalletObject*)self)->wallet, ((PyDapChainNetIdObject*)obj_net_id)->net_id ); - return Py_BuildValue("(O)", obj_addr); + return Py_BuildValue("O", obj_addr); } PyObject *dap_chain_wallet_get_certs_number_py(PyObject *self, PyObject *argv){ (void)argv; @@ -121,18 +192,20 @@ PyObject *dap_chain_wallet_get_pkey_py(PyObject *self, PyObject *argv){ if (!PyArg_ParseTuple(argv, "I", &key_idx)) return NULL; PyObject *obj_pkey = _PyObject_New(&DapPkeyObject_DapPkeyObjectType); + PyObject_Dir(obj_pkey); ((PyDapPkeyObject*)obj_pkey)->pkey = dap_chain_wallet_get_pkey(((PyDapChainWalletObject*)self)->wallet, key_idx); - return Py_BuildValue("(O)", obj_pkey); + return Py_BuildValue("O", obj_pkey); } PyObject *dap_chain_wallet_get_key_py(PyObject *self, PyObject *argv){ uint32_t key_idx; if (!PyArg_ParseTuple(argv, "I", &key_idx)) return NULL; PyObject *obj_key = _PyObject_New(&PyCryptoKeyObject_PyCryptoKeyType); + PyObject_Dir(obj_key); ((PyCryptoKeyObject*)obj_key)->key = dap_chain_wallet_get_key( ((PyDapChainWalletObject*)self)->wallet, key_idx ); - return Py_BuildValue("(O)", obj_key); + return Py_BuildValue("O", obj_key); } diff --git a/modules/dap-sdk/crypto/include/libdap-crypto-python.h b/modules/dap-sdk/crypto/include/libdap-crypto-python.h index b17cb127d9baae109fcc4e4b4eb4e648300e59ed..b88db2aef5868caf4e84e3eb1f52df99ad72880e 100644 --- a/modules/dap-sdk/crypto/include/libdap-crypto-python.h +++ b/modules/dap-sdk/crypto/include/libdap-crypto-python.h @@ -50,75 +50,7 @@ int dap_crypto_init(void); void dap_crypto_deinit(void); -static PyMethodDef g_crypto_methods_py[] = { - {"encodeBase58", dap_encode_base58_py, METH_VARARGS | METH_STATIC, "Encrypts information using the base58 algorithm from the DAP crypto library"}, - {"decodeBase58", dap_decode_base58_py, METH_VARARGS | METH_STATIC, "Dencrypts information using the base58 algorithm from the DAP crypto library"}, - {"encodeBase64", dap_encode_base64_py, METH_VARARGS | METH_STATIC, "Encrypts information using the base64 algorithm from the DAP crypto library"}, - {"decodeBase64", dap_decode_base64_py, METH_VARARGS | METH_STATIC, "Dencrypts information using the base64 algorithm from the DAP crypto library"}, - {"newKey", dap_enc_key_new_py, METH_VARARGS | METH_STATIC, "The function creates a new key, and returns it with PyObject."}, - {"generateNewKey", dap_enc_key_new_generate_py, METH_VARARGS | METH_STATIC, ""}, - {"getEncSizeKey", dap_enc_key_get_enc_size_py, METH_VARARGS | METH_STATIC, ""}, - {"getDecSizeKey", dap_enc_key_get_dec_size_py, METH_VARARGS | METH_STATIC, ""}, - /*IAES256*/ - {"newKeyIAES", dap_enc_iaes_key_new_py, METH_VARARGS | METH_STATIC, ""}, - {"deleteKeyIAES", dap_enc_iaes_key_delete_py, METH_VARARGS | METH_STATIC, ""}, - {"generateKeyIAES", dap_enc_iaes_key_generate_py, METH_VARARGS | METH_STATIC, ""}, - {"encodeSizeIAES256", dap_enc_iaes256_calc_encode_size_py, METH_VARARGS | METH_STATIC, ""}, - {"decodeSizeIAES256", dap_enc_iaes256_calc_decode_size_py, METH_VARARGS | METH_STATIC, ""}, - {"encryptIAES256CBCFast", dap_enc_iaes256_cbc_encrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, - {"decryptIAES256CBCFast", dap_enc_iaes256_cbc_decrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, - /*OAES*/ - {"newKeyOAES", dap_enc_oaes_key_new_py, METH_VARARGS | METH_STATIC, ""}, - {"deleteKeyOAES", dap_enc_oaes_key_delete_py, METH_VARARGS | METH_STATIC, ""}, - {"generateKeyOAES", dap_enc_oaes_key_generate_py, METH_VARARGS | METH_STATIC, ""}, - {"encodeSizeOAES", dap_enc_oaes_calc_encode_size_py, METH_VARARGS | METH_STATIC, ""}, - {"decodeSizeOAES", dap_enc_oaes_calc_decode_size_py, METH_VARARGS | METH_STATIC, ""}, - {"encryptOAESFast", dap_enc_oaes_encrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, - {"decryptOAESFast", dap_enc_oaes_decrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject g_crypto_type_py = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Crypto", /* tp_name */ - sizeof(PyCryptoObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Crypto objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - g_crypto_methods_py, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject g_crypto_type_py; #ifdef __cplusplus } diff --git a/modules/dap-sdk/crypto/include/libdap_crypto_data_type.h b/modules/dap-sdk/crypto/include/libdap_crypto_data_type.h index 541e8693f7da211d5b19722f38bf0700de7eeaee..3876a959e872e4135e172bf4fdd5c19e8ca86694 100644 --- a/modules/dap-sdk/crypto/include/libdap_crypto_data_type.h +++ b/modules/dap-sdk/crypto/include/libdap_crypto_data_type.h @@ -35,65 +35,11 @@ typedef struct PyCryptoDataType{ PyObject_HEAD }PyCryptoDataTypeObjecy; -static PyObject *get_ENC_DATA_TYPE_RAW(){ - return PyLong_FromLong(DAP_ENC_DATA_TYPE_RAW); -} -static PyObject *get_ENC_DATA_TYPE_B64(){ - return PyLong_FromLong(DAP_ENC_DATA_TYPE_B64); -} -static PyObject *get_ENC_DATA_TYPE_B64_URLSAFE(){ - return PyLong_FromLong(DAP_ENC_DATA_TYPE_B64_URLSAFE); -} - -static PyMethodDef PyCryptoDataTypeObjecyMethods[] = { - {"DAP_ENC_DATA_TYPE_RAW", (PyCFunction)get_ENC_DATA_TYPE_RAW, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_DATA_TYPE_B64", (PyCFunction)get_ENC_DATA_TYPE_B64, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_DATA_TYPE_B64_URLSAFE", (PyCFunction)get_ENC_DATA_TYPE_B64_URLSAFE, METH_NOARGS | METH_STATIC, ""}, - - {NULL, NULL, 0, NULL} -}; +PyObject *get_ENC_DATA_TYPE_RAW(); +PyObject *get_ENC_DATA_TYPE_B64(); +PyObject *get_ENC_DATA_TYPE_B64_URLSAFE(); -static PyTypeObject CryptoDataTypeObjecy_CryptoDataTypeObjecyType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.CryptoDataType", /* tp_name */ - sizeof(PyCryptoDataTypeObjecy), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Crypto data type objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyCryptoDataTypeObjecyMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject CryptoDataTypeObject_CryptoDataTypeObjectType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/crypto/include/libdap_crypto_key_python.h b/modules/dap-sdk/crypto/include/libdap_crypto_key_python.h index 109776d211761d0e9e1d525c370f4f7fadfc6e3a..e96c5988f84600f4fa0ad618eb74d14b612be7fe 100644 --- a/modules/dap-sdk/crypto/include/libdap_crypto_key_python.h +++ b/modules/dap-sdk/crypto/include/libdap_crypto_key_python.h @@ -12,34 +12,9 @@ typedef struct PyCryptoKey{ dap_enc_key_t *key; }PyCryptoKeyObject; -static void PyCryptoKeyObject_dealloc(PyCryptoKeyObject *cryptoObject){ - dap_enc_key_delete(cryptoObject->key); - Py_TYPE(cryptoObject)->tp_free((PyObject*)cryptoObject); -} +void PyCryptoKeyObject_dealloc(PyCryptoKeyObject *cryptoObject); -static PyTypeObject PyCryptoKeyObject_PyCryptoKeyType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Crypto.Key", /* tp_name */ - sizeof(PyCryptoKeyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PyCryptoKeyObject_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "Crypto key objects", /* tp_doc */ -}; +extern PyTypeObject PyCryptoKeyObject_PyCryptoKeyType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/crypto/include/libdap_crypto_key_type_python.h b/modules/dap-sdk/crypto/include/libdap_crypto_key_type_python.h index 248d39e80addd6c758e2f116a353dde90d8500f4..d713cef079232df80690526c131b3d0e9f7264c2 100644 --- a/modules/dap-sdk/crypto/include/libdap_crypto_key_type_python.h +++ b/modules/dap-sdk/crypto/include/libdap_crypto_key_type_python.h @@ -33,7 +33,7 @@ extern "C" { typedef struct PyCryptoKeyType{ PyObject_HEAD -}PyCryptoKeyTypeObjecy; +}PyCryptoKeyTypeObject; PyObject *get_ENC_KEY_TYPE_IAES(); PyObject *get_ENC_KEY_TYPE_OAES(); @@ -54,71 +54,7 @@ PyObject *get_ENC_KEY_TYPE_SIG_TESLA(); PyObject *get_ENC_KEY_TYPE_SIG_DILITHIUM(); PyObject *get_ENC_KEY_TYPE_NULL(); -static PyMethodDef PyCryptoKeyTypeObjecyMethods[] = { - {"DAP_ENC_KEY_TYPE_IAES", (PyCFunction)get_ENC_KEY_TYPE_IAES, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_OAES", (PyCFunction)get_ENC_KEY_TYPE_OAES, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_RLWE_NEWHOPE", (PyCFunction)get_ENC_KEY_TYPE_RLWE_NEWHOPE, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIDH_CLN16", (PyCFunction)get_ENC_KEY_TYPE_SIDH_CLN16, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_DEFEO", (PyCFunction)get_ENC_KEY_TYPE_DEFEO, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_MSRLN", (PyCFunction)get_ENC_KEY_TYPE_MSRLN, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_MSRLN16", (PyCFunction)get_ENC_KEY_TYPE_MSRLN16, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_RLWE_BCNS15", (PyCFunction)get_ENC_KEY_TYPE_RLWE_BCNS15, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_LWE_FRODO", (PyCFunction)get_ENC_KEY_TYPE_LWE_FRODO, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIDH_IQC_REF", (PyCFunction)get_ENC_KEY_TYPE_SIDH_IQC_REF, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_CODE_MCBITS", (PyCFunction)get_ENC_KEY_TYPE_CODE_MCBITS, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_NTRU", (PyCFunction)get_ENC_KEY_TYPE_NTRU, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_MLWE_KYBER", (PyCFunction)get_ENC_KEY_TYPE_MLWE_KYBER, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIG_PICNIC", (PyCFunction)get_ENC_KEY_TYPE_SIG_PICNIC, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIG_BLISS", (PyCFunction)get_ENC_KEY_TYPE_SIG_BLISS, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIG_TESLA", (PyCFunction)get_ENC_KEY_TYPE_SIG_TESLA, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_SIG_DILITHIUM", (PyCFunction)get_ENC_KEY_TYPE_SIG_DILITHIUM, METH_NOARGS | METH_STATIC, ""}, - {"DAP_ENC_KEY_TYPE_NULL", (PyCFunction)get_ENC_KEY_TYPE_NULL, METH_NOARGS | METH_STATIC, ""}, - - - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject CryptoKeyTypeObjecy_CryptoKeyTypeObjecyType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.CryptoKeyType", /* tp_name */ - sizeof(PyCryptoKeyTypeObjecy), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Crypto keys type objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyCryptoKeyTypeObjecyMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject CryptoKeyTypeObject_CryptoKeyTypeObjectType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/crypto/include/wrapping_cert.h b/modules/dap-sdk/crypto/include/wrapping_cert.h index 97e77964db37a3f8e4b24daae7af1d3d2d896285..1ad1a4dcf5a21c4f751443288bfe5481ecde3014 100644 --- a/modules/dap-sdk/crypto/include/wrapping_cert.h +++ b/modules/dap-sdk/crypto/include/wrapping_cert.h @@ -55,73 +55,7 @@ void dap_cert_delete_py(PyObject *self); PyObject* dap_cert_folder_add_py(PyObject *self, PyObject *args); PyObject* dap_cert_folder_get_py(PyObject *self, PyObject *args); -static PyMethodDef g_crypto_cert_methods_py[] = { - {"generate",dap_cert_generate_py , METH_VARARGS | METH_STATIC, "Generate from seed or randomly the new certificate"}, - {"find", dap_cert_find_py, METH_VARARGS | METH_STATIC, ""}, - {"folderAdd", dap_cert_folder_add_py, METH_VARARGS | METH_STATIC, "Add folders with .dcert files in it"}, - {"folderGet", dap_cert_folder_get_py, METH_VARARGS | METH_STATIC, "Get folder by number or the default one"}, - {"load", dap_cert_load_py, METH_VARARGS | METH_STATIC ,""}, - {"dump", dap_cert_dump_py, METH_VARARGS , ""}, - {"pkey", dap_cert_pkey_py, METH_VARARGS , ""}, - {"sign", dap_cert_sign_py, METH_VARARGS , ""}, - {"certSignAdd", dap_cert_cert_sign_add_py, METH_VARARGS, ""}, - {"certSigns", dap_cert_cert_signs_py, METH_VARARGS , ""}, - {"compare", dap_cert_compare_py, METH_VARARGS, ""}, - {"save", dap_cert_save_py, METH_VARARGS , "Save to the first directory in cert folders list"}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject g_crypto_cert_type_py = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Cert", /* tp_name */ - sizeof(PyCryptoCertObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - dap_cert_delete_py, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Crypto cert object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - g_crypto_cert_methods_py, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0 -}; +extern PyTypeObject g_crypto_cert_type_py; #ifdef __cplusplus } diff --git a/modules/dap-sdk/crypto/include/wrapping_dap_enc_key.h b/modules/dap-sdk/crypto/include/wrapping_dap_enc_key.h index 9ccc8b6e946a96af8db42421dedb9b0a9ddcd22d..9d7bdcabb25ad795372fe204956da1e5bb94d855 100644 --- a/modules/dap-sdk/crypto/include/wrapping_dap_enc_key.h +++ b/modules/dap-sdk/crypto/include/wrapping_dap_enc_key.h @@ -28,6 +28,7 @@ #include "Python.h" #include "dap_common.h" #include "libdap_crypto_key_python.h" +#include "dap_strfuncs.h" #ifdef __cplusplus extern "C" { diff --git a/modules/dap-sdk/crypto/include/wrapping_dap_hash.h b/modules/dap-sdk/crypto/include/wrapping_dap_hash.h index e4e4508f271d4aade9bd2aa20213445702497e71..4661c5f3d659d7e42b26ffdfe7965ff63b586045 100644 --- a/modules/dap-sdk/crypto/include/wrapping_dap_hash.h +++ b/modules/dap-sdk/crypto/include/wrapping_dap_hash.h @@ -39,53 +39,7 @@ typedef struct PyDapHashType{ PyObject *DAP_HASH_TYPE_KECCAK_PY(); PyObject *DAP_HASH_TYPE_SLOW_0_PY(); -static PyMethodDef DapHashTypeMethods[] = { - {"DAP_HASH_TYPE_KECCAK", (PyCFunction)DAP_HASH_TYPE_KECCAK_PY, METH_NOARGS | METH_STATIC, ""}, - {"DAP_HASH_TYPE_SLOW_0", (PyCFunction)DAP_HASH_TYPE_SLOW_0_PY, METH_NOARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapHashTypeObject_DapChainHashTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.HashType", /* tp_name */ - sizeof(PyDapHashTypeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Hash type object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapHashTypeMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapHashTypeObject_DapChainHashTypeObjectType; /*=================*/ @@ -103,62 +57,11 @@ PyObject *dap_chain_hash_fast_to_str_py(PyObject *self, PyObject *args); PyObject *dap_chain_hash_fast_to_str_new_py(PyObject *self, PyObject *args); PyObject *wrapping_dap_hash_to_str(PyObject *self); -static PyMethodDef DapHashFastMethods[] = { - {"strToHashFast", (PyCFunction)dap_chain_str_to_hash_fast_py, METH_VARARGS | METH_STATIC, ""}, - {"hashFast", (PyCFunction)dap_hash_fast_py, METH_VARARGS, ""}, - {"compare", (PyCFunction)dap_hash_fast_compare_py, METH_VARARGS | METH_STATIC, ""}, - {"isBlank", (PyCFunction)dap_hash_fast_is_blank_py, METH_VARARGS, ""}, - {"toStr", (PyCFunction)dap_chain_hash_fast_to_str_py, METH_VARARGS, ""}, - {"toStrNew", (PyCFunction)dap_chain_hash_fast_to_str_new_py, METH_VARARGS, ""}, - {"__str__", (PyCFunction)wrapping_dap_hash_to_str, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapHashFastObject_DapHashFastObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.HashFast", /* tp_name */ - sizeof(PyDapHashFastObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - wrapping_dap_hash_to_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Hash fast object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapHashFastMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapHashFastObject_DapHashFastObjectType; static bool PyDapHashFast_Check(PyDapHashFastObject *pyHash) { - return !PyObject_TypeCheck(pyHash, &DapHashFastObject_DapHashFastObjectType); + return PyObject_TypeCheck(pyHash, &DapHashFastObject_DapHashFastObjectType); } #ifdef __cplusplus diff --git a/modules/dap-sdk/crypto/include/wrapping_dap_pkey.h b/modules/dap-sdk/crypto/include/wrapping_dap_pkey.h index b9edef514a85ac5aa7d7c5afe7fca48f6b3f0ea1..8a0535d2890827a27eec5e3ee411dc64817c28ac 100644 --- a/modules/dap-sdk/crypto/include/wrapping_dap_pkey.h +++ b/modules/dap-sdk/crypto/include/wrapping_dap_pkey.h @@ -37,47 +37,7 @@ typedef struct PyDapPkeyType{ PyObject *PyDapPkeyType_str(PyObject *self); -static PyTypeObject DapPkeyTypeObject_DapPkeyTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.PkeyType", /* tp_name */ - sizeof(PyDapPkeyTypeObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - PyDapPkeyType_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Pkey type object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapPkeyTypeObject_DapPkeyTypeObjectType; /* ----------------------------------- */ @@ -90,58 +50,7 @@ PyObject *wrapping_dap_pkey_get_type(PyObject *self, void *closure); PyObject *wrapping_dap_pkey_get_hash(PyObject *self, void *closure); PyObject *wrapping_dap_pkey_get_size(PyObject *self, void *closure); -static PyGetSetDef PyDapPkeyGetsSetsDef[] = { - {"hash", (getter)wrapping_dap_pkey_get_hash, NULL, NULL, NULL}, - {"type", (getter)wrapping_dap_pkey_get_type, NULL, NULL, NULL}, - {"size", (getter)wrapping_dap_pkey_get_size, NULL, NULL, NULL}, - {NULL} -}; - -static PyMethodDef PyDapPkeyMethods[]={ - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapPkeyObject_DapPkeyObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Pkey", /* tp_name */ - sizeof(PyDapPkeyObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Pkey object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapPkeyMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapPkeyGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapPkeyObject_DapPkeyObjectType; /* ----------------------------------- */ diff --git a/modules/dap-sdk/crypto/include/wrapping_dap_sign.h b/modules/dap-sdk/crypto/include/wrapping_dap_sign.h index cc2a3302cc989b159eed582f130fe1f38ca7dd36..5c06407a5cb7da0355ac99076dd4e44b7e390011 100644 --- a/modules/dap-sdk/crypto/include/wrapping_dap_sign.h +++ b/modules/dap-sdk/crypto/include/wrapping_dap_sign.h @@ -37,47 +37,7 @@ typedef struct PyDapSignType{ PyObject *PyDapSignType_to_str(PyObject *self); -static PyTypeObject DapSignTypeObject_DapSignTypeObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.SignType", /* tp_name */ - sizeof(PyDapSignTypeObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - PyDapSignType_to_str, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Sign type object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapSignTypeObject_DapSignTypeObjectType; typedef struct PyDapSign{ PyObject_HEAD @@ -89,59 +49,10 @@ PyObject *wrapping_dap_sign_get_pkey(PyObject *self, void *closure); PyObject *wrapping_dap_sign_get_pkey_hash(PyObject *self, void *closure); PyObject *wrapping_dap_sign_get_size(PyObject *self, void *closure); -static PyGetSetDef DapSignObjectGetsSetsDef[] = { - {"type", (getter)wrapping_dap_sign_get_type, NULL, NULL, NULL}, - {"pkey", (getter)wrapping_dap_sign_get_pkey, NULL, NULL, NULL}, - {"pkeyHash", (getter)wrapping_dap_sign_get_pkey_hash, NULL,NULL}, - {"size", (getter)wrapping_dap_sign_get_size, NULL, NULL, NULL}, - {NULL} -}; - -static PyTypeObject DapSignObject_DapSignObjectType = { - PyVarObject_HEAD_INIT(NULL, 0) - "DAP.Sign", /* tp_name */ - sizeof(PyDapSignObject),/* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Sign object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - DapSignObjectGetsSetsDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapSignObject_DapSignObjectType; static bool PyDapSignObject_Check(PyObject *self){ return PyObject_TypeCheck(self, &DapSignObject_DapSignObjectType); } - #endif // _WRAPPING_DAP_SIGN_ diff --git a/modules/dap-sdk/crypto/src/libdap-crypto-python.c b/modules/dap-sdk/crypto/src/libdap-crypto-python.c index d3c0e9232c498477bd8e0a51dc54f21bc66731c8..82256b2a1d433a1b095fae4885ac224a57157fac 100644 --- a/modules/dap-sdk/crypto/src/libdap-crypto-python.c +++ b/modules/dap-sdk/crypto/src/libdap-crypto-python.c @@ -28,6 +28,76 @@ #define LOG_TAG "dap_crypto_python" +PyMethodDef g_crypto_methods_py[] = { + {"encodeBase58", dap_encode_base58_py, METH_VARARGS | METH_STATIC, "Encrypts information using the base58 algorithm from the DAP crypto library"}, + {"decodeBase58", dap_decode_base58_py, METH_VARARGS | METH_STATIC, "Dencrypts information using the base58 algorithm from the DAP crypto library"}, + {"encodeBase64", dap_encode_base64_py, METH_VARARGS | METH_STATIC, "Encrypts information using the base64 algorithm from the DAP crypto library"}, + {"decodeBase64", dap_decode_base64_py, METH_VARARGS | METH_STATIC, "Dencrypts information using the base64 algorithm from the DAP crypto library"}, + {"newKey", dap_enc_key_new_py, METH_VARARGS | METH_STATIC, "The function creates a new key, and returns it with PyObject."}, + {"generateNewKey", dap_enc_key_new_generate_py, METH_VARARGS | METH_STATIC, ""}, + {"getEncSizeKey", dap_enc_key_get_enc_size_py, METH_VARARGS | METH_STATIC, ""}, + {"getDecSizeKey", dap_enc_key_get_dec_size_py, METH_VARARGS | METH_STATIC, ""}, + /*IAES256*/ + {"newKeyIAES", dap_enc_iaes_key_new_py, METH_VARARGS | METH_STATIC, ""}, + {"deleteKeyIAES", dap_enc_iaes_key_delete_py, METH_VARARGS | METH_STATIC, ""}, + {"generateKeyIAES", dap_enc_iaes_key_generate_py, METH_VARARGS | METH_STATIC, ""}, + {"encodeSizeIAES256", dap_enc_iaes256_calc_encode_size_py, METH_VARARGS | METH_STATIC, ""}, + {"decodeSizeIAES256", dap_enc_iaes256_calc_decode_size_py, METH_VARARGS | METH_STATIC, ""}, + {"encryptIAES256CBCFast", dap_enc_iaes256_cbc_encrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, + {"decryptIAES256CBCFast", dap_enc_iaes256_cbc_decrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, + /*OAES*/ + {"newKeyOAES", dap_enc_oaes_key_new_py, METH_VARARGS | METH_STATIC, ""}, + {"deleteKeyOAES", dap_enc_oaes_key_delete_py, METH_VARARGS | METH_STATIC, ""}, + {"generateKeyOAES", dap_enc_oaes_key_generate_py, METH_VARARGS | METH_STATIC, ""}, + {"encodeSizeOAES", dap_enc_oaes_calc_encode_size_py, METH_VARARGS | METH_STATIC, ""}, + {"decodeSizeOAES", dap_enc_oaes_calc_decode_size_py, METH_VARARGS | METH_STATIC, ""}, + {"encryptOAESFast", dap_enc_oaes_encrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, + {"decryptOAESFast", dap_enc_oaes_decrypt_fast_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject g_crypto_type_py = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Crypto", /* tp_name */ + sizeof(PyCryptoObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Crypto objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + g_crypto_methods_py, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + int dap_crypto_init(void){ if(dap_enc_init()!=0){ log_it(L_CRITICAL,"Can't init encryption module"); diff --git a/modules/dap-sdk/crypto/src/libdap_crypto_data_type.c b/modules/dap-sdk/crypto/src/libdap_crypto_data_type.c new file mode 100644 index 0000000000000000000000000000000000000000..4f255531fee29594f713c1d83dc77850977883f8 --- /dev/null +++ b/modules/dap-sdk/crypto/src/libdap_crypto_data_type.c @@ -0,0 +1,61 @@ +#include "libdap_crypto_data_type.h" + +PyObject *get_ENC_DATA_TYPE_RAW(){ + return PyLong_FromLong(DAP_ENC_DATA_TYPE_RAW); +} +PyObject *get_ENC_DATA_TYPE_B64(){ + return PyLong_FromLong(DAP_ENC_DATA_TYPE_B64); +} +PyObject *get_ENC_DATA_TYPE_B64_URLSAFE(){ + return PyLong_FromLong(DAP_ENC_DATA_TYPE_B64_URLSAFE); +} + +PyMethodDef PyCryptoDataTypeObjectMethods[] = { + {"DAP_ENC_DATA_TYPE_RAW", (PyCFunction)get_ENC_DATA_TYPE_RAW, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_DATA_TYPE_B64", (PyCFunction)get_ENC_DATA_TYPE_B64, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_DATA_TYPE_B64_URLSAFE", (PyCFunction)get_ENC_DATA_TYPE_B64_URLSAFE, METH_NOARGS | METH_STATIC, ""}, + + {NULL, NULL, 0, NULL} +}; + +PyTypeObject CryptoDataTypeObject_CryptoDataTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.CryptoDataType", /* tp_name */ + sizeof(PyCryptoDataTypeObjecy), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Crypto data type objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyCryptoDataTypeObjectMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; diff --git a/modules/dap-sdk/crypto/src/libdap_crypto_key_python.c b/modules/dap-sdk/crypto/src/libdap_crypto_key_python.c new file mode 100644 index 0000000000000000000000000000000000000000..f96bd6e76cd7dd0d5e52860d5656e950140bfa2b --- /dev/null +++ b/modules/dap-sdk/crypto/src/libdap_crypto_key_python.c @@ -0,0 +1,30 @@ +#include "libdap_crypto_key_python.h" + +PyTypeObject PyCryptoKeyObject_PyCryptoKeyType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Crypto.Key", /* tp_name */ + sizeof(PyCryptoKeyObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PyCryptoKeyObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Crypto key objects", /* tp_doc */ +}; + +void PyCryptoKeyObject_dealloc(PyCryptoKeyObject *cryptoObject){ + dap_enc_key_delete(cryptoObject->key); + Py_TYPE(cryptoObject)->tp_free((PyObject*)cryptoObject); +} diff --git a/modules/dap-sdk/crypto/src/libdap_crypto_key_type_python.c b/modules/dap-sdk/crypto/src/libdap_crypto_key_type_python.c index 0a378715d4779ffe0b39de3e47bc345240a93861..4e28f3fcf1fcceeb60119e0e41a853bf57b6eac5 100644 --- a/modules/dap-sdk/crypto/src/libdap_crypto_key_type_python.c +++ b/modules/dap-sdk/crypto/src/libdap_crypto_key_type_python.c @@ -1,5 +1,71 @@ #include "libdap_crypto_key_type_python.h" +PyMethodDef PyCryptoKeyTypeObjectMethods[] = { + {"DAP_ENC_KEY_TYPE_IAES", (PyCFunction)get_ENC_KEY_TYPE_IAES, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_OAES", (PyCFunction)get_ENC_KEY_TYPE_OAES, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_RLWE_NEWHOPE", (PyCFunction)get_ENC_KEY_TYPE_RLWE_NEWHOPE, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIDH_CLN16", (PyCFunction)get_ENC_KEY_TYPE_SIDH_CLN16, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_DEFEO", (PyCFunction)get_ENC_KEY_TYPE_DEFEO, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_MSRLN", (PyCFunction)get_ENC_KEY_TYPE_MSRLN, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_MSRLN16", (PyCFunction)get_ENC_KEY_TYPE_MSRLN16, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_RLWE_BCNS15", (PyCFunction)get_ENC_KEY_TYPE_RLWE_BCNS15, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_LWE_FRODO", (PyCFunction)get_ENC_KEY_TYPE_LWE_FRODO, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIDH_IQC_REF", (PyCFunction)get_ENC_KEY_TYPE_SIDH_IQC_REF, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_CODE_MCBITS", (PyCFunction)get_ENC_KEY_TYPE_CODE_MCBITS, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_NTRU", (PyCFunction)get_ENC_KEY_TYPE_NTRU, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_MLWE_KYBER", (PyCFunction)get_ENC_KEY_TYPE_MLWE_KYBER, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIG_PICNIC", (PyCFunction)get_ENC_KEY_TYPE_SIG_PICNIC, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIG_BLISS", (PyCFunction)get_ENC_KEY_TYPE_SIG_BLISS, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIG_TESLA", (PyCFunction)get_ENC_KEY_TYPE_SIG_TESLA, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_SIG_DILITHIUM", (PyCFunction)get_ENC_KEY_TYPE_SIG_DILITHIUM, METH_NOARGS | METH_STATIC, ""}, + {"DAP_ENC_KEY_TYPE_NULL", (PyCFunction)get_ENC_KEY_TYPE_NULL, METH_NOARGS | METH_STATIC, ""}, + + + {NULL, NULL, 0, NULL} +}; + +PyTypeObject CryptoKeyTypeObject_CryptoKeyTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.CryptoKeyType", /* tp_name */ + sizeof(PyCryptoKeyTypeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Crypto keys type objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyCryptoKeyTypeObjectMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *get_ENC_KEY_TYPE_IAES(){ return PyLong_FromLong(DAP_ENC_KEY_TYPE_IAES); } diff --git a/modules/dap-sdk/crypto/src/wrapping_cert.c b/modules/dap-sdk/crypto/src/wrapping_cert.c index ff401fa87502206db4f3bbff67dac9b6f9cd6635..86d178a47d2fdbe7aa58d7907342f8054b66d93a 100644 --- a/modules/dap-sdk/crypto/src/wrapping_cert.c +++ b/modules/dap-sdk/crypto/src/wrapping_cert.c @@ -30,6 +30,73 @@ #include "libdap_crypto_key_type_python.h" #define LOG_TAG "wrapping_cert" +PyMethodDef g_crypto_cert_methods_py[] = { + {"generate",dap_cert_generate_py , METH_VARARGS | METH_STATIC, "Generate from seed or randomly the new certificate"}, + {"find", dap_cert_find_py, METH_VARARGS | METH_STATIC, ""}, + {"folderAdd", dap_cert_folder_add_py, METH_VARARGS | METH_STATIC, "Add folders with .dcert files in it"}, + {"folderGet", dap_cert_folder_get_py, METH_VARARGS | METH_STATIC, "Get folder by number or the default one"}, + {"load", dap_cert_load_py, METH_VARARGS | METH_STATIC ,""}, + {"dump", dap_cert_dump_py, METH_VARARGS , ""}, + {"pkey", dap_cert_pkey_py, METH_VARARGS , ""}, + {"sign", dap_cert_sign_py, METH_VARARGS , ""}, + {"certSignAdd", dap_cert_cert_sign_add_py, METH_VARARGS, ""}, + {"certSigns", dap_cert_cert_signs_py, METH_VARARGS , ""}, + {"compare", dap_cert_compare_py, METH_VARARGS, ""}, + {"save", dap_cert_save_py, METH_VARARGS , "Save to the first directory in cert folders list"}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject g_crypto_cert_type_py = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Cert", /* tp_name */ + sizeof(PyCryptoCertObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + dap_cert_delete_py, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Crypto cert object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + g_crypto_cert_methods_py, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +}; PyObject* dap_cert_generate_py(PyObject *self, PyObject *args) { diff --git a/modules/dap-sdk/crypto/src/wrapping_dap_enc_key.c b/modules/dap-sdk/crypto/src/wrapping_dap_enc_key.c index 19f11f9de00b3f83c7a93d8b15889635413d5d47..ad19f01bb8949013c83d892e15439da921f4d868 100644 --- a/modules/dap-sdk/crypto/src/wrapping_dap_enc_key.c +++ b/modules/dap-sdk/crypto/src/wrapping_dap_enc_key.c @@ -74,27 +74,56 @@ PyObject* dap_enc_key_new_py(PyObject *self, PyObject *args){ /// default gen key PyObject *dap_enc_key_new_generate_py(PyObject *self, PyObject *args){ uint8_t in_type_key; - PyBytesObject *in_kex_buf; - size_t in_kex_size; - PyBytesObject *in_seed; - size_t in_seed_size; + PyObject *obj_kex_buf; + PyObject *obj_seed = NULL; size_t in_key_size; - if (!PyArg_ParseTuple(args, "h|S|n|S|n|n", &in_type_key, &in_kex_buf, &in_kex_size, &in_seed, - &in_seed_size, &in_key_size)){ + if (!PyArg_ParseTuple(args, "iOn|O", &in_type_key, &obj_kex_buf, &in_key_size, &obj_seed)){ return NULL; } - if (in_type_key > 16){ - return PyLong_FromLong(-1); + void *l_kex_buf = NULL; + size_t l_kex_buf_size = 0; + void *l_seed = NULL; + size_t l_seed_size = 0; + if (PyUnicode_Check(obj_kex_buf)){ + const char *l_kex_buf_str = PyUnicode_AsUTF8(obj_kex_buf); + l_kex_buf_size = dap_strlen(l_kex_buf_str); + if (l_kex_buf_size < 1){ + PyErr_SetString(PyExc_SyntaxError, "The kex buffer size must be grater than one character"); + return NULL; + } + l_kex_buf = DAP_NEW_SIZE(char, l_kex_buf_size); + } else { + if (PyBytes_Check(obj_kex_buf)) { + l_kex_buf = PyBytes_AsString(obj_kex_buf); + l_kex_buf_size = PyBytes_Size(obj_kex_buf); + } else { + PyErr_SetString(PyExc_SyntaxError, "The second argument to this function can be either " + "a unicode string ot an object of type bytes"); + return NULL; + } + } + if (obj_seed != NULL){ + if (PyUnicode_Check(obj_seed)){ + const char *l_seed_buf_str = PyUnicode_AsUTF8(obj_seed); + l_seed_size = dap_strlen(l_seed_buf_str); + l_seed = DAP_NEW_SIZE(char, l_seed_size); + memcpy(l_seed, l_seed_buf_str, l_seed_size); + }else{ + if (PyBytes_Check(obj_seed)){ + l_seed = PyBytes_AsString(obj_seed); + l_seed_size = PyBytes_Size(obj_seed); + }else{ + PyErr_SetString(PyExc_SyntaxError, "The fourth argument to this function can be either " + "a unicode string ot an object of type bytes"); + return NULL; + } + } } - void *kex_buf = NULL; - void *seed = NULL; - if (in_kex_size != 0) - kex_buf = PyBytes_AsString((PyObject*)in_kex_buf); - if (in_seed_size != 0) - seed = PyBytes_AsString((PyObject*)in_seed); - PyCryptoKeyObject *obj_key = (PyCryptoKeyObject*)_PyObject_New(&PyCryptoKeyObject_PyCryptoKeyType); - obj_key->key = dap_enc_key_new_generate(in_type_key, kex_buf, in_kex_size, seed, in_seed_size, in_key_size); - return Py_BuildValue("O", (PyObject*)obj_key); + PyCryptoKeyObject *obj_key = PyObject_New(PyCryptoKeyObject, &PyCryptoKeyObject_PyCryptoKeyType); + PyObject_Dir((PyObject*)obj_key); + obj_key->key = dap_enc_key_new_generate(in_type_key, l_kex_buf, l_kex_buf_size, + l_seed, l_seed_size, in_key_size); + return (PyObject*)obj_key; } // update struct dap_enc_key_t after insert foreign keys diff --git a/modules/dap-sdk/crypto/src/wrapping_dap_hash.c b/modules/dap-sdk/crypto/src/wrapping_dap_hash.c index 9d1eced234fec087d9c2b3a79ced173d16084d03..9e47c199382998932c4c162d7110162b95faf461 100644 --- a/modules/dap-sdk/crypto/src/wrapping_dap_hash.c +++ b/modules/dap-sdk/crypto/src/wrapping_dap_hash.c @@ -1,5 +1,54 @@ #include "wrapping_dap_hash.h" +/* Hash type */ +PyMethodDef DapHashTypeMethods[] = { + {"DAP_HASH_TYPE_KECCAK", (PyCFunction)DAP_HASH_TYPE_KECCAK_PY, METH_NOARGS | METH_STATIC, ""}, + {"DAP_HASH_TYPE_SLOW_0", (PyCFunction)DAP_HASH_TYPE_SLOW_0_PY, METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapHashTypeObject_DapChainHashTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.HashType", /* tp_name */ + sizeof(PyDapHashTypeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Hash type object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapHashTypeMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *DAP_HASH_TYPE_KECCAK_PY(){ PyObject *obj = _PyObject_New(&DapHashTypeObject_DapChainHashTypeObjectType); ((PyDapHashTypeObject*)obj)->hash_type = DAP_HASH_TYPE_KECCAK; @@ -11,6 +60,60 @@ PyObject *DAP_HASH_TYPE_SLOW_0_PY(){ return Py_BuildValue("O", obj); } +/* Chain hash fast */ +PyMethodDef DapHashFastMethods[] = { + {"strToHashFast", (PyCFunction)dap_chain_str_to_hash_fast_py, METH_VARARGS | METH_STATIC, ""}, + {"hashFast", (PyCFunction)dap_hash_fast_py, METH_VARARGS, ""}, + {"compare", (PyCFunction)dap_hash_fast_compare_py, METH_VARARGS | METH_STATIC, ""}, + {"isBlank", (PyCFunction)dap_hash_fast_is_blank_py, METH_VARARGS, ""}, + {"toStr", (PyCFunction)dap_chain_hash_fast_to_str_py, METH_VARARGS, ""}, + {"toStrNew", (PyCFunction)dap_chain_hash_fast_to_str_new_py, METH_VARARGS, ""}, + {"__str__", (PyCFunction)wrapping_dap_hash_to_str, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapHashFastObject_DapHashFastObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.HashFast", /* tp_name */ + sizeof(PyDapHashFastObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + wrapping_dap_hash_to_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Hash fast object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapHashFastMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_chain_str_to_hash_fast_py(PyObject *self, PyObject *args){ const char *hash_str; if (!PyArg_ParseTuple(args, "s", &hash_str)) @@ -75,6 +178,6 @@ PyObject *wrapping_dap_hash_to_str(PyObject *self){ Py_BuildValue("s", "Hash is missing."); } int res = dap_chain_hash_fast_to_str(((PyDapHashFastObject*)self)->hash_fast, str, 70); - PyObject *obj_str = PyUnicode_FromStringAndSize(str, res); + PyObject *obj_str = PyUnicode_FromString(str); return obj_str; } diff --git a/modules/dap-sdk/crypto/src/wrapping_dap_pkey.c b/modules/dap-sdk/crypto/src/wrapping_dap_pkey.c index cacc8b05e8b754ca988b4d58320706f0eeb267b1..1856ff9064ee00d27e2aa40ccce4a48a90e7a7a1 100644 --- a/modules/dap-sdk/crypto/src/wrapping_dap_pkey.c +++ b/modules/dap-sdk/crypto/src/wrapping_dap_pkey.c @@ -1,10 +1,105 @@ #include "wrapping_dap_pkey.h" +PyTypeObject DapPkeyTypeObject_DapPkeyTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.PkeyType", /* tp_name */ + sizeof(PyDapPkeyTypeObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapPkeyType_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Pkey type object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *PyDapPkeyType_str(PyObject *self){ const char *str = dap_pkey_type_to_str(*((PyDapPkeyTypeObject*)self)->pkey_type); return Py_BuildValue("s", str); } +PyGetSetDef PyDapPkeyGetsSetsDef[] = { + {"hash", (getter)wrapping_dap_pkey_get_hash, NULL, NULL, NULL}, + {"type", (getter)wrapping_dap_pkey_get_type, NULL, NULL, NULL}, + {"size", (getter)wrapping_dap_pkey_get_size, NULL, NULL, NULL}, + {NULL} +}; + +PyMethodDef PyDapPkeyMethods[]={ + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapPkeyObject_DapPkeyObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Pkey", /* tp_name */ + sizeof(PyDapPkeyObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Pkey object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapPkeyMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapPkeyGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_pkey_get_type(PyObject *self, void *closure){ (void)closure; PyDapPkeyTypeObject *obj_type_pkey = PyObject_New(PyDapPkeyTypeObject, &DapPkeyTypeObject_DapPkeyTypeObjectType); diff --git a/modules/dap-sdk/crypto/src/wrapping_dap_sign.c b/modules/dap-sdk/crypto/src/wrapping_dap_sign.c index 194cd9d34b3d1281fa8dc8011237e92ef05ff592..2680bf0710d9f9c662e5dd0d6e0b6edb79c83225 100644 --- a/modules/dap-sdk/crypto/src/wrapping_dap_sign.c +++ b/modules/dap-sdk/crypto/src/wrapping_dap_sign.c @@ -1,9 +1,103 @@ #include "wrapping_dap_sign.h" +/* Sign type*/ +PyTypeObject DapSignTypeObject_DapSignTypeObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.SignType", /* tp_name */ + sizeof(PyDapSignTypeObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + PyDapSignType_to_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Sign type object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *PyDapSignType_to_str(PyObject *self){ return Py_BuildValue("s", dap_sign_type_to_str(*((PyDapSignTypeObject*)self)->sign_type)); } +/* Sign */ +PyGetSetDef DapSignObjectGetsSetsDef[] = { + {"type", (getter)wrapping_dap_sign_get_type, NULL, NULL, NULL}, + {"pkey", (getter)wrapping_dap_sign_get_pkey, NULL, NULL, NULL}, + {"pkeyHash", (getter)wrapping_dap_sign_get_pkey_hash, NULL,NULL}, + {"size", (getter)wrapping_dap_sign_get_size, NULL, NULL, NULL}, + {NULL} +}; + +PyTypeObject DapSignObject_DapSignObjectType = { + PyVarObject_HEAD_INIT(NULL, 0) + "DAP.Sign", /* tp_name */ + sizeof(PyDapSignObject),/* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Sign object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, /* tp_members */ + DapSignObjectGetsSetsDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *wrapping_dap_sign_get_type(PyObject *self, void *closure){ (void)closure; PyDapSignTypeObject *obj_type_sign = PyObject_New(PyDapSignTypeObject, &DapSignTypeObject_DapSignTypeObjectType); diff --git a/modules/dap-sdk/net/client/include/libdap_client_python.h b/modules/dap-sdk/net/client/include/libdap_client_python.h index 9a95fbf75234b16249550749214b3156fddb9325..a4455a341287a67b93f65307bfde8df83648e529 100644 --- a/modules/dap-sdk/net/client/include/libdap_client_python.h +++ b/modules/dap-sdk/net/client/include/libdap_client_python.h @@ -45,52 +45,7 @@ PyObject *dap_client_set_active_channels_py(PyObject *self, PyObject *args); PyObject *dap_client_get_stage_py(PyObject *self, PyObject *args); PyObject *dap_client_get_stage_status_py(PyObject *self, PyObject *args); -static PyMethodDef DapClientMethods[] = { - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject dapClientObject_dapClientType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.Client", /* tp_name */ - sizeof(PyDapClientObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Client objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapClientMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; +extern PyTypeObject dapClientObject_dapClientType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/client/include/wrapping_dap_client_stage.h b/modules/dap-sdk/net/client/include/wrapping_dap_client_stage.h index bb3a9fe88d21ab26d2ad4b53a439d0e9e0cc278a..b19b40a629517c2e683c839561fa62d6e51934d3 100644 --- a/modules/dap-sdk/net/client/include/wrapping_dap_client_stage.h +++ b/modules/dap-sdk/net/client/include/wrapping_dap_client_stage.h @@ -20,62 +20,7 @@ PyObject *STAGE_STREAM_CONNECTED_PY(); PyObject *STAGE_STREAM_STREAMING_PY(); PyObject *STAGE_STREAM_ABORT_PY(); -static PyMethodDef DapClientStageMethods[] = { - {"STAGE_BEGIN", (PyCFunction)STAGE_BEGIN_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_ENC_INIT", (PyCFunction)STAGE_ENC_INIT_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STREAM_CTL", (PyCFunction)STAGE_STREAM_CTL_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STREAM_SESSION", (PyCFunction)STAGE_STREAM_SESSION_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STREAM_CONNECTED", (PyCFunction)STAGE_STREAM_CONNECTED_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STREAM_STREAMING", (PyCFunction)STAGE_STREAM_STREAMING_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STREAM_ABORT",(PyCFunction) STAGE_STREAM_ABORT_PY, METH_NOARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject dapClientStageObject_dapClientStageType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ClientStage", /* tp_name */ - sizeof(PyDapClientStageObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Client stage objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapClientStageMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; - - - +extern PyTypeObject dapClientStageObject_dapClientStageType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/client/include/wrapping_dap_client_stage_status.h b/modules/dap-sdk/net/client/include/wrapping_dap_client_stage_status.h index 8b33546fbec58bcf03add34be043c4c8b5035551..fe5b1d718d57a1b04d0ba531124d213041ca6e2f 100644 --- a/modules/dap-sdk/net/client/include/wrapping_dap_client_stage_status.h +++ b/modules/dap-sdk/net/client/include/wrapping_dap_client_stage_status.h @@ -20,61 +20,7 @@ PyObject *STAGE_STATUS_ABORTING_PY(); PyObject *STAGE_STATUS_ERROR_PY(); PyObject *STAGE_STATUS_DONE_PY(); - -PyMethodDef DapClientStageStatusMethods[] = { - {"STAGE_STATUS_NONE", STAGE_STATUS_NONE_PY, METH_NOARGS, ""}, - // Enc init stage - {"STAGE_STATUS_IN_PROGRESS", STAGE_STATUS_IN_PROGRESS_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STATUS_ABORTING", STAGE_STATUS_ABORTING_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STATUS_ERROR", STAGE_STATUS_ERROR_PY, METH_NOARGS | METH_STATIC, ""}, - {"STAGE_STATUS_DONE", STAGE_STATUS_DONE_PY, METH_NOARGS | METH_STATIC, ""}, - - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject dapClientStageStatusObject_dapClientStageStatusType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ClientStageStatus", /* tp_name */ - sizeof(PyDapClientStageStatusObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Client stage status objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapClientStageStatusMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - -}; - +extern PyTypeObject dapClientStageStatusObject_dapClientStageStatusType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/client/src/libdap_client_python.c b/modules/dap-sdk/net/client/src/libdap_client_python.c index a6950eeaaf41cf9e97efa8364cbd6683bb42f7ae..dd9eb4291d03220c2c8cb914782c6f65bd761974 100644 --- a/modules/dap-sdk/net/client/src/libdap_client_python.c +++ b/modules/dap-sdk/net/client/src/libdap_client_python.c @@ -1,5 +1,52 @@ #include "libdap_client_python.h" +PyMethodDef DapClientMethods[] = { + {NULL, NULL, 0, NULL} +}; + +PyTypeObject dapClientObject_dapClientType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.Client", /* tp_name */ + sizeof(PyDapClientObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Client objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapClientMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + int dap_client_init_py(){ return dap_client_init(); } diff --git a/modules/dap-sdk/net/client/src/wrapping_dap_client_stage.c b/modules/dap-sdk/net/client/src/wrapping_dap_client_stage.c index 25cc196673915741813f4ff7b2e78e5393ee4e09..9f4d361ac2d9ad09e75bdda2bf3b0a92018dad52 100644 --- a/modules/dap-sdk/net/client/src/wrapping_dap_client_stage.c +++ b/modules/dap-sdk/net/client/src/wrapping_dap_client_stage.c @@ -1,5 +1,59 @@ #include "wrapping_dap_client_stage.h" +PyMethodDef DapClientStageMethods[] = { + {"STAGE_BEGIN", (PyCFunction)STAGE_BEGIN_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_ENC_INIT", (PyCFunction)STAGE_ENC_INIT_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STREAM_CTL", (PyCFunction)STAGE_STREAM_CTL_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STREAM_SESSION", (PyCFunction)STAGE_STREAM_SESSION_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STREAM_CONNECTED", (PyCFunction)STAGE_STREAM_CONNECTED_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STREAM_STREAMING", (PyCFunction)STAGE_STREAM_STREAMING_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STREAM_ABORT",(PyCFunction) STAGE_STREAM_ABORT_PY, METH_NOARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject dapClientStageObject_dapClientStageType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ClientStage", /* tp_name */ + sizeof(PyDapClientStageObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Client stage objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapClientStageMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + PyObject *STAGE_BEGIN_PY(){ PyDapClientStageObject *obj_stage = (PyDapClientStageObject*)_PyObject_New(&dapClientStageObject_dapClientStageType); obj_stage->stage = STAGE_BEGIN; diff --git a/modules/dap-sdk/net/client/src/wrapping_dap_client_stage_status.c b/modules/dap-sdk/net/client/src/wrapping_dap_client_stage_status.c index ff1603ab0c656b38cb381eebadd580dc0b14c866..a6c8dbad2f1a8e00b459d42a2af9247ccb669af9 100644 --- a/modules/dap-sdk/net/client/src/wrapping_dap_client_stage_status.c +++ b/modules/dap-sdk/net/client/src/wrapping_dap_client_stage_status.c @@ -1,5 +1,59 @@ #include "wrapping_dap_client_stage_status.h" +PyMethodDef DapClientStageStatusMethods[] = { + {"STAGE_STATUS_NONE", STAGE_STATUS_NONE_PY, METH_NOARGS, ""}, + // Enc init stage + {"STAGE_STATUS_IN_PROGRESS", STAGE_STATUS_IN_PROGRESS_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STATUS_ABORTING", STAGE_STATUS_ABORTING_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STATUS_ERROR", STAGE_STATUS_ERROR_PY, METH_NOARGS | METH_STATIC, ""}, + {"STAGE_STATUS_DONE", STAGE_STATUS_DONE_PY, METH_NOARGS | METH_STATIC, ""}, + + {NULL, NULL, 0, NULL} +}; + +PyTypeObject dapClientStageStatusObject_dapClientStageStatusType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ClientStageStatus", /* tp_name */ + sizeof(PyDapClientStageStatusObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Client stage status objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapClientStageStatusMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + +}; + PyObject *STAGE_STATUS_NONE_PY(){ PyDapClientStageStatusObject *obj_stage_status = (PyDapClientStageStatusObject*)_PyObject_New( &dapClientStageStatusObject_dapClientStageStatusType); diff --git a/modules/dap-sdk/net/core/include/dap_events_python.h b/modules/dap-sdk/net/core/include/dap_events_python.h index c79f86dff81b5cec4933be34e3461b9c1da8fa66..b77e8528879937ce2ae3707e0aa4fadb1c32b52a 100644 --- a/modules/dap-sdk/net/core/include/dap_events_python.h +++ b/modules/dap-sdk/net/core/include/dap_events_python.h @@ -24,55 +24,7 @@ PyObject *dap_events_socket_kill_socket_py(PyDapEventsObject *self, PyObject *ar PyObject *dap_events_start_py(PyDapEventsObject *self); PyObject *dap_events_wait_py(PyDapEventsObject *self); -static PyMethodDef PyDapEventsObject_methods[] = { - {"start", (PyCFunction)dap_events_start_py, METH_NOARGS, ""}, - {"wait", (PyCFunction)dap_events_wait_py, METH_NOARGS, ""}, - {"killSocket", (PyCFunction)dap_events_socket_kill_socket_py, METH_VARARGS, ""}, - {"removeAndDeleteSocket", (PyCFunction)dap_events_socket_remove_and_delete_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -static PyTypeObject dapEvents_dapEventsType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ServerCore.DapEvents", /* tp_name */ - sizeof(PyDapEventsObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PyDapEventsObject_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "DapEvents objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapEventsObject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyDapEventsObject_new, /* tp_new */ -}; +extern PyTypeObject dapEvents_dapEventsType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/core/include/dap_events_socket_python.h b/modules/dap-sdk/net/core/include/dap_events_socket_python.h index e4fb86e2d3b358cbbd3deea64814e923e8c02273..5a6767cda3336836df957f48cf7fcb1e16081e67 100644 --- a/modules/dap-sdk/net/core/include/dap_events_socket_python.h +++ b/modules/dap-sdk/net/core/include/dap_events_socket_python.h @@ -27,59 +27,7 @@ PyObject *dap_events_socket_delete_py(PyDapEventsSocketObject *self, PyObject *a PyObject *dap_events_socket_shrink_buf_in_py(PyDapEventsSocketObject *self, PyObject *args); -static PyMethodDef PyDapEventsObjectSocket_methods[] = { - {"createAfter", (PyCFunction)dap_events_socket_create_after_py, METH_NOARGS, ""}, - {"setReadable", (PyCFunction)dap_events_socket_set_readable_py, METH_VARARGS, ""}, - {"setWritable", (PyCFunction)dap_events_socket_set_writable_py, METH_VARARGS, ""}, - {"write", (PyCFunction)dap_events_socket_write_py, METH_VARARGS, ""}, - {"writeF", (PyCFunction)dap_events_socket_write_f_py, METH_VARARGS, ""}, - {"read", (PyCFunction)dap_events_socket_read_py, METH_VARARGS, ""}, - {"delete", (PyCFunction)dap_events_socket_delete_py, METH_VARARGS, ""}, - {"shringBufIn", (PyCFunction)dap_events_socket_shrink_buf_in_py, METH_VARARGS, ""}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -static PyTypeObject dapEventsSocket_dapEventsSocketType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ServerCore.DapEventsSocket", /* tp_name */ - sizeof(PyDapEventsSocketObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "DapEventsSocket objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapEventsObjectSocket_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject dapEventsSocket_dapEventsSocketType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/core/include/dap_server_python.h b/modules/dap-sdk/net/core/include/dap_server_python.h index d208b5a033572a4bfdad713110fc1a22e8abd2fb..9bcec3fc5ee9313327c5d6148a1ed2feb2123167 100644 --- a/modules/dap-sdk/net/core/include/dap_server_python.h +++ b/modules/dap-sdk/net/core/include/dap_server_python.h @@ -12,29 +12,7 @@ typedef struct PyDapServer { dap_server_t *t_server; }PyDapServerObject; -static PyTypeObject dapServer_dapServerType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.ServerCore.DapServer", /* tp_name */ - sizeof(PyDapServerObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - "DapServer objects", /* tp_doc */ -}; +extern PyTypeObject dapServer_dapServerType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/core/include/libdap-server-core-python.h b/modules/dap-sdk/net/core/include/libdap-server-core-python.h index bb14b5b6296e7e34a51ae743bd07f54f61f6829b..15b31abf070714ec50a66b8a6d658607ee8e40a9 100644 --- a/modules/dap-sdk/net/core/include/libdap-server-core-python.h +++ b/modules/dap-sdk/net/core/include/libdap-server-core-python.h @@ -23,55 +23,7 @@ void dap_server_core_deinit(void); PyObject *dap_server_core_loop(PyObject *self, PyObject *args); PyObject *dap_server_core_listen(PyObject *self, PyObject *args); -static PyMethodDef ServerCorePythonMethods[] = { - {"listen", dap_server_core_listen, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - - -static PyTypeObject ServerCore_ServerCoreType = { - PyVarObject_HEAD_INIT(NULL, 0) - "ServerCore", /* tp_name */ - sizeof(PyServerCoreObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "ServerCore objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ServerCorePythonMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0 , /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; - - +extern PyTypeObject ServerCore_ServerCoreType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/core/src/dap_events_python.c b/modules/dap-sdk/net/core/src/dap_events_python.c index 9e3b6a3fc8cc29cc29e65a89bdef2846cba3eb74..c85462c581bbd88fcfe6d0ef6202d465b30f4fb0 100644 --- a/modules/dap-sdk/net/core/src/dap_events_python.c +++ b/modules/dap-sdk/net/core/src/dap_events_python.c @@ -1,5 +1,55 @@ #include "dap_events_python.h" +PyMethodDef PyDapEventsObject_methods[] = { + {"start", (PyCFunction)dap_events_start_py, METH_NOARGS, ""}, + {"wait", (PyCFunction)dap_events_wait_py, METH_NOARGS, ""}, + {"killSocket", (PyCFunction)dap_events_socket_kill_socket_py, METH_VARARGS, ""}, + {"removeAndDeleteSocket", (PyCFunction)dap_events_socket_remove_and_delete_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyTypeObject dapEvents_dapEventsType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ServerCore.DapEvents", /* tp_name */ + sizeof(PyDapEventsObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)PyDapEventsObject_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "DapEvents objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapEventsObject_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyDapEventsObject_new, /* tp_new */ +}; + PyObject *PyDapEventsObject_new(PyTypeObject *type_object, PyObject *args, PyObject *kwds){ PyDapEventsObject *new_EO = (PyDapEventsObject*)PyType_GenericNew(type_object, args, kwds); new_EO->t_events = dap_events_new(); diff --git a/modules/dap-sdk/net/core/src/dap_events_socket_python.c b/modules/dap-sdk/net/core/src/dap_events_socket_python.c index 1e155e27662c85462d2f2b3bf8124892bd3d60ff..9685de9786c8ef0861c476926dcc0204ad803e25 100644 --- a/modules/dap-sdk/net/core/src/dap_events_socket_python.c +++ b/modules/dap-sdk/net/core/src/dap_events_socket_python.c @@ -2,6 +2,60 @@ #define LOG_TAG "dap_events_socket_python" +PyMethodDef PyDapEventsObjectSocket_methods[] = { + {"createAfter", (PyCFunction)dap_events_socket_create_after_py, METH_NOARGS, ""}, + {"setReadable", (PyCFunction)dap_events_socket_set_readable_py, METH_VARARGS, ""}, + {"setWritable", (PyCFunction)dap_events_socket_set_writable_py, METH_VARARGS, ""}, + {"write", (PyCFunction)dap_events_socket_write_py, METH_VARARGS, ""}, + {"writeF", (PyCFunction)dap_events_socket_write_f_py, METH_VARARGS, ""}, + {"read", (PyCFunction)dap_events_socket_read_py, METH_VARARGS, ""}, + {"delete", (PyCFunction)dap_events_socket_delete_py, METH_VARARGS, ""}, + {"shringBufIn", (PyCFunction)dap_events_socket_shrink_buf_in_py, METH_VARARGS, ""}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyTypeObject dapEventsSocket_dapEventsSocketType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ServerCore.DapEventsSocket", /* tp_name */ + sizeof(PyDapEventsSocketObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "DapEventsSocket objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapEventsObjectSocket_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *dap_events_socket_create_after_py(PyDapEventsSocketObject *self){ if (self->t_events_socket == NULL){ return NULL; diff --git a/modules/dap-sdk/net/core/src/dap_server_python.c b/modules/dap-sdk/net/core/src/dap_server_python.c new file mode 100644 index 0000000000000000000000000000000000000000..f81bbb1b24ac5b12bcd6fd5367ffd0bb031ce8f4 --- /dev/null +++ b/modules/dap-sdk/net/core/src/dap_server_python.c @@ -0,0 +1,25 @@ +#include "dap_server_python.h" + +PyTypeObject dapServer_dapServerType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.ServerCore.DapServer", /* tp_name */ + sizeof(PyDapServerObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "DapServer objects", /* tp_doc */ +}; diff --git a/modules/dap-sdk/net/core/src/libdap-server-core-python.c b/modules/dap-sdk/net/core/src/libdap-server-core-python.c index 4eb4cd656fa45784368011f4ce62c4f3ebe81aef..d80639f58402b54eafec1fe96e0ef55ba8beefce 100644 --- a/modules/dap-sdk/net/core/src/libdap-server-core-python.c +++ b/modules/dap-sdk/net/core/src/libdap-server-core-python.c @@ -2,6 +2,54 @@ #define LOG_TAG "libdap-server-core-python" +PyMethodDef ServerCorePythonMethods[] = { + {"listen", dap_server_core_listen, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + + +PyTypeObject ServerCore_ServerCoreType = { + PyVarObject_HEAD_INIT(NULL, 0) + "ServerCore", /* tp_name */ + sizeof(PyServerCoreObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "ServerCore objects", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ServerCorePythonMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0 , /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + int dap_server_core_init(uint32_t l_thread_cnt, size_t conn_t){ int result = dap_server_init(); if ( result != 0 ) { diff --git a/modules/dap-sdk/net/server/enc/include/wrapping_dap_enc_http.h b/modules/dap-sdk/net/server/enc/include/wrapping_dap_enc_http.h index 8af685eda8ab6dfcf5b271259e23ce022a26e1cf..d08c1339d0c048a7bbd2703b6428baa4634f7a15 100644 --- a/modules/dap-sdk/net/server/enc/include/wrapping_dap_enc_http.h +++ b/modules/dap-sdk/net/server/enc/include/wrapping_dap_enc_http.h @@ -20,66 +20,9 @@ PyObject *enc_http_reply_encode_py(PyObject *self, PyObject *args); void enc_http_delegate_delete_py(PyObject *self); PyObject *enc_http_add_proc_py(PyObject *self, PyObject *args); -static PyMethodDef PyDapEncServerMethods[] = { - {"requestDecode", enc_http_request_decode_py, METH_VARARGS | METH_STATIC, ""}, - {"isNull", enc_http_is_null_py, METH_NOARGS, ""}, - {"reply", enc_http_reply_py, METH_VARARGS, ""}, - {"replyEncode", enc_http_reply_encode_py, METH_VARARGS, ""}, - {"addProc", enc_http_add_proc_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - PyObject *enc_http_get_action_py(PyDapEncServerObject *self, void *clouser); PyObject *enc_http_get_request_py(PyDapEncServerObject *self, void *clouser); PyObject *enc_http_get_url_path_py(PyDapEncServerObject *self, void *clouser); PyObject *enc_http_get_in_query_py(PyDapEncServerObject *self, void *clouser); -static PyGetSetDef PyDapEncServerGetSet[] = { - {"action", (getter)enc_http_get_action_py, NULL, "Return action request", NULL}, - {"request", (getter)enc_http_get_request_py, NULL, "Return request in view bytes", NULL}, - {"urlPath", (getter)enc_http_get_url_path_py, NULL, "Return request in view bytes", NULL}, - {"query", (getter)enc_http_get_in_query_py, NULL, "Return request in view bytes", NULL}, - {NULL} -}; - -static PyTypeObject DapEncServer_DapEncServerType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.EncHttp", /* tp_name */ - sizeof(PyDapEncServerObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)enc_http_delegate_delete_py, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap enc server object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapEncServerMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapEncServerGetSet, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapEncServer_DapEncServerType; diff --git a/modules/dap-sdk/net/server/enc/src/wrapping_dap_enc_http.c b/modules/dap-sdk/net/server/enc/src/wrapping_dap_enc_http.c index c9e402a947923b71e04a5c3c828645032e297f02..70e60c03e887ea7cad618d06037b10222e0f8fd4 100644 --- a/modules/dap-sdk/net/server/enc/src/wrapping_dap_enc_http.c +++ b/modules/dap-sdk/net/server/enc/src/wrapping_dap_enc_http.c @@ -1,5 +1,64 @@ #include "wrapping_dap_enc_http.h" +PyMethodDef PyDapEncServerMethods[] = { + {"requestDecode", enc_http_request_decode_py, METH_VARARGS | METH_STATIC, ""}, + {"isNull", enc_http_is_null_py, METH_NOARGS, ""}, + {"reply", enc_http_reply_py, METH_VARARGS, ""}, + {"replyEncode", enc_http_reply_encode_py, METH_VARARGS, ""}, + {"addProc", enc_http_add_proc_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef PyDapEncServerGetSet[] = { + {"action", (getter)enc_http_get_action_py, NULL, "Return action request", NULL}, + {"request", (getter)enc_http_get_request_py, NULL, "Return request in view bytes", NULL}, + {"urlPath", (getter)enc_http_get_url_path_py, NULL, "Return request in view bytes", NULL}, + {"query", (getter)enc_http_get_in_query_py, NULL, "Return request in view bytes", NULL}, + {NULL} +}; + +PyTypeObject DapEncServer_DapEncServerType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.EncHttp", /* tp_name */ + sizeof(PyDapEncServerObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)enc_http_delegate_delete_py, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap enc server object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapEncServerMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapEncServerGetSet, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + PyObject *enc_http_reply_py(PyObject *self, PyObject *args){ PyObject *l_obj_bytes; if (!PyArg_ParseTuple(args, "O", &l_obj_bytes)){ diff --git a/modules/dap-sdk/net/server/http/include/wrapping_dap_http_simple.h b/modules/dap-sdk/net/server/http/include/wrapping_dap_http_simple.h index c1cec4db486ea70f376c125979d96aaf08a9d290..db731e13ae401b68d56e11a22509ce26cd14a852 100644 --- a/modules/dap-sdk/net/server/http/include/wrapping_dap_http_simple.h +++ b/modules/dap-sdk/net/server/http/include/wrapping_dap_http_simple.h @@ -25,73 +25,13 @@ PyObject *dap_http_simple_set_supported_user_agents_py(PyObject *self, PyObject PyObject *dap_http_simple_set_pass_unknown_user_agents_py(PyObject *self, PyObject *args); PyObject *dap_http_simple_reply_py(PyObject *self, PyObject *args); -static PyMethodDef PyDapHttpSimpleMethods[] = { - //{"addProc", enc_http_add_proc_py, METH_VARARGS | METH_STATIC, ""}, - {"init", dap_http_simple_module_init_py, METH_NOARGS | METH_STATIC, "Initialization module http simple"}, - {"deinit", dap_http_simple_module_deinit_py, METH_NOARGS | METH_STATIC, "Deinitialization module http simple"}, - {"addProc", dap_http_simple_add_proc_py, METH_VARARGS | METH_STATIC, "Add HTTP URL"}, - {"setPassUnknownUserAgents", dap_http_simple_set_pass_unknown_user_agents_py, METH_VARARGS | METH_STATIC, ""}, - {"replyAdd", dap_http_simple_reply_py, METH_VARARGS, "Reply for request"}, - {NULL, NULL, 0, NULL} -}; - /* Attributes */ PyObject *dap_http_simple_method_py(PyDapHttpSimpleObject *self, void *clouser); PyObject *dap_http_simple_request_py(PyDapHttpSimpleObject *self, void *clouser); PyObject *dap_http_simple_url_path_py(PyDapHttpSimpleObject *self, void *clouser); PyObject *dap_http_simple_query_py(PyDapHttpSimpleObject *self, void *clouser); -static PyGetSetDef PyDapHttpSimpleGetSetDef[] = { - {"action", (getter)dap_http_simple_method_py, NULL, "Return action request", NULL}, - {"request", (getter)dap_http_simple_request_py, NULL, "Return request in view bytes", NULL}, - {"urlPath", (getter)dap_http_simple_url_path_py, NULL, "Return request in view bytes", NULL}, - {"query", (getter)dap_http_simple_query_py, NULL, "Return request in view bytes", NULL}, - {NULL} -}; - -/*------------*/ - -static PyTypeObject DapHTTPSimple_DapHTTPSimpleType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.HttpSimple", /* tp_name */ - sizeof(PyDapHttpSimpleObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap http simple object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapHttpSimpleMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapHttpSimpleGetSetDef, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapHTTPSimple_DapHTTPSimpleType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/server/http/include/wrapping_http.h b/modules/dap-sdk/net/server/http/include/wrapping_http.h index f6a8718d97412029f77c3ed2ea2b36ffc73de905..8b8cab5b4eff9389bb86a412b72dc70952a433a2 100644 --- a/modules/dap-sdk/net/server/http/include/wrapping_http.h +++ b/modules/dap-sdk/net/server/http/include/wrapping_http.h @@ -16,52 +16,7 @@ typedef struct PyDapHttp{ PyObject *dap_http_new_py(PyObject *self, PyObject *args); -static PyMethodDef DapHttpMethods[] = { - {"new", dap_http_new_py, METH_VARARGS | METH_STATIC, ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapHTTP_DapHTTPType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.DapHttp", /* tp_name */ - sizeof(PyDapHttpObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap Http object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - DapHttpMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapHTTP_DapHTTPType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/server/http/include/wrapping_http_status_code.h b/modules/dap-sdk/net/server/http/include/wrapping_http_status_code.h index 1ebeba8955efcd687866adab98f99d41966be648..2b5c19ad3dab5956dc8376abb2347d8c487ee330 100644 --- a/modules/dap-sdk/net/server/http/include/wrapping_http_status_code.h +++ b/modules/dap-sdk/net/server/http/include/wrapping_http_status_code.h @@ -4,9 +4,6 @@ #include "http_status_code.h" #include "Python.h" -#undef LOG_TAG -#define LOG_TAG "wrapping_http_status_code" - #ifdef __cplusplus extern "C" { #endif @@ -16,158 +13,13 @@ typedef struct PyHTTPStatusCode{ http_status_code_t http_status; }PyHttpStatusCodeObject; -static http_status_code_t _get_status_code_from_init(int a_code){ - switch (a_code) { -// case - /*####### 1xx - Informational #######*/ - case 100: return Http_Status_OK; - case 101: return Http_Status_SwitchingProtocols; - case 102: return Http_Status_Processing; - case 103: return Http_Status_EarlyHints; - - /*####### 2xx - Successful #######*/ - case 200: return Http_Status_OK; - case 201: return Http_Status_Created; - case 202: return Http_Status_Accepted; - case 203: return Http_Status_NonAuthoritativeInformation; - case 204: return Http_Status_NoContent; - case 205: return Http_Status_ResetContent; - case 206: return Http_Status_PartialContent; - case 207: return Http_Status_MultiStatus; - case 208: return Http_Status_AlreadyReported; - case 226: return Http_Status_IMUsed; - - /*####### 3xx - Redirection #######*/ - case 300: return Http_Status_MultipleChoices; - case 301: return Http_Status_MovedPermanently; - case 302: return Http_Status_Found; - case 303: return Http_Status_SeeOther; - case 304: return Http_Status_NotModified; - case 305: return Http_Status_UseProxy; - case 307: return Http_Status_TemporaryRedirect; - case 308: return Http_Status_PermanentRedirect; - - /*####### 4xx - Client Error #######*/ - case 400: return Http_Status_BadRequest; - case 401: return Http_Status_Unauthorized; - case 402: return Http_Status_PaymentRequired; - case 403: return Http_Status_Forbidden; - case 404: return Http_Status_NotFound; - case 405: return Http_Status_MethodNotAllowed; - case 406: return Http_Status_NotAcceptable; - case 407: return Http_Status_ProxyAuthenticationRequired; - case 408: return Http_Status_RequestTimeout; - case 409: return Http_Status_Conflict; - case 410: return Http_Status_Gone; - case 411: return Http_Status_LengthRequired; - case 412: return Http_Status_PreconditionFailed; - case 413: return Http_Status_PayloadTooLarge; - case 414: return Http_Status_URITooLong; - case 415: return Http_Status_UnsupportedMediaType; - case 416: return Http_Status_RangeNotSatisfiable; - case 417: return Http_Status_ExpectationFailed; - case 418: return Http_Status_ImATeapot; - case 422: return Http_Status_UnprocessableEntity; - case 423: return Http_Status_Locked; - case 424: return Http_Status_FailedDependency; - case 426: return Http_Status_UpgradeRequired; - case 428: return Http_Status_PreconditionRequired; - case 429: return Http_Status_TooManyRequests; - case 431: return Http_Status_RequestHeaderFieldsTooLarge; - case 451: return Http_Status_UnavailableForLegalReasons; - - /*####### 5xx - Server Error #######*/ - case 500: return Http_Status_InternalServerError; - case 501: return Http_Status_NotImplemented; - case 502: return Http_Status_BadGateway; - case 503: return Http_Status_ServiceUnavailable; - case 504: return Http_Status_GatewayTimeout; - case 505: return Http_Status_HTTPVersionNotSupported; - case 506: return Http_Status_VariantAlsoNegotiates; - case 507: return Http_Status_InsufficientStorage; - case 508: return Http_Status_LoopDetected; - case 510: return Http_Status_NotExtended; - default: - log_it(L_ERROR, "Unknown status code %d. Returned default status: Internal Server Error", a_code); - return Http_Status_InternalServerError; - } -} - -static PyObject *wrapping_http_status_code_set_py(PyObject *self, PyObject *args){ - PyObject *l_obj_status_code; - if (!PyArg_ParseTuple(args, "O", &l_obj_status_code)){ - return NULL; - } - if (PyLong_Check(l_obj_status_code)){ - int code = PyLong_AsLong(l_obj_status_code); - ((PyHttpStatusCodeObject*)self)->http_status = _get_status_code_from_init(code); - } - return Py_None; -} - -static PyObject *wrapping_http_code_set_ok(PyObject *self, PyObject *args){ - (void)args; - ((PyHttpStatusCodeObject*)self)->http_status = Http_Status_OK; - return Py_None; -} - -static PyObject *wrapping_http_code_set_bad_request(PyObject *self, PyObject *args){ - (void)args; - ((PyHttpStatusCodeObject*)self)->http_status = Http_Status_BadRequest; - return Py_None; -} -static PyMethodDef PyDapHttpCodeMethods[] = { - {"set", wrapping_http_status_code_set_py, METH_VARARGS, "Set status code Http response"}, - {"OK", wrapping_http_code_set_ok, METH_NOARGS, "Set status code OK for this object"}, - {"BadRequest", wrapping_http_code_set_bad_request, METH_NOARGS, "Set status code Bad request for this object"}, - {NULL, NULL, 0, NULL} -}; - +PyObject *wrapping_http_status_code_set_py(PyObject *self, PyObject *args); +PyObject *wrapping_http_code_set_ok(PyObject *self, PyObject *args); -static PyTypeObject HTTPCode_HTTPCodeType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.HTTPCode", /* tp_name */ - sizeof(PyHttpStatusCodeObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap http code", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapHttpCodeMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +PyObject *wrapping_http_code_set_bad_request(PyObject *self, PyObject *args); -#undef LOG_TAG +extern PyTypeObject HTTPCode_HTTPCodeType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/server/http/src/wrapping_dap_http_simple.c b/modules/dap-sdk/net/server/http/src/wrapping_dap_http_simple.c index c5e058fcc799655e5ded58763afecf4df22aaaf6..3b704f5a9ad0b29d6a3a6b9bbabac857bbe3f3c2 100644 --- a/modules/dap-sdk/net/server/http/src/wrapping_dap_http_simple.c +++ b/modules/dap-sdk/net/server/http/src/wrapping_dap_http_simple.c @@ -2,6 +2,66 @@ #define LOG_TAG "wrapping_dap_http_simple" +PyMethodDef PyDapHttpSimpleMethods[] = { + //{"addProc", enc_http_add_proc_py, METH_VARARGS | METH_STATIC, ""}, + {"init", dap_http_simple_module_init_py, METH_NOARGS | METH_STATIC, "Initialization module http simple"}, + {"deinit", dap_http_simple_module_deinit_py, METH_NOARGS | METH_STATIC, "Deinitialization module http simple"}, + {"addProc", dap_http_simple_add_proc_py, METH_VARARGS | METH_STATIC, "Add HTTP URL"}, + {"setPassUnknownUserAgents", dap_http_simple_set_pass_unknown_user_agents_py, METH_VARARGS | METH_STATIC, ""}, + {"replyAdd", dap_http_simple_reply_py, METH_VARARGS, "Reply for request"}, + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef PyDapHttpSimpleGetSetDef[] = { + {"action", (getter)dap_http_simple_method_py, NULL, "Return action request", NULL}, + {"request", (getter)dap_http_simple_request_py, NULL, "Return request in view bytes", NULL}, + {"urlPath", (getter)dap_http_simple_url_path_py, NULL, "Return request in view bytes", NULL}, + {"query", (getter)dap_http_simple_query_py, NULL, "Return request in view bytes", NULL}, + {NULL} +}; + +PyTypeObject DapHTTPSimple_DapHTTPSimpleType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.HttpSimple", /* tp_name */ + sizeof(PyDapHttpSimpleObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap http simple object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapHttpSimpleMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapHttpSimpleGetSetDef, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + typedef struct wrapping_dap_http_simple_proc{ char *url; diff --git a/modules/dap-sdk/net/server/http/src/wrapping_http.c b/modules/dap-sdk/net/server/http/src/wrapping_http.c index 13e1a408ad29f0933ac5d40e77fadaae6a24533f..94d2f2bae207474490f355e9dbd0211dcfbc7efa 100644 --- a/modules/dap-sdk/net/server/http/src/wrapping_http.c +++ b/modules/dap-sdk/net/server/http/src/wrapping_http.c @@ -1,5 +1,51 @@ #include "wrapping_http.h" +PyMethodDef DapHttpMethods[] = { + {"new", dap_http_new_py, METH_VARARGS | METH_STATIC, ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapHTTP_DapHTTPType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.DapHttp", /* tp_name */ + sizeof(PyDapHttpObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap Http object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + DapHttpMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; PyObject *dap_http_new_py(PyObject *self, PyObject *args){ PyObject *obj_server; diff --git a/modules/dap-sdk/net/server/http/src/wrapping_http_status_code.c b/modules/dap-sdk/net/server/http/src/wrapping_http_status_code.c new file mode 100644 index 0000000000000000000000000000000000000000..ea9912f7d7bf9babafd234609f19dcbcb71f2ff4 --- /dev/null +++ b/modules/dap-sdk/net/server/http/src/wrapping_http_status_code.c @@ -0,0 +1,153 @@ +#include "wrapping_http_status_code.h" + +#define LOG_TAG "wrapping_http_status_code" + +PyMethodDef PyDapHttpCodeMethods[] = { + {"set", wrapping_http_status_code_set_py, METH_VARARGS, "Set status code Http response"}, + {"OK", wrapping_http_code_set_ok, METH_NOARGS, "Set status code OK for this object"}, + {"BadRequest", wrapping_http_code_set_bad_request, METH_NOARGS, "Set status code Bad request for this object"}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject HTTPCode_HTTPCodeType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.HTTPCode", /* tp_name */ + sizeof(PyHttpStatusCodeObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap http code", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapHttpCodeMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + +http_status_code_t _get_status_code_from_init(int a_code){ + switch (a_code) { +// case + /*####### 1xx - Informational #######*/ + case 100: return Http_Status_OK; + case 101: return Http_Status_SwitchingProtocols; + case 102: return Http_Status_Processing; + case 103: return Http_Status_EarlyHints; + + /*####### 2xx - Successful #######*/ + case 200: return Http_Status_OK; + case 201: return Http_Status_Created; + case 202: return Http_Status_Accepted; + case 203: return Http_Status_NonAuthoritativeInformation; + case 204: return Http_Status_NoContent; + case 205: return Http_Status_ResetContent; + case 206: return Http_Status_PartialContent; + case 207: return Http_Status_MultiStatus; + case 208: return Http_Status_AlreadyReported; + case 226: return Http_Status_IMUsed; + + /*####### 3xx - Redirection #######*/ + case 300: return Http_Status_MultipleChoices; + case 301: return Http_Status_MovedPermanently; + case 302: return Http_Status_Found; + case 303: return Http_Status_SeeOther; + case 304: return Http_Status_NotModified; + case 305: return Http_Status_UseProxy; + case 307: return Http_Status_TemporaryRedirect; + case 308: return Http_Status_PermanentRedirect; + + /*####### 4xx - Client Error #######*/ + case 400: return Http_Status_BadRequest; + case 401: return Http_Status_Unauthorized; + case 402: return Http_Status_PaymentRequired; + case 403: return Http_Status_Forbidden; + case 404: return Http_Status_NotFound; + case 405: return Http_Status_MethodNotAllowed; + case 406: return Http_Status_NotAcceptable; + case 407: return Http_Status_ProxyAuthenticationRequired; + case 408: return Http_Status_RequestTimeout; + case 409: return Http_Status_Conflict; + case 410: return Http_Status_Gone; + case 411: return Http_Status_LengthRequired; + case 412: return Http_Status_PreconditionFailed; + case 413: return Http_Status_PayloadTooLarge; + case 414: return Http_Status_URITooLong; + case 415: return Http_Status_UnsupportedMediaType; + case 416: return Http_Status_RangeNotSatisfiable; + case 417: return Http_Status_ExpectationFailed; + case 418: return Http_Status_ImATeapot; + case 422: return Http_Status_UnprocessableEntity; + case 423: return Http_Status_Locked; + case 424: return Http_Status_FailedDependency; + case 426: return Http_Status_UpgradeRequired; + case 428: return Http_Status_PreconditionRequired; + case 429: return Http_Status_TooManyRequests; + case 431: return Http_Status_RequestHeaderFieldsTooLarge; + case 451: return Http_Status_UnavailableForLegalReasons; + + /*####### 5xx - Server Error #######*/ + case 500: return Http_Status_InternalServerError; + case 501: return Http_Status_NotImplemented; + case 502: return Http_Status_BadGateway; + case 503: return Http_Status_ServiceUnavailable; + case 504: return Http_Status_GatewayTimeout; + case 505: return Http_Status_HTTPVersionNotSupported; + case 506: return Http_Status_VariantAlsoNegotiates; + case 507: return Http_Status_InsufficientStorage; + case 508: return Http_Status_LoopDetected; + case 510: return Http_Status_NotExtended; + default: + log_it(L_ERROR, "Unknown status code %d. Returned default status: Internal Server Error", a_code); + return Http_Status_InternalServerError; + } +} + +PyObject *wrapping_http_status_code_set_py(PyObject *self, PyObject *args){ + PyObject *l_obj_status_code; + if (!PyArg_ParseTuple(args, "O", &l_obj_status_code)){ + return NULL; + } + if (PyLong_Check(l_obj_status_code)){ + int code = PyLong_AsLong(l_obj_status_code); + ((PyHttpStatusCodeObject*)self)->http_status = _get_status_code_from_init(code); + } + return Py_None; +} + +PyObject *wrapping_http_code_set_ok(PyObject *self, PyObject *args){ + (void)args; + ((PyHttpStatusCodeObject*)self)->http_status = Http_Status_OK; + return Py_None; +} + +PyObject *wrapping_http_code_set_bad_request(PyObject *self, PyObject *args) { + (void) args; + ((PyHttpStatusCodeObject *) self)->http_status = Http_Status_BadRequest; + return Py_None; +} diff --git a/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_request.h b/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_request.h index c219c6634cb147f76bd5e2a17e55259c214b7725..eabd1ee5e4a11363945feb9b91bc6897008b1dea 100644 --- a/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_request.h +++ b/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_request.h @@ -27,52 +27,7 @@ struct _w_json_rpc_handler{ PyObject* dap_json_roc_request_send_py(PyObject *self, PyObject *args); PyObject* dap_json_rpc_request_reg_handler_py(PyObject *self, PyObject *args); -static PyMethodDef PyDapJSONRPCRequestMethods[] = { - {"registrationHandler", (PyCFunction)dap_json_rpc_request_reg_handler_py, METH_VARARGS | METH_STATIC , ""}, - {NULL, NULL, 0, NULL} -}; - -static PyTypeObject DapJSONRPCRequest_DapJSONRPCRequestType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.JSONRPC.Request", /* tp_name */ - sizeof(PyDAPJsonRPCRequestObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap JSON RPC request object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapJSONRPCRequestMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapJSONRPCRequest_DapJSONRPCRequestType; #ifdef __cplusplus } diff --git a/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_response.h b/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_response.h index 91d5dd19657494b460904b2ce295ea8de42fadc9..90b840ef9fe14b34fce222c1dd3851d845d6335c 100644 --- a/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_response.h +++ b/modules/dap-sdk/net/server/json_rpc/include/wrapping_json_rpc_response.h @@ -13,55 +13,4 @@ PyObject *wrapping_json_rpc_response_get_error(PyObject *self, void *closure); int wrapping_json_rpc_response_set_error(PyObject *self, PyObject *args, void *closure); PyObject *wrapping_json_rpc_response_get_id(PyObject *self, void *closure); -static PyMethodDef PyDapJSONRPCResponseMethods[] = { - {NULL, NULL, 0, NULL} -}; - -static PyGetSetDef PyDapJSONRPCResponseGetsSets[] = { - {"ID", (getter)wrapping_json_rpc_response_get_id, NULL, "ID request", NULL}, - {"Error", (getter)wrapping_json_rpc_response_get_error, (setter)wrapping_json_rpc_response_set_error, "", NULL }, - {"Result", (getter)wrapping_json_rpc_response_get_result, (setter)wrapping_json_rpc_response_set_result, "", NULL}, - {NULL, NULL, NULL, NULL, NULL} -}; - -static PyTypeObject DapJSONRPCResponse_DapJSONRPCResponseType = { - PyVarObject_HEAD_INIT(NULL, 0) - "CellFrame.JSONRPC.Response", /* tp_name */ - sizeof(PyDapJSONRPCResponseObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Dap JSON RPC response object", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PyDapJSONRPCResponseMethods, /* tp_methods */ - 0, /* tp_members */ - PyDapJSONRPCResponseGetsSets, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ -}; +extern PyTypeObject DapJSONRPCResponse_DapJSONRPCResponseType; diff --git a/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_request.c b/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_request.c index d9b353ca8f13accb1666469f3b4a88b6aa1fd72d..d4ee0ab74f88d949ce5067055785614c2f370b2f 100644 --- a/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_request.c +++ b/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_request.c @@ -2,6 +2,53 @@ #define LOG_TAG "wrapping_json_rpc_request" +PyMethodDef PyDapJSONRPCRequestMethods[] = { + {"registrationHandler", (PyCFunction)dap_json_rpc_request_reg_handler_py, METH_VARARGS | METH_STATIC , ""}, + {NULL, NULL, 0, NULL} +}; + +PyTypeObject DapJSONRPCRequest_DapJSONRPCRequestType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.JSONRPC.Request", /* tp_name */ + sizeof(PyDAPJsonRPCRequestObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap JSON RPC request object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapJSONRPCRequestMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + struct _w_json_rpc_handler *handlers = NULL; void _w_dap_json_rpc_request_handler(dap_json_rpc_params_t *a_params, dap_json_rpc_response_t *a_response, const char *a_method){ diff --git a/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_response.c b/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_response.c index 604569a3e9dc4934a048a9664b6623e6abb8b0e0..d7b683b7a6eea806dd9ae439ee1589d2c39c92db 100644 --- a/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_response.c +++ b/modules/dap-sdk/net/server/json_rpc/src/wrapping_json_rpc_response.c @@ -2,6 +2,59 @@ #define LOG_TAG "wrapping_json_rpc_response" +PyMethodDef PyDapJSONRPCResponseMethods[] = { + {NULL, NULL, 0, NULL} +}; + +PyGetSetDef PyDapJSONRPCResponseGetsSets[] = { + {"ID", (getter)wrapping_json_rpc_response_get_id, NULL, "ID request", NULL}, + {"Error", (getter)wrapping_json_rpc_response_get_error, (setter)wrapping_json_rpc_response_set_error, "", NULL }, + {"Result", (getter)wrapping_json_rpc_response_get_result, (setter)wrapping_json_rpc_response_set_result, "", NULL}, + {NULL, NULL, NULL, NULL, NULL} +}; + +PyTypeObject DapJSONRPCResponse_DapJSONRPCResponseType = { + PyVarObject_HEAD_INIT(NULL, 0) + "CellFrame.JSONRPC.Response", /* tp_name */ + sizeof(PyDapJSONRPCResponseObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Dap JSON RPC response object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PyDapJSONRPCResponseMethods, /* tp_methods */ + 0, /* tp_members */ + PyDapJSONRPCResponseGetsSets, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ +}; + int wrapping_json_rpc_response_set_result(PyObject *self, PyObject *value, void *closure){ UNUSED(closure); dap_json_rpc_response_t *l_resp = ((PyDapJSONRPCResponseObject*)self)->response; diff --git a/modules/plugins/include/dap_chain_plugins.h b/modules/plugins/include/dap_chain_plugins.h index ea8c7517a7a7b1ae01a2d8ddb2e9a702eb7d0035..d874cae443746fc6a9aa511049b7c058d6b69041 100644 --- a/modules/plugins/include/dap_chain_plugins.h +++ b/modules/plugins/include/dap_chain_plugins.h @@ -36,6 +36,8 @@ extern const char *s_plugins_root_path; int dap_chain_plugins_init(dap_config_t *a_config); void dap_chain_plugins_deinit(); void dap_chain_plugins_loading(); +void dap_chain_plugins_load_plugin_importing(const char *a_dir_path, const char *a_name); +void dap_chain_plugins_load_plugin_initialization(); void dap_chain_plugins_load_plugin(const char *a_dir_path, const char *a_name); int dap_chain_plugins_reload_plugin(const char * a_name_plugin); diff --git a/modules/plugins/src/dap_chain_plugins.c b/modules/plugins/src/dap_chain_plugins.c index c3d5a32b7bc3cb430ff9801dcfc246794393874f..766ef382beba36c010ad54b7ffda2445e48c60f8 100644 --- a/modules/plugins/src/dap_chain_plugins.c +++ b/modules/plugins/src/dap_chain_plugins.c @@ -14,6 +14,13 @@ PyObject *s_sys_path = NULL; const char *s_plugins_root_path = NULL; +typedef struct _dap_chain_plugins_module{ + PyObject *module; + char *name; + struct _dap_chain_plugins_module *next; +}_dap_chain_plugins_module_t; + +_dap_chain_plugins_module_t *_s_modules = NULL; int dap_chain_plugins_init(dap_config_t *a_config){ if(dap_config_get_item_bool_default(a_config, "plugins", "py_load", false)){ @@ -76,10 +83,10 @@ void dap_chain_plugins_loading(){ log_it(L_NOTICE, "Plugin %s add treshold", l_man->name); LL_APPEND(l_treshold, l_man); }else{ - dap_chain_plugins_load_plugin(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); + dap_chain_plugins_load_plugin_importing(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); } }else{ - dap_chain_plugins_load_plugin(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); + dap_chain_plugins_load_plugin_importing(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); } } @@ -91,7 +98,7 @@ void dap_chain_plugins_loading(){ LL_FOREACH_SAFE(l_treshold, l_man, l_tmp){ if (dap_chain_plugins_list_check_load_plugins(l_man->dependencys)){ log_it(L_NOTICE, "For plugin %s loading all dependecys", l_man->name); - dap_chain_plugins_load_plugin(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); + dap_chain_plugins_load_plugin_importing(dap_strjoin("", s_plugins_root_path, l_man->name, "/", NULL), l_man->name); LL_DELETE(l_treshold, l_man); l_c_processed++; l_step_processed = 0; @@ -99,6 +106,7 @@ void dap_chain_plugins_loading(){ } l_step_processed++; }while(l_c_processed < l_len && l_step_processed <= 2); + dap_chain_plugins_load_plugin_initialization(); //Check loading all treshold LL_COUNT(l_treshold, l_man, l_len); if (l_len > 0){ @@ -108,6 +116,57 @@ void dap_chain_plugins_loading(){ } } } + +void dap_chain_plugins_load_plugin_importing(const char *a_dir_path, const char *a_name){ + log_it(L_NOTICE, "Import module %s from %s", a_name, a_dir_path); + PyObject *l_obj_dir_path = PyUnicode_FromString(a_dir_path); + PyList_Append(s_sys_path, l_obj_dir_path); + Py_XDECREF(l_obj_dir_path); + PyObject *l_module = PyImport_ImportModule(a_name); + if (!l_module){ + PyErr_Print(); + PyErr_Clear(); + return; + } + _dap_chain_plugins_module_t *module = DAP_NEW(_dap_chain_plugins_module_t); + module->module = l_module; + module->name = dap_strdup(a_name); + Py_INCREF(l_module); + LL_APPEND(_s_modules, module); +} + +void dap_chain_plugins_load_plugin_initialization(){ + _dap_chain_plugins_module_t *l_container = NULL; + LL_FOREACH(_s_modules, l_container){ + PyObject *l_func_init = PyObject_GetAttrString(l_container->module, "init"); + PyObject *l_func_deinit = PyObject_GetAttrString(l_container->module, "deinit"); + PyObject *l_res_int = NULL; + PyErr_Clear(); + if (PyCallable_Check(l_func_init)) { + l_res_int = PyEval_CallObject(l_func_init, NULL); + if (l_res_int && PyLong_Check(l_res_int)) { + if (_PyLong_AsInt(l_res_int) == 0) { + dap_chain_plugins_list_add(l_container->module, l_container->name); + Py_INCREF(l_container->module); + } else { + PyErr_Print(); + log_it(L_ERROR, "Code error %i at initialization %s plugin", _PyLong_AsInt(l_res_int), + l_container->name); + } + } else { + PyErr_Print(); + log_it(L_ERROR, "Function initialization %s plugin don't reterned integer value", l_container->name); + } + Py_XDECREF(l_res_int); + } else { + log_it(L_ERROR, "For plugins %s don't found function init", l_container->name); + } + if (l_func_deinit == NULL || !PyCallable_Check(l_func_deinit)){ + log_it(L_WARNING, "For plugins %s don't found function deinit", l_container->name); + } + } +} + void dap_chain_plugins_load_plugin(const char *a_dir_path, const char *a_name){ log_it(L_NOTICE, "Loading %s plugin directory %s", a_name, a_dir_path); PyErr_Clear();