bitmart 0.0.116__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bitmart/__init__.py +7 -0
- bitmart/ccxt/__init__.py +102 -0
- bitmart/ccxt/abstract/bitmart.py +117 -0
- bitmart/ccxt/async_support/__init__.py +81 -0
- bitmart/ccxt/async_support/base/__init__.py +1 -0
- bitmart/ccxt/async_support/base/exchange.py +2315 -0
- bitmart/ccxt/async_support/base/throttler.py +88 -0
- bitmart/ccxt/async_support/base/ws/__init__.py +38 -0
- bitmart/ccxt/async_support/base/ws/cache.py +219 -0
- bitmart/ccxt/async_support/base/ws/client.py +350 -0
- bitmart/ccxt/async_support/base/ws/functions.py +59 -0
- bitmart/ccxt/async_support/base/ws/future.py +46 -0
- bitmart/ccxt/async_support/base/ws/order_book.py +78 -0
- bitmart/ccxt/async_support/base/ws/order_book_side.py +174 -0
- bitmart/ccxt/async_support/bitmart.py +5361 -0
- bitmart/ccxt/base/__init__.py +27 -0
- bitmart/ccxt/base/decimal_to_precision.py +178 -0
- bitmart/ccxt/base/errors.py +273 -0
- bitmart/ccxt/base/exchange.py +7642 -0
- bitmart/ccxt/base/precise.py +297 -0
- bitmart/ccxt/base/types.py +619 -0
- bitmart/ccxt/bitmart.py +5361 -0
- bitmart/ccxt/pro/__init__.py +66 -0
- bitmart/ccxt/pro/bitmart.py +1917 -0
- bitmart/ccxt/static_dependencies/README.md +1 -0
- bitmart/ccxt/static_dependencies/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/__init__.py +6 -0
- bitmart/ccxt/static_dependencies/bip/addr/P2PKH_addr.py +205 -0
- bitmart/ccxt/static_dependencies/bip/addr/__init__.py +5 -0
- bitmart/ccxt/static_dependencies/bip/addr/addr_dec_utils.py +125 -0
- bitmart/ccxt/static_dependencies/bip/addr/addr_key_validator.py +162 -0
- bitmart/ccxt/static_dependencies/bip/addr/iaddr_decoder.py +48 -0
- bitmart/ccxt/static_dependencies/bip/addr/iaddr_encoder.py +50 -0
- bitmart/ccxt/static_dependencies/bip/base58/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/base58/base58.py +207 -0
- bitmart/ccxt/static_dependencies/bip/base58/base58_ex.py +25 -0
- bitmart/ccxt/static_dependencies/bip/base58/base58_xmr.py +155 -0
- bitmart/ccxt/static_dependencies/bip/bech32/__init__.py +4 -0
- bitmart/ccxt/static_dependencies/bip/bech32/bch_bech32.py +220 -0
- bitmart/ccxt/static_dependencies/bip/bech32/bech32.py +235 -0
- bitmart/ccxt/static_dependencies/bip/bech32/bech32_base.py +246 -0
- bitmart/ccxt/static_dependencies/bip/bech32/bech32_ex.py +25 -0
- bitmart/ccxt/static_dependencies/bip/bech32/segwit_bech32.py +173 -0
- bitmart/ccxt/static_dependencies/bip/bip32/__init__.py +14 -0
- bitmart/ccxt/static_dependencies/bip/bip32/base/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/bip32/base/bip32_base.py +581 -0
- bitmart/ccxt/static_dependencies/bip/bip32/base/ibip32_key_derivator.py +83 -0
- bitmart/ccxt/static_dependencies/bip/bip32/base/ibip32_mst_key_generator.py +47 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_const.py +35 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_ex.py +29 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_key_data.py +500 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_key_net_ver.py +83 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_key_ser.py +294 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_keys.py +457 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_path.py +247 -0
- bitmart/ccxt/static_dependencies/bip/bip32/bip32_utils.py +72 -0
- bitmart/ccxt/static_dependencies/bip/bip32/kholaw/__init__.py +4 -0
- bitmart/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519.py +82 -0
- bitmart/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_ed25519_key_derivator.py +118 -0
- bitmart/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_key_derivator_base.py +204 -0
- bitmart/ccxt/static_dependencies/bip/bip32/kholaw/bip32_kholaw_mst_key_generator.py +119 -0
- bitmart/ccxt/static_dependencies/bip/bip32/slip10/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_key_derivator.py +200 -0
- bitmart/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_mst_key_generator.py +168 -0
- bitmart/ccxt/static_dependencies/bip/bip32/slip10/bip32_slip10_secp256k1.py +82 -0
- bitmart/ccxt/static_dependencies/bip/bip44/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/bip44/bip44.py +265 -0
- bitmart/ccxt/static_dependencies/bip/bip44_base/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/bip44_base/bip44_base.py +624 -0
- bitmart/ccxt/static_dependencies/bip/bip44_base/bip44_base_ex.py +25 -0
- bitmart/ccxt/static_dependencies/bip/bip44_base/bip44_keys.py +225 -0
- bitmart/ccxt/static_dependencies/bip/coin_conf/__init__.py +2 -0
- bitmart/ccxt/static_dependencies/bip/coin_conf/coin_conf.py +68 -0
- bitmart/ccxt/static_dependencies/bip/coin_conf/coins_conf.py +890 -0
- bitmart/ccxt/static_dependencies/bip/conf/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip44/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip44/bip44_coins.py +126 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip44/bip44_conf.py +1360 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip44/bip44_conf_getter.py +153 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip49/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip49/bip49_coins.py +53 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip49/bip49_conf.py +366 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip49/bip49_conf_getter.py +80 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip84/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip84/bip84_coins.py +39 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip84/bip84_conf.py +113 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip84/bip84_conf_getter.py +66 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip86/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip86/bip86_coins.py +37 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip86/bip86_conf.py +83 -0
- bitmart/ccxt/static_dependencies/bip/conf/bip86/bip86_conf_getter.py +64 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/__init__.py +8 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/atom_addr.py +104 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/bip_bitcoin_cash_conf.py +106 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/bip_coin_conf.py +217 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/bip_coins.py +28 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/bip_conf_const.py +30 -0
- bitmart/ccxt/static_dependencies/bip/conf/common/bip_litecoin_conf.py +121 -0
- bitmart/ccxt/static_dependencies/bip/ecc/__init__.py +42 -0
- bitmart/ccxt/static_dependencies/bip/ecc/common/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/ecc/common/dummy_point.py +219 -0
- bitmart/ccxt/static_dependencies/bip/ecc/common/ikeys.py +263 -0
- bitmart/ccxt/static_dependencies/bip/ecc/common/ipoint.py +190 -0
- bitmart/ccxt/static_dependencies/bip/ecc/conf.py +28 -0
- bitmart/ccxt/static_dependencies/bip/ecc/curve/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve.py +121 -0
- bitmart/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_getter.py +74 -0
- bitmart/ccxt/static_dependencies/bip/ecc/curve/elliptic_curve_types.py +37 -0
- bitmart/ccxt/static_dependencies/bip/ecc/ecdsa/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/ecc/ecdsa/ecdsa_keys.py +36 -0
- bitmart/ccxt/static_dependencies/bip/ecc/secp256k1/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1.py +36 -0
- bitmart/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_const.py +59 -0
- bitmart/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_keys_ecdsa.py +248 -0
- bitmart/ccxt/static_dependencies/bip/ecc/secp256k1/secp256k1_point_ecdsa.py +234 -0
- bitmart/ccxt/static_dependencies/bip/slip/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip173/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip173/slip173.py +60 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip32/__init__.py +4 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip32/slip32.py +322 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip32/slip32_key_net_ver.py +62 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip44/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/slip/slip44/slip44.py +81 -0
- bitmart/ccxt/static_dependencies/bip/utils/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/bip/utils/conf/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/utils/conf/coin_names.py +59 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/__init__.py +10 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/aes_ecb.py +152 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/blake2.py +191 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/chacha20_poly1305.py +101 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/hash160.py +57 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/hmac.py +118 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/pbkdf2.py +66 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/ripemd.py +58 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/scrypt.py +66 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/sha2.py +182 -0
- bitmart/ccxt/static_dependencies/bip/utils/crypto/sha3.py +99 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/__init__.py +7 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/algo.py +108 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/base32.py +151 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/bit.py +115 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/bytes.py +200 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/data_bytes.py +181 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/integer.py +97 -0
- bitmart/ccxt/static_dependencies/bip/utils/misc/string.py +54 -0
- bitmart/ccxt/static_dependencies/bip/utils/typing/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/utils/typing/literal.py +27 -0
- bitmart/ccxt/static_dependencies/bip/wif/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/bip/wif/wif.py +144 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/amino/amino_pb2.py +31 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/base/v1beta1/coin_pb2.py +47 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/keys_pb2.py +33 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/multisig/v1beta1/multisig_pb2.py +33 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/crypto/secp256k1/keys_pb2.py +34 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/msg/v1/msg_pb2.py +27 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/signing/v1beta1/signing_pb2.py +38 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos/tx/v1beta1/tx_pb2.py +75 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/cosmos_proto/cosmos_pb2.py +36 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/accountplus_pb2.py +31 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/genesis_pb2.py +40 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/models_pb2.py +26 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/params_pb2.py +29 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/query_pb2.py +57 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/accountplus/tx_pb2.py +51 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/block_rate_limit_config_pb2.py +37 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/clob_pair_pb2.py +41 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/equity_tier_limit_config_pb2.py +35 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/finalize_block_pb2.py +27 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_config_pb2.py +39 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/liquidations_pb2.py +38 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/matches_pb2.py +55 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/mev_pb2.py +49 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/operation_pb2.py +32 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_pb2.py +86 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/order_removals_pb2.py +32 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/process_proposer_matches_events_pb2.py +42 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/query_pb2.py +124 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/streaming_pb2.py +29 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/clob/tx_pb2.py +117 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/genesis_pb2.py +26 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/query_pb2.py +26 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/transfer_pb2.py +61 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/sending/tx_pb2.py +37 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/asset_position_pb2.py +29 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/genesis_pb2.py +30 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/perpetual_position_pb2.py +33 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/query_pb2.py +63 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/streaming_pb2.py +31 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/dydxprotocol/subaccounts/subaccount_pb2.py +33 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/gogoproto/gogo_pb2.py +102 -0
- bitmart/ccxt/static_dependencies/dydx_v4_client/registry.py +38 -0
- bitmart/ccxt/static_dependencies/ecdsa/__init__.py +14 -0
- bitmart/ccxt/static_dependencies/ecdsa/_version.py +520 -0
- bitmart/ccxt/static_dependencies/ecdsa/curves.py +56 -0
- bitmart/ccxt/static_dependencies/ecdsa/der.py +221 -0
- bitmart/ccxt/static_dependencies/ecdsa/ecdsa.py +310 -0
- bitmart/ccxt/static_dependencies/ecdsa/ellipticcurve.py +1039 -0
- bitmart/ccxt/static_dependencies/ecdsa/keys.py +343 -0
- bitmart/ccxt/static_dependencies/ecdsa/numbertheory.py +531 -0
- bitmart/ccxt/static_dependencies/ecdsa/rfc6979.py +100 -0
- bitmart/ccxt/static_dependencies/ecdsa/util.py +266 -0
- bitmart/ccxt/static_dependencies/ethereum/__init__.py +7 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/__init__.py +16 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/abi.py +19 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/base.py +152 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/codec.py +217 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/constants.py +3 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/decoding.py +565 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/encoding.py +720 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/exceptions.py +139 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/grammar.py +443 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/packed.py +13 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/py.typed +0 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/registry.py +643 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/tools/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/tools/_strategies.py +230 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/utils/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/utils/numeric.py +83 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/utils/padding.py +27 -0
- bitmart/ccxt/static_dependencies/ethereum/abi/utils/string.py +19 -0
- bitmart/ccxt/static_dependencies/ethereum/account/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/ethereum/account/encode_typed_data/__init__.py +4 -0
- bitmart/ccxt/static_dependencies/ethereum/account/encode_typed_data/encoding_and_hashing.py +239 -0
- bitmart/ccxt/static_dependencies/ethereum/account/encode_typed_data/helpers.py +40 -0
- bitmart/ccxt/static_dependencies/ethereum/account/messages.py +263 -0
- bitmart/ccxt/static_dependencies/ethereum/account/py.typed +0 -0
- bitmart/ccxt/static_dependencies/ethereum/hexbytes/__init__.py +5 -0
- bitmart/ccxt/static_dependencies/ethereum/hexbytes/_utils.py +54 -0
- bitmart/ccxt/static_dependencies/ethereum/hexbytes/main.py +65 -0
- bitmart/ccxt/static_dependencies/ethereum/hexbytes/py.typed +0 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/__init__.py +63 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/abi.py +6 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/bls.py +7 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/discovery.py +5 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/encoding.py +7 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/enums.py +17 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/ethpm.py +9 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/evm.py +20 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/networks.py +1122 -0
- bitmart/ccxt/static_dependencies/ethereum/typing/py.typed +0 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/__init__.py +115 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/abi.py +72 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/address.py +171 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/applicators.py +151 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/conversions.py +190 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/currency.py +107 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/curried/__init__.py +269 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/debug.py +20 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/decorators.py +132 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/encoding.py +6 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/exceptions.py +4 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/functional.py +75 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/hexadecimal.py +74 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/humanize.py +188 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/logging.py +159 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/module_loading.py +31 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/numeric.py +43 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/py.typed +0 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/toolz.py +76 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/types.py +54 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/typing/__init__.py +18 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/typing/misc.py +14 -0
- bitmart/ccxt/static_dependencies/ethereum/utils/units.py +31 -0
- bitmart/ccxt/static_dependencies/keccak/__init__.py +3 -0
- bitmart/ccxt/static_dependencies/keccak/keccak.py +197 -0
- bitmart/ccxt/static_dependencies/lark/__init__.py +38 -0
- bitmart/ccxt/static_dependencies/lark/__pyinstaller/__init__.py +6 -0
- bitmart/ccxt/static_dependencies/lark/__pyinstaller/hook-lark.py +14 -0
- bitmart/ccxt/static_dependencies/lark/ast_utils.py +59 -0
- bitmart/ccxt/static_dependencies/lark/common.py +86 -0
- bitmart/ccxt/static_dependencies/lark/exceptions.py +292 -0
- bitmart/ccxt/static_dependencies/lark/grammar.py +130 -0
- bitmart/ccxt/static_dependencies/lark/grammars/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/lark/grammars/common.lark +59 -0
- bitmart/ccxt/static_dependencies/lark/grammars/lark.lark +62 -0
- bitmart/ccxt/static_dependencies/lark/grammars/python.lark +302 -0
- bitmart/ccxt/static_dependencies/lark/grammars/unicode.lark +7 -0
- bitmart/ccxt/static_dependencies/lark/indenter.py +143 -0
- bitmart/ccxt/static_dependencies/lark/lark.py +658 -0
- bitmart/ccxt/static_dependencies/lark/lexer.py +678 -0
- bitmart/ccxt/static_dependencies/lark/load_grammar.py +1428 -0
- bitmart/ccxt/static_dependencies/lark/parse_tree_builder.py +391 -0
- bitmart/ccxt/static_dependencies/lark/parser_frontends.py +257 -0
- bitmart/ccxt/static_dependencies/lark/parsers/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/lark/parsers/cyk.py +340 -0
- bitmart/ccxt/static_dependencies/lark/parsers/earley.py +314 -0
- bitmart/ccxt/static_dependencies/lark/parsers/earley_common.py +42 -0
- bitmart/ccxt/static_dependencies/lark/parsers/earley_forest.py +801 -0
- bitmart/ccxt/static_dependencies/lark/parsers/grammar_analysis.py +203 -0
- bitmart/ccxt/static_dependencies/lark/parsers/lalr_analysis.py +332 -0
- bitmart/ccxt/static_dependencies/lark/parsers/lalr_interactive_parser.py +158 -0
- bitmart/ccxt/static_dependencies/lark/parsers/lalr_parser.py +122 -0
- bitmart/ccxt/static_dependencies/lark/parsers/lalr_parser_state.py +110 -0
- bitmart/ccxt/static_dependencies/lark/parsers/xearley.py +165 -0
- bitmart/ccxt/static_dependencies/lark/py.typed +0 -0
- bitmart/ccxt/static_dependencies/lark/reconstruct.py +107 -0
- bitmart/ccxt/static_dependencies/lark/tools/__init__.py +70 -0
- bitmart/ccxt/static_dependencies/lark/tools/nearley.py +202 -0
- bitmart/ccxt/static_dependencies/lark/tools/serialize.py +32 -0
- bitmart/ccxt/static_dependencies/lark/tools/standalone.py +196 -0
- bitmart/ccxt/static_dependencies/lark/tree.py +267 -0
- bitmart/ccxt/static_dependencies/lark/tree_matcher.py +186 -0
- bitmart/ccxt/static_dependencies/lark/tree_templates.py +180 -0
- bitmart/ccxt/static_dependencies/lark/utils.py +343 -0
- bitmart/ccxt/static_dependencies/lark/visitors.py +596 -0
- bitmart/ccxt/static_dependencies/marshmallow/__init__.py +81 -0
- bitmart/ccxt/static_dependencies/marshmallow/base.py +65 -0
- bitmart/ccxt/static_dependencies/marshmallow/class_registry.py +94 -0
- bitmart/ccxt/static_dependencies/marshmallow/decorators.py +231 -0
- bitmart/ccxt/static_dependencies/marshmallow/error_store.py +60 -0
- bitmart/ccxt/static_dependencies/marshmallow/exceptions.py +71 -0
- bitmart/ccxt/static_dependencies/marshmallow/fields.py +2114 -0
- bitmart/ccxt/static_dependencies/marshmallow/orderedset.py +89 -0
- bitmart/ccxt/static_dependencies/marshmallow/py.typed +0 -0
- bitmart/ccxt/static_dependencies/marshmallow/schema.py +1228 -0
- bitmart/ccxt/static_dependencies/marshmallow/types.py +12 -0
- bitmart/ccxt/static_dependencies/marshmallow/utils.py +378 -0
- bitmart/ccxt/static_dependencies/marshmallow/validate.py +678 -0
- bitmart/ccxt/static_dependencies/marshmallow/warnings.py +2 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/__init__.py +1047 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/collection_field.py +51 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/lazy_class_attribute.py +45 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/mypy.py +71 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/py.typed +0 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/typing.py +14 -0
- bitmart/ccxt/static_dependencies/marshmallow_dataclass/union_field.py +82 -0
- bitmart/ccxt/static_dependencies/marshmallow_oneofschema/__init__.py +1 -0
- bitmart/ccxt/static_dependencies/marshmallow_oneofschema/one_of_schema.py +193 -0
- bitmart/ccxt/static_dependencies/marshmallow_oneofschema/py.typed +0 -0
- bitmart/ccxt/static_dependencies/mnemonic/__init__.py +4 -0
- bitmart/ccxt/static_dependencies/mnemonic/mnemonic.py +282 -0
- bitmart/ccxt/static_dependencies/mnemonic/py.typed +1 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/chinese_simplified.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/chinese_traditional.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/czech.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/english.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/french.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/italian.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/japanese.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/korean.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/portuguese.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/russian.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/spanish.txt +2048 -0
- bitmart/ccxt/static_dependencies/mnemonic/wordlist/turkish.txt +2048 -0
- bitmart/ccxt/static_dependencies/msgpack/__init__.py +55 -0
- bitmart/ccxt/static_dependencies/msgpack/_cmsgpack.pyx +11 -0
- bitmart/ccxt/static_dependencies/msgpack/_packer.pyx +374 -0
- bitmart/ccxt/static_dependencies/msgpack/_unpacker.pyx +547 -0
- bitmart/ccxt/static_dependencies/msgpack/buff_converter.h +8 -0
- bitmart/ccxt/static_dependencies/msgpack/exceptions.py +48 -0
- bitmart/ccxt/static_dependencies/msgpack/ext.py +168 -0
- bitmart/ccxt/static_dependencies/msgpack/fallback.py +951 -0
- bitmart/ccxt/static_dependencies/msgpack/pack.h +89 -0
- bitmart/ccxt/static_dependencies/msgpack/pack_template.h +820 -0
- bitmart/ccxt/static_dependencies/msgpack/sysdep.h +194 -0
- bitmart/ccxt/static_dependencies/msgpack/unpack.h +391 -0
- bitmart/ccxt/static_dependencies/msgpack/unpack_define.h +95 -0
- bitmart/ccxt/static_dependencies/msgpack/unpack_template.h +464 -0
- bitmart/ccxt/static_dependencies/parsimonious/__init__.py +10 -0
- bitmart/ccxt/static_dependencies/parsimonious/exceptions.py +105 -0
- bitmart/ccxt/static_dependencies/parsimonious/expressions.py +479 -0
- bitmart/ccxt/static_dependencies/parsimonious/grammar.py +487 -0
- bitmart/ccxt/static_dependencies/parsimonious/nodes.py +325 -0
- bitmart/ccxt/static_dependencies/parsimonious/utils.py +40 -0
- bitmart/ccxt/static_dependencies/starknet/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v0/__init__.py +2 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v0/model.py +44 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v0/parser.py +216 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v0/schemas.py +72 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v0/shape.py +63 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/__init__.py +2 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/core_structures.json +14 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/model.py +39 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/parser.py +220 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/parser_transformer.py +179 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/schemas.py +66 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v1/shape.py +47 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/__init__.py +2 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/model.py +89 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/parser.py +293 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/parser_transformer.py +192 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/schemas.py +132 -0
- bitmart/ccxt/static_dependencies/starknet/abi/v2/shape.py +107 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/data_types.py +123 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/deprecated_parse/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/deprecated_parse/cairo_types.py +77 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser.py +46 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/deprecated_parse/parser_transformer.py +138 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/felt.py +64 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/type_parser.py +121 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/v1/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/v1/type_parser.py +59 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/v2/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/cairo/v2/type_parser.py +77 -0
- bitmart/ccxt/static_dependencies/starknet/ccxt_utils.py +7 -0
- bitmart/ccxt/static_dependencies/starknet/common.py +15 -0
- bitmart/ccxt/static_dependencies/starknet/constants.py +39 -0
- bitmart/ccxt/static_dependencies/starknet/hash/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/hash/address.py +79 -0
- bitmart/ccxt/static_dependencies/starknet/hash/compiled_class_hash_objects.py +111 -0
- bitmart/ccxt/static_dependencies/starknet/hash/selector.py +16 -0
- bitmart/ccxt/static_dependencies/starknet/hash/storage.py +12 -0
- bitmart/ccxt/static_dependencies/starknet/hash/utils.py +78 -0
- bitmart/ccxt/static_dependencies/starknet/models/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/models/typed_data.py +45 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/__init__.py +24 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/_calldata_reader.py +40 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/_context.py +142 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/__init__.py +10 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/_common.py +82 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/array_serializer.py +43 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/bool_serializer.py +37 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/byte_array_serializer.py +66 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/cairo_data_serializer.py +71 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/enum_serializer.py +71 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/felt_serializer.py +50 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/named_tuple_serializer.py +58 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/option_serializer.py +43 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/output_serializer.py +40 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/payload_serializer.py +72 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/struct_serializer.py +36 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/tuple_serializer.py +36 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/uint256_serializer.py +76 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/uint_serializer.py +100 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/data_serializers/unit_serializer.py +32 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/errors.py +10 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/factory.py +229 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/function_serialization_adapter.py +110 -0
- bitmart/ccxt/static_dependencies/starknet/serialization/tuple_dataclass.py +59 -0
- bitmart/ccxt/static_dependencies/starknet/utils/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starknet/utils/constructor_args_translator.py +86 -0
- bitmart/ccxt/static_dependencies/starknet/utils/iterable.py +13 -0
- bitmart/ccxt/static_dependencies/starknet/utils/schema.py +13 -0
- bitmart/ccxt/static_dependencies/starknet/utils/typed_data.py +182 -0
- bitmart/ccxt/static_dependencies/starkware/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starkware/crypto/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/starkware/crypto/fast_pedersen_hash.py +50 -0
- bitmart/ccxt/static_dependencies/starkware/crypto/math_utils.py +78 -0
- bitmart/ccxt/static_dependencies/starkware/crypto/signature.py +2344 -0
- bitmart/ccxt/static_dependencies/starkware/crypto/utils.py +63 -0
- bitmart/ccxt/static_dependencies/sympy/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/sympy/core/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/sympy/core/intfunc.py +35 -0
- bitmart/ccxt/static_dependencies/sympy/external/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/sympy/external/gmpy.py +345 -0
- bitmart/ccxt/static_dependencies/sympy/external/importtools.py +187 -0
- bitmart/ccxt/static_dependencies/sympy/external/ntheory.py +637 -0
- bitmart/ccxt/static_dependencies/sympy/external/pythonmpq.py +341 -0
- bitmart/ccxt/static_dependencies/toolz/__init__.py +26 -0
- bitmart/ccxt/static_dependencies/toolz/_signatures.py +784 -0
- bitmart/ccxt/static_dependencies/toolz/_version.py +520 -0
- bitmart/ccxt/static_dependencies/toolz/compatibility.py +30 -0
- bitmart/ccxt/static_dependencies/toolz/curried/__init__.py +101 -0
- bitmart/ccxt/static_dependencies/toolz/curried/exceptions.py +22 -0
- bitmart/ccxt/static_dependencies/toolz/curried/operator.py +22 -0
- bitmart/ccxt/static_dependencies/toolz/dicttoolz.py +339 -0
- bitmart/ccxt/static_dependencies/toolz/functoolz.py +1049 -0
- bitmart/ccxt/static_dependencies/toolz/itertoolz.py +1057 -0
- bitmart/ccxt/static_dependencies/toolz/recipes.py +46 -0
- bitmart/ccxt/static_dependencies/toolz/utils.py +9 -0
- bitmart/ccxt/static_dependencies/typing_inspect/__init__.py +0 -0
- bitmart/ccxt/static_dependencies/typing_inspect/typing_inspect.py +851 -0
- bitmart-0.0.116.dist-info/METADATA +342 -0
- bitmart-0.0.116.dist-info/RECORD +466 -0
- bitmart-0.0.116.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MessagePack system dependencies
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008-2010 FURUHASHI Sadayuki
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
#ifndef MSGPACK_SYSDEP_H__
|
|
19
|
+
#define MSGPACK_SYSDEP_H__
|
|
20
|
+
|
|
21
|
+
#include <stdlib.h>
|
|
22
|
+
#include <stddef.h>
|
|
23
|
+
#if defined(_MSC_VER) && _MSC_VER < 1600
|
|
24
|
+
typedef __int8 int8_t;
|
|
25
|
+
typedef unsigned __int8 uint8_t;
|
|
26
|
+
typedef __int16 int16_t;
|
|
27
|
+
typedef unsigned __int16 uint16_t;
|
|
28
|
+
typedef __int32 int32_t;
|
|
29
|
+
typedef unsigned __int32 uint32_t;
|
|
30
|
+
typedef __int64 int64_t;
|
|
31
|
+
typedef unsigned __int64 uint64_t;
|
|
32
|
+
#elif defined(_MSC_VER) // && _MSC_VER >= 1600
|
|
33
|
+
#include <stdint.h>
|
|
34
|
+
#else
|
|
35
|
+
#include <stdint.h>
|
|
36
|
+
#include <stdbool.h>
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#ifdef _WIN32
|
|
40
|
+
#define _msgpack_atomic_counter_header <windows.h>
|
|
41
|
+
typedef long _msgpack_atomic_counter_t;
|
|
42
|
+
#define _msgpack_sync_decr_and_fetch(ptr) InterlockedDecrement(ptr)
|
|
43
|
+
#define _msgpack_sync_incr_and_fetch(ptr) InterlockedIncrement(ptr)
|
|
44
|
+
#elif defined(__GNUC__) && ((__GNUC__*10 + __GNUC_MINOR__) < 41)
|
|
45
|
+
#define _msgpack_atomic_counter_header "gcc_atomic.h"
|
|
46
|
+
#else
|
|
47
|
+
typedef unsigned int _msgpack_atomic_counter_t;
|
|
48
|
+
#define _msgpack_sync_decr_and_fetch(ptr) __sync_sub_and_fetch(ptr, 1)
|
|
49
|
+
#define _msgpack_sync_incr_and_fetch(ptr) __sync_add_and_fetch(ptr, 1)
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#ifdef _WIN32
|
|
53
|
+
|
|
54
|
+
#ifdef __cplusplus
|
|
55
|
+
/* numeric_limits<T>::min,max */
|
|
56
|
+
#ifdef max
|
|
57
|
+
#undef max
|
|
58
|
+
#endif
|
|
59
|
+
#ifdef min
|
|
60
|
+
#undef min
|
|
61
|
+
#endif
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
#else /* _WIN32 */
|
|
65
|
+
#include <arpa/inet.h> /* ntohs, ntohl */
|
|
66
|
+
#endif
|
|
67
|
+
|
|
68
|
+
#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
|
|
69
|
+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
70
|
+
#define __LITTLE_ENDIAN__
|
|
71
|
+
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
72
|
+
#define __BIG_ENDIAN__
|
|
73
|
+
#elif _WIN32
|
|
74
|
+
#define __LITTLE_ENDIAN__
|
|
75
|
+
#endif
|
|
76
|
+
#endif
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
#ifdef __LITTLE_ENDIAN__
|
|
80
|
+
|
|
81
|
+
#ifdef _WIN32
|
|
82
|
+
# if defined(ntohs)
|
|
83
|
+
# define _msgpack_be16(x) ntohs(x)
|
|
84
|
+
# elif defined(_byteswap_ushort) || (defined(_MSC_VER) && _MSC_VER >= 1400)
|
|
85
|
+
# define _msgpack_be16(x) ((uint16_t)_byteswap_ushort((unsigned short)x))
|
|
86
|
+
# else
|
|
87
|
+
# define _msgpack_be16(x) ( \
|
|
88
|
+
((((uint16_t)x) << 8) ) | \
|
|
89
|
+
((((uint16_t)x) >> 8) ) )
|
|
90
|
+
# endif
|
|
91
|
+
#else
|
|
92
|
+
# define _msgpack_be16(x) ntohs(x)
|
|
93
|
+
#endif
|
|
94
|
+
|
|
95
|
+
#ifdef _WIN32
|
|
96
|
+
# if defined(ntohl)
|
|
97
|
+
# define _msgpack_be32(x) ntohl(x)
|
|
98
|
+
# elif defined(_byteswap_ulong) || defined(_MSC_VER)
|
|
99
|
+
# define _msgpack_be32(x) ((uint32_t)_byteswap_ulong((unsigned long)x))
|
|
100
|
+
# else
|
|
101
|
+
# define _msgpack_be32(x) \
|
|
102
|
+
( ((((uint32_t)x) << 24) ) | \
|
|
103
|
+
((((uint32_t)x) << 8) & 0x00ff0000U ) | \
|
|
104
|
+
((((uint32_t)x) >> 8) & 0x0000ff00U ) | \
|
|
105
|
+
((((uint32_t)x) >> 24) ) )
|
|
106
|
+
# endif
|
|
107
|
+
#else
|
|
108
|
+
# define _msgpack_be32(x) ntohl(x)
|
|
109
|
+
#endif
|
|
110
|
+
|
|
111
|
+
#if defined(_byteswap_uint64) || defined(_MSC_VER)
|
|
112
|
+
# define _msgpack_be64(x) (_byteswap_uint64(x))
|
|
113
|
+
#elif defined(bswap_64)
|
|
114
|
+
# define _msgpack_be64(x) bswap_64(x)
|
|
115
|
+
#elif defined(__DARWIN_OSSwapInt64)
|
|
116
|
+
# define _msgpack_be64(x) __DARWIN_OSSwapInt64(x)
|
|
117
|
+
#else
|
|
118
|
+
#define _msgpack_be64(x) \
|
|
119
|
+
( ((((uint64_t)x) << 56) ) | \
|
|
120
|
+
((((uint64_t)x) << 40) & 0x00ff000000000000ULL ) | \
|
|
121
|
+
((((uint64_t)x) << 24) & 0x0000ff0000000000ULL ) | \
|
|
122
|
+
((((uint64_t)x) << 8) & 0x000000ff00000000ULL ) | \
|
|
123
|
+
((((uint64_t)x) >> 8) & 0x00000000ff000000ULL ) | \
|
|
124
|
+
((((uint64_t)x) >> 24) & 0x0000000000ff0000ULL ) | \
|
|
125
|
+
((((uint64_t)x) >> 40) & 0x000000000000ff00ULL ) | \
|
|
126
|
+
((((uint64_t)x) >> 56) ) )
|
|
127
|
+
#endif
|
|
128
|
+
|
|
129
|
+
#define _msgpack_load16(cast, from) ((cast)( \
|
|
130
|
+
(((uint16_t)((uint8_t*)(from))[0]) << 8) | \
|
|
131
|
+
(((uint16_t)((uint8_t*)(from))[1]) ) ))
|
|
132
|
+
|
|
133
|
+
#define _msgpack_load32(cast, from) ((cast)( \
|
|
134
|
+
(((uint32_t)((uint8_t*)(from))[0]) << 24) | \
|
|
135
|
+
(((uint32_t)((uint8_t*)(from))[1]) << 16) | \
|
|
136
|
+
(((uint32_t)((uint8_t*)(from))[2]) << 8) | \
|
|
137
|
+
(((uint32_t)((uint8_t*)(from))[3]) ) ))
|
|
138
|
+
|
|
139
|
+
#define _msgpack_load64(cast, from) ((cast)( \
|
|
140
|
+
(((uint64_t)((uint8_t*)(from))[0]) << 56) | \
|
|
141
|
+
(((uint64_t)((uint8_t*)(from))[1]) << 48) | \
|
|
142
|
+
(((uint64_t)((uint8_t*)(from))[2]) << 40) | \
|
|
143
|
+
(((uint64_t)((uint8_t*)(from))[3]) << 32) | \
|
|
144
|
+
(((uint64_t)((uint8_t*)(from))[4]) << 24) | \
|
|
145
|
+
(((uint64_t)((uint8_t*)(from))[5]) << 16) | \
|
|
146
|
+
(((uint64_t)((uint8_t*)(from))[6]) << 8) | \
|
|
147
|
+
(((uint64_t)((uint8_t*)(from))[7]) ) ))
|
|
148
|
+
|
|
149
|
+
#else
|
|
150
|
+
|
|
151
|
+
#define _msgpack_be16(x) (x)
|
|
152
|
+
#define _msgpack_be32(x) (x)
|
|
153
|
+
#define _msgpack_be64(x) (x)
|
|
154
|
+
|
|
155
|
+
#define _msgpack_load16(cast, from) ((cast)( \
|
|
156
|
+
(((uint16_t)((uint8_t*)from)[0]) << 8) | \
|
|
157
|
+
(((uint16_t)((uint8_t*)from)[1]) ) ))
|
|
158
|
+
|
|
159
|
+
#define _msgpack_load32(cast, from) ((cast)( \
|
|
160
|
+
(((uint32_t)((uint8_t*)from)[0]) << 24) | \
|
|
161
|
+
(((uint32_t)((uint8_t*)from)[1]) << 16) | \
|
|
162
|
+
(((uint32_t)((uint8_t*)from)[2]) << 8) | \
|
|
163
|
+
(((uint32_t)((uint8_t*)from)[3]) ) ))
|
|
164
|
+
|
|
165
|
+
#define _msgpack_load64(cast, from) ((cast)( \
|
|
166
|
+
(((uint64_t)((uint8_t*)from)[0]) << 56) | \
|
|
167
|
+
(((uint64_t)((uint8_t*)from)[1]) << 48) | \
|
|
168
|
+
(((uint64_t)((uint8_t*)from)[2]) << 40) | \
|
|
169
|
+
(((uint64_t)((uint8_t*)from)[3]) << 32) | \
|
|
170
|
+
(((uint64_t)((uint8_t*)from)[4]) << 24) | \
|
|
171
|
+
(((uint64_t)((uint8_t*)from)[5]) << 16) | \
|
|
172
|
+
(((uint64_t)((uint8_t*)from)[6]) << 8) | \
|
|
173
|
+
(((uint64_t)((uint8_t*)from)[7]) ) ))
|
|
174
|
+
#endif
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
#define _msgpack_store16(to, num) \
|
|
178
|
+
do { uint16_t val = _msgpack_be16(num); memcpy(to, &val, 2); } while(0)
|
|
179
|
+
#define _msgpack_store32(to, num) \
|
|
180
|
+
do { uint32_t val = _msgpack_be32(num); memcpy(to, &val, 4); } while(0)
|
|
181
|
+
#define _msgpack_store64(to, num) \
|
|
182
|
+
do { uint64_t val = _msgpack_be64(num); memcpy(to, &val, 8); } while(0)
|
|
183
|
+
|
|
184
|
+
/*
|
|
185
|
+
#define _msgpack_load16(cast, from) \
|
|
186
|
+
({ cast val; memcpy(&val, (char*)from, 2); _msgpack_be16(val); })
|
|
187
|
+
#define _msgpack_load32(cast, from) \
|
|
188
|
+
({ cast val; memcpy(&val, (char*)from, 4); _msgpack_be32(val); })
|
|
189
|
+
#define _msgpack_load64(cast, from) \
|
|
190
|
+
({ cast val; memcpy(&val, (char*)from, 8); _msgpack_be64(val); })
|
|
191
|
+
*/
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
#endif /* msgpack/sysdep.h */
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MessagePack for Python unpacking routine
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2009 Naoki INADA
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
#define MSGPACK_EMBED_STACK_SIZE (1024)
|
|
20
|
+
#include "unpack_define.h"
|
|
21
|
+
|
|
22
|
+
typedef struct unpack_user {
|
|
23
|
+
bool use_list;
|
|
24
|
+
bool raw;
|
|
25
|
+
bool has_pairs_hook;
|
|
26
|
+
bool strict_map_key;
|
|
27
|
+
int timestamp;
|
|
28
|
+
PyObject *object_hook;
|
|
29
|
+
PyObject *list_hook;
|
|
30
|
+
PyObject *ext_hook;
|
|
31
|
+
PyObject *timestamp_t;
|
|
32
|
+
PyObject *giga;
|
|
33
|
+
PyObject *utc;
|
|
34
|
+
const char *unicode_errors;
|
|
35
|
+
Py_ssize_t max_str_len, max_bin_len, max_array_len, max_map_len, max_ext_len;
|
|
36
|
+
} unpack_user;
|
|
37
|
+
|
|
38
|
+
typedef PyObject* msgpack_unpack_object;
|
|
39
|
+
struct unpack_context;
|
|
40
|
+
typedef struct unpack_context unpack_context;
|
|
41
|
+
typedef int (*execute_fn)(unpack_context *ctx, const char* data, Py_ssize_t len, Py_ssize_t* off);
|
|
42
|
+
|
|
43
|
+
static inline msgpack_unpack_object unpack_callback_root(unpack_user* u)
|
|
44
|
+
{
|
|
45
|
+
return NULL;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static inline int unpack_callback_uint16(unpack_user* u, uint16_t d, msgpack_unpack_object* o)
|
|
49
|
+
{
|
|
50
|
+
PyObject *p = PyInt_FromLong((long)d);
|
|
51
|
+
if (!p)
|
|
52
|
+
return -1;
|
|
53
|
+
*o = p;
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
static inline int unpack_callback_uint8(unpack_user* u, uint8_t d, msgpack_unpack_object* o)
|
|
57
|
+
{
|
|
58
|
+
return unpack_callback_uint16(u, d, o);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
static inline int unpack_callback_uint32(unpack_user* u, uint32_t d, msgpack_unpack_object* o)
|
|
63
|
+
{
|
|
64
|
+
PyObject *p = PyInt_FromSize_t((size_t)d);
|
|
65
|
+
if (!p)
|
|
66
|
+
return -1;
|
|
67
|
+
*o = p;
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static inline int unpack_callback_uint64(unpack_user* u, uint64_t d, msgpack_unpack_object* o)
|
|
72
|
+
{
|
|
73
|
+
PyObject *p;
|
|
74
|
+
if (d > LONG_MAX) {
|
|
75
|
+
p = PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)d);
|
|
76
|
+
} else {
|
|
77
|
+
p = PyInt_FromLong((long)d);
|
|
78
|
+
}
|
|
79
|
+
if (!p)
|
|
80
|
+
return -1;
|
|
81
|
+
*o = p;
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static inline int unpack_callback_int32(unpack_user* u, int32_t d, msgpack_unpack_object* o)
|
|
86
|
+
{
|
|
87
|
+
PyObject *p = PyInt_FromLong(d);
|
|
88
|
+
if (!p)
|
|
89
|
+
return -1;
|
|
90
|
+
*o = p;
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static inline int unpack_callback_int16(unpack_user* u, int16_t d, msgpack_unpack_object* o)
|
|
95
|
+
{
|
|
96
|
+
return unpack_callback_int32(u, d, o);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static inline int unpack_callback_int8(unpack_user* u, int8_t d, msgpack_unpack_object* o)
|
|
100
|
+
{
|
|
101
|
+
return unpack_callback_int32(u, d, o);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static inline int unpack_callback_int64(unpack_user* u, int64_t d, msgpack_unpack_object* o)
|
|
105
|
+
{
|
|
106
|
+
PyObject *p;
|
|
107
|
+
if (d > LONG_MAX || d < LONG_MIN) {
|
|
108
|
+
p = PyLong_FromLongLong((PY_LONG_LONG)d);
|
|
109
|
+
} else {
|
|
110
|
+
p = PyInt_FromLong((long)d);
|
|
111
|
+
}
|
|
112
|
+
*o = p;
|
|
113
|
+
return 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
static inline int unpack_callback_double(unpack_user* u, double d, msgpack_unpack_object* o)
|
|
117
|
+
{
|
|
118
|
+
PyObject *p = PyFloat_FromDouble(d);
|
|
119
|
+
if (!p)
|
|
120
|
+
return -1;
|
|
121
|
+
*o = p;
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static inline int unpack_callback_float(unpack_user* u, float d, msgpack_unpack_object* o)
|
|
126
|
+
{
|
|
127
|
+
return unpack_callback_double(u, d, o);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
static inline int unpack_callback_nil(unpack_user* u, msgpack_unpack_object* o)
|
|
131
|
+
{ Py_INCREF(Py_None); *o = Py_None; return 0; }
|
|
132
|
+
|
|
133
|
+
static inline int unpack_callback_true(unpack_user* u, msgpack_unpack_object* o)
|
|
134
|
+
{ Py_INCREF(Py_True); *o = Py_True; return 0; }
|
|
135
|
+
|
|
136
|
+
static inline int unpack_callback_false(unpack_user* u, msgpack_unpack_object* o)
|
|
137
|
+
{ Py_INCREF(Py_False); *o = Py_False; return 0; }
|
|
138
|
+
|
|
139
|
+
static inline int unpack_callback_array(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
|
|
140
|
+
{
|
|
141
|
+
if (n > u->max_array_len) {
|
|
142
|
+
PyErr_Format(PyExc_ValueError, "%u exceeds max_array_len(%zd)", n, u->max_array_len);
|
|
143
|
+
return -1;
|
|
144
|
+
}
|
|
145
|
+
PyObject *p = u->use_list ? PyList_New(n) : PyTuple_New(n);
|
|
146
|
+
|
|
147
|
+
if (!p)
|
|
148
|
+
return -1;
|
|
149
|
+
*o = p;
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
static inline int unpack_callback_array_item(unpack_user* u, unsigned int current, msgpack_unpack_object* c, msgpack_unpack_object o)
|
|
154
|
+
{
|
|
155
|
+
if (u->use_list)
|
|
156
|
+
PyList_SET_ITEM(*c, current, o);
|
|
157
|
+
else
|
|
158
|
+
PyTuple_SET_ITEM(*c, current, o);
|
|
159
|
+
return 0;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static inline int unpack_callback_array_end(unpack_user* u, msgpack_unpack_object* c)
|
|
163
|
+
{
|
|
164
|
+
if (u->list_hook) {
|
|
165
|
+
PyObject *new_c = PyObject_CallFunctionObjArgs(u->list_hook, *c, NULL);
|
|
166
|
+
if (!new_c)
|
|
167
|
+
return -1;
|
|
168
|
+
Py_DECREF(*c);
|
|
169
|
+
*c = new_c;
|
|
170
|
+
}
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static inline int unpack_callback_map(unpack_user* u, unsigned int n, msgpack_unpack_object* o)
|
|
175
|
+
{
|
|
176
|
+
if (n > u->max_map_len) {
|
|
177
|
+
PyErr_Format(PyExc_ValueError, "%u exceeds max_map_len(%zd)", n, u->max_map_len);
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
PyObject *p;
|
|
181
|
+
if (u->has_pairs_hook) {
|
|
182
|
+
p = PyList_New(n); // Or use tuple?
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
p = PyDict_New();
|
|
186
|
+
}
|
|
187
|
+
if (!p)
|
|
188
|
+
return -1;
|
|
189
|
+
*o = p;
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static inline int unpack_callback_map_item(unpack_user* u, unsigned int current, msgpack_unpack_object* c, msgpack_unpack_object k, msgpack_unpack_object v)
|
|
194
|
+
{
|
|
195
|
+
if (u->strict_map_key && !PyUnicode_CheckExact(k) && !PyBytes_CheckExact(k)) {
|
|
196
|
+
PyErr_Format(PyExc_ValueError, "%.100s is not allowed for map key when strict_map_key=True", Py_TYPE(k)->tp_name);
|
|
197
|
+
return -1;
|
|
198
|
+
}
|
|
199
|
+
if (PyUnicode_CheckExact(k)) {
|
|
200
|
+
PyUnicode_InternInPlace(&k);
|
|
201
|
+
}
|
|
202
|
+
if (u->has_pairs_hook) {
|
|
203
|
+
msgpack_unpack_object item = PyTuple_Pack(2, k, v);
|
|
204
|
+
if (!item)
|
|
205
|
+
return -1;
|
|
206
|
+
Py_DECREF(k);
|
|
207
|
+
Py_DECREF(v);
|
|
208
|
+
PyList_SET_ITEM(*c, current, item);
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
else if (PyDict_SetItem(*c, k, v) == 0) {
|
|
212
|
+
Py_DECREF(k);
|
|
213
|
+
Py_DECREF(v);
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
return -1;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
static inline int unpack_callback_map_end(unpack_user* u, msgpack_unpack_object* c)
|
|
220
|
+
{
|
|
221
|
+
if (u->object_hook) {
|
|
222
|
+
PyObject *new_c = PyObject_CallFunctionObjArgs(u->object_hook, *c, NULL);
|
|
223
|
+
if (!new_c)
|
|
224
|
+
return -1;
|
|
225
|
+
|
|
226
|
+
Py_DECREF(*c);
|
|
227
|
+
*c = new_c;
|
|
228
|
+
}
|
|
229
|
+
return 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static inline int unpack_callback_raw(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o)
|
|
233
|
+
{
|
|
234
|
+
if (l > u->max_str_len) {
|
|
235
|
+
PyErr_Format(PyExc_ValueError, "%u exceeds max_str_len(%zd)", l, u->max_str_len);
|
|
236
|
+
return -1;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
PyObject *py;
|
|
240
|
+
|
|
241
|
+
if (u->raw) {
|
|
242
|
+
py = PyBytes_FromStringAndSize(p, l);
|
|
243
|
+
} else {
|
|
244
|
+
py = PyUnicode_DecodeUTF8(p, l, u->unicode_errors);
|
|
245
|
+
}
|
|
246
|
+
if (!py)
|
|
247
|
+
return -1;
|
|
248
|
+
*o = py;
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
static inline int unpack_callback_bin(unpack_user* u, const char* b, const char* p, unsigned int l, msgpack_unpack_object* o)
|
|
253
|
+
{
|
|
254
|
+
if (l > u->max_bin_len) {
|
|
255
|
+
PyErr_Format(PyExc_ValueError, "%u exceeds max_bin_len(%zd)", l, u->max_bin_len);
|
|
256
|
+
return -1;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
PyObject *py = PyBytes_FromStringAndSize(p, l);
|
|
260
|
+
if (!py)
|
|
261
|
+
return -1;
|
|
262
|
+
*o = py;
|
|
263
|
+
return 0;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
typedef struct msgpack_timestamp {
|
|
267
|
+
int64_t tv_sec;
|
|
268
|
+
uint32_t tv_nsec;
|
|
269
|
+
} msgpack_timestamp;
|
|
270
|
+
|
|
271
|
+
/*
|
|
272
|
+
* Unpack ext buffer to a timestamp. Pulled from msgpack-c timestamp.h.
|
|
273
|
+
*/
|
|
274
|
+
static int unpack_timestamp(const char* buf, unsigned int buflen, msgpack_timestamp* ts) {
|
|
275
|
+
switch (buflen) {
|
|
276
|
+
case 4:
|
|
277
|
+
ts->tv_nsec = 0;
|
|
278
|
+
{
|
|
279
|
+
uint32_t v = _msgpack_load32(uint32_t, buf);
|
|
280
|
+
ts->tv_sec = (int64_t)v;
|
|
281
|
+
}
|
|
282
|
+
return 0;
|
|
283
|
+
case 8: {
|
|
284
|
+
uint64_t value =_msgpack_load64(uint64_t, buf);
|
|
285
|
+
ts->tv_nsec = (uint32_t)(value >> 34);
|
|
286
|
+
ts->tv_sec = value & 0x00000003ffffffffLL;
|
|
287
|
+
return 0;
|
|
288
|
+
}
|
|
289
|
+
case 12:
|
|
290
|
+
ts->tv_nsec = _msgpack_load32(uint32_t, buf);
|
|
291
|
+
ts->tv_sec = _msgpack_load64(int64_t, buf + 4);
|
|
292
|
+
return 0;
|
|
293
|
+
default:
|
|
294
|
+
return -1;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
#include "datetime.h"
|
|
299
|
+
|
|
300
|
+
static int unpack_callback_ext(unpack_user* u, const char* base, const char* pos,
|
|
301
|
+
unsigned int length, msgpack_unpack_object* o)
|
|
302
|
+
{
|
|
303
|
+
int8_t typecode = (int8_t)*pos++;
|
|
304
|
+
if (!u->ext_hook) {
|
|
305
|
+
PyErr_SetString(PyExc_AssertionError, "u->ext_hook cannot be NULL");
|
|
306
|
+
return -1;
|
|
307
|
+
}
|
|
308
|
+
if (length-1 > u->max_ext_len) {
|
|
309
|
+
PyErr_Format(PyExc_ValueError, "%u exceeds max_ext_len(%zd)", length, u->max_ext_len);
|
|
310
|
+
return -1;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
PyObject *py = NULL;
|
|
314
|
+
// length also includes the typecode, so the actual data is length-1
|
|
315
|
+
if (typecode == -1) {
|
|
316
|
+
msgpack_timestamp ts;
|
|
317
|
+
if (unpack_timestamp(pos, length-1, &ts) < 0) {
|
|
318
|
+
return -1;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (u->timestamp == 2) { // int
|
|
322
|
+
PyObject *a = PyLong_FromLongLong(ts.tv_sec);
|
|
323
|
+
if (a == NULL) return -1;
|
|
324
|
+
|
|
325
|
+
PyObject *c = PyNumber_Multiply(a, u->giga);
|
|
326
|
+
Py_DECREF(a);
|
|
327
|
+
if (c == NULL) {
|
|
328
|
+
return -1;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
PyObject *b = PyLong_FromUnsignedLong(ts.tv_nsec);
|
|
332
|
+
if (b == NULL) {
|
|
333
|
+
Py_DECREF(c);
|
|
334
|
+
return -1;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
py = PyNumber_Add(c, b);
|
|
338
|
+
Py_DECREF(c);
|
|
339
|
+
Py_DECREF(b);
|
|
340
|
+
}
|
|
341
|
+
else if (u->timestamp == 0) { // Timestamp
|
|
342
|
+
py = PyObject_CallFunction(u->timestamp_t, "(Lk)", ts.tv_sec, ts.tv_nsec);
|
|
343
|
+
}
|
|
344
|
+
else if (u->timestamp == 3) { // datetime
|
|
345
|
+
// Calculate datetime using epoch + delta
|
|
346
|
+
// due to limitations PyDateTime_FromTimestamp on Windows with negative timestamps
|
|
347
|
+
PyObject *epoch = PyDateTimeAPI->DateTime_FromDateAndTime(1970, 1, 1, 0, 0, 0, 0, u->utc, PyDateTimeAPI->DateTimeType);
|
|
348
|
+
if (epoch == NULL) {
|
|
349
|
+
return -1;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
PyObject* d = PyDelta_FromDSU(ts.tv_sec/(24*3600), ts.tv_sec%(24*3600), ts.tv_nsec / 1000);
|
|
353
|
+
if (d == NULL) {
|
|
354
|
+
Py_DECREF(epoch);
|
|
355
|
+
return -1;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
py = PyNumber_Add(epoch, d);
|
|
359
|
+
|
|
360
|
+
Py_DECREF(epoch);
|
|
361
|
+
Py_DECREF(d);
|
|
362
|
+
}
|
|
363
|
+
else { // float
|
|
364
|
+
PyObject *a = PyFloat_FromDouble((double)ts.tv_nsec);
|
|
365
|
+
if (a == NULL) return -1;
|
|
366
|
+
|
|
367
|
+
PyObject *b = PyNumber_TrueDivide(a, u->giga);
|
|
368
|
+
Py_DECREF(a);
|
|
369
|
+
if (b == NULL) return -1;
|
|
370
|
+
|
|
371
|
+
PyObject *c = PyLong_FromLongLong(ts.tv_sec);
|
|
372
|
+
if (c == NULL) {
|
|
373
|
+
Py_DECREF(b);
|
|
374
|
+
return -1;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
a = PyNumber_Add(b, c);
|
|
378
|
+
Py_DECREF(b);
|
|
379
|
+
Py_DECREF(c);
|
|
380
|
+
py = a;
|
|
381
|
+
}
|
|
382
|
+
} else {
|
|
383
|
+
py = PyObject_CallFunction(u->ext_hook, "(iy#)", (int)typecode, pos, (Py_ssize_t)length-1);
|
|
384
|
+
}
|
|
385
|
+
if (!py)
|
|
386
|
+
return -1;
|
|
387
|
+
*o = py;
|
|
388
|
+
return 0;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
#include "unpack_template.h"
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* MessagePack unpacking routine template
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2008-2010 FURUHASHI Sadayuki
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
#ifndef MSGPACK_UNPACK_DEFINE_H__
|
|
19
|
+
#define MSGPACK_UNPACK_DEFINE_H__
|
|
20
|
+
|
|
21
|
+
#include "msgpack/sysdep.h"
|
|
22
|
+
#include <stdlib.h>
|
|
23
|
+
#include <string.h>
|
|
24
|
+
#include <assert.h>
|
|
25
|
+
#include <stdio.h>
|
|
26
|
+
|
|
27
|
+
#ifdef __cplusplus
|
|
28
|
+
extern "C" {
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
#ifndef MSGPACK_EMBED_STACK_SIZE
|
|
33
|
+
#define MSGPACK_EMBED_STACK_SIZE 32
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// CS is first byte & 0x1f
|
|
38
|
+
typedef enum {
|
|
39
|
+
CS_HEADER = 0x00, // nil
|
|
40
|
+
|
|
41
|
+
//CS_ = 0x01,
|
|
42
|
+
//CS_ = 0x02, // false
|
|
43
|
+
//CS_ = 0x03, // true
|
|
44
|
+
|
|
45
|
+
CS_BIN_8 = 0x04,
|
|
46
|
+
CS_BIN_16 = 0x05,
|
|
47
|
+
CS_BIN_32 = 0x06,
|
|
48
|
+
|
|
49
|
+
CS_EXT_8 = 0x07,
|
|
50
|
+
CS_EXT_16 = 0x08,
|
|
51
|
+
CS_EXT_32 = 0x09,
|
|
52
|
+
|
|
53
|
+
CS_FLOAT = 0x0a,
|
|
54
|
+
CS_DOUBLE = 0x0b,
|
|
55
|
+
CS_UINT_8 = 0x0c,
|
|
56
|
+
CS_UINT_16 = 0x0d,
|
|
57
|
+
CS_UINT_32 = 0x0e,
|
|
58
|
+
CS_UINT_64 = 0x0f,
|
|
59
|
+
CS_INT_8 = 0x10,
|
|
60
|
+
CS_INT_16 = 0x11,
|
|
61
|
+
CS_INT_32 = 0x12,
|
|
62
|
+
CS_INT_64 = 0x13,
|
|
63
|
+
|
|
64
|
+
//CS_FIXEXT1 = 0x14,
|
|
65
|
+
//CS_FIXEXT2 = 0x15,
|
|
66
|
+
//CS_FIXEXT4 = 0x16,
|
|
67
|
+
//CS_FIXEXT8 = 0x17,
|
|
68
|
+
//CS_FIXEXT16 = 0x18,
|
|
69
|
+
|
|
70
|
+
CS_RAW_8 = 0x19,
|
|
71
|
+
CS_RAW_16 = 0x1a,
|
|
72
|
+
CS_RAW_32 = 0x1b,
|
|
73
|
+
CS_ARRAY_16 = 0x1c,
|
|
74
|
+
CS_ARRAY_32 = 0x1d,
|
|
75
|
+
CS_MAP_16 = 0x1e,
|
|
76
|
+
CS_MAP_32 = 0x1f,
|
|
77
|
+
|
|
78
|
+
ACS_RAW_VALUE,
|
|
79
|
+
ACS_BIN_VALUE,
|
|
80
|
+
ACS_EXT_VALUE,
|
|
81
|
+
} msgpack_unpack_state;
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
typedef enum {
|
|
85
|
+
CT_ARRAY_ITEM,
|
|
86
|
+
CT_MAP_KEY,
|
|
87
|
+
CT_MAP_VALUE,
|
|
88
|
+
} msgpack_container_type;
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
#ifdef __cplusplus
|
|
92
|
+
}
|
|
93
|
+
#endif
|
|
94
|
+
|
|
95
|
+
#endif /* msgpack/unpack_define.h */
|