| 1 |
#------------------------------------------------------------------------- |
| 2 |
# Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 |
# Licensed under the MIT License. See License.txt in the project root for |
| 4 |
# license information. |
| 5 |
#-------------------------------------------------------------------------- |
| 6 |
|
| 7 |
from libc cimport stdint |
| 8 |
|
| 9 |
|
| 10 |
cdef extern from "azure_uamqp_c/amqpvalue_to_string.h": |
| 11 |
|
| 12 |
char* amqpvalue_to_string(AMQP_VALUE amqp_value) |
| 13 |
|
| 14 |
|
| 15 |
cdef extern from "azure_uamqp_c/amqp_types.h": |
| 16 |
|
| 17 |
cdef enum AMQP_TYPE_TAG: |
| 18 |
AMQP_TYPE_NULL, |
| 19 |
AMQP_TYPE_BOOL, |
| 20 |
AMQP_TYPE_UBYTE, |
| 21 |
AMQP_TYPE_USHORT, |
| 22 |
AMQP_TYPE_UINT, |
| 23 |
AMQP_TYPE_ULONG, |
| 24 |
AMQP_TYPE_BYTE, |
| 25 |
AMQP_TYPE_SHORT, |
| 26 |
AMQP_TYPE_INT, |
| 27 |
AMQP_TYPE_LONG, |
| 28 |
AMQP_TYPE_FLOAT, |
| 29 |
AMQP_TYPE_DOUBLE, |
| 30 |
AMQP_TYPE_CHAR, |
| 31 |
AMQP_TYPE_TIMESTAMP, |
| 32 |
AMQP_TYPE_UUID, |
| 33 |
AMQP_TYPE_BINARY, |
| 34 |
AMQP_TYPE_STRING, |
| 35 |
AMQP_TYPE_SYMBOL, |
| 36 |
AMQP_TYPE_LIST, |
| 37 |
AMQP_TYPE_MAP, |
| 38 |
AMQP_TYPE_ARRAY, |
| 39 |
AMQP_TYPE_DESCRIBED, |
| 40 |
AMQP_TYPE_COMPOSITE, |
| 41 |
AMQP_TYPE_UNKNOWN |
| 42 |
|
| 43 |
|
| 44 |
cdef extern from "azure_uamqp_c/amqpvalue.h": |
| 45 |
|
| 46 |
ctypedef struct AMQP_VALUE: |
| 47 |
pass |
| 48 |
|
| 49 |
ctypedef unsigned char uuid[16] |
| 50 |
ctypedef stdint.int64_t timestamp |
| 51 |
|
| 52 |
cdef struct amqp_binary_TAG: |
| 53 |
void* bytes |
| 54 |
stdint.uint32_t length |
| 55 |
|
| 56 |
ctypedef amqp_binary_TAG amqp_binary |
| 57 |
|
| 58 |
# type handling |
| 59 |
AMQP_VALUE amqpvalue_create_null() |
| 60 |
AMQP_VALUE amqpvalue_create_boolean(bint bool_value) |
| 61 |
int amqpvalue_get_boolean(AMQP_VALUE value, bint* bool_value) |
| 62 |
AMQP_VALUE amqpvalue_create_ubyte(unsigned char ubyte_value) |
| 63 |
int amqpvalue_get_ubyte(AMQP_VALUE value, unsigned char* ubyte_value) |
| 64 |
AMQP_VALUE amqpvalue_create_ushort(stdint.uint16_t ushort_value) |
| 65 |
int amqpvalue_get_ushort(AMQP_VALUE value, stdint.uint16_t* ushort_value) |
| 66 |
AMQP_VALUE amqpvalue_create_uint(stdint.uint32_t uint_value) |
| 67 |
int amqpvalue_get_uint(AMQP_VALUE value, stdint.uint32_t* uint_value) |
| 68 |
AMQP_VALUE amqpvalue_create_ulong(stdint.uint64_t ulong_value) |
| 69 |
int amqpvalue_get_ulong(AMQP_VALUE value, stdint.uint64_t* ulong_value) |
| 70 |
AMQP_VALUE amqpvalue_create_byte(char byte_value) |
| 71 |
int amqpvalue_get_byte(AMQP_VALUE value, char* byte_value) |
| 72 |
AMQP_VALUE amqpvalue_create_short(stdint.int16_t short_value) |
| 73 |
int amqpvalue_get_short(AMQP_VALUE value, stdint.int16_t* short_value) |
| 74 |
AMQP_VALUE amqpvalue_create_int(stdint.int32_t int_value) |
| 75 |
int amqpvalue_get_int(AMQP_VALUE value, stdint.int32_t* int_value) |
| 76 |
AMQP_VALUE amqpvalue_create_long(stdint.int64_t long_value) |
| 77 |
int amqpvalue_get_long(AMQP_VALUE value, stdint.int64_t* long_value) |
| 78 |
AMQP_VALUE amqpvalue_create_float(float float_value) |
| 79 |
int amqpvalue_get_float(AMQP_VALUE value, float* float_value) |
| 80 |
AMQP_VALUE amqpvalue_create_double(double double_value) |
| 81 |
int amqpvalue_get_double(AMQP_VALUE value, double* double_value) |
| 82 |
AMQP_VALUE amqpvalue_create_char(stdint.uint32_t char_value) |
| 83 |
int amqpvalue_get_char(AMQP_VALUE value, stdint.uint32_t* char_value) |
| 84 |
AMQP_VALUE amqpvalue_create_timestamp(stdint.int64_t timestamp_value) |
| 85 |
int amqpvalue_get_timestamp(AMQP_VALUE value, stdint.int64_t* timestamp_value) |
| 86 |
AMQP_VALUE amqpvalue_create_uuid(uuid uuid_value) |
| 87 |
int amqpvalue_get_uuid(AMQP_VALUE value, uuid* uuid_value) |
| 88 |
AMQP_VALUE amqpvalue_create_binary(amqp_binary binary_value) |
| 89 |
int amqpvalue_get_binary(AMQP_VALUE value, amqp_binary* binary_value) |
| 90 |
AMQP_VALUE amqpvalue_create_string(char* string_value) |
| 91 |
int amqpvalue_get_string(AMQP_VALUE value, char** string_value) |
| 92 |
AMQP_VALUE amqpvalue_create_symbol(char* symbol_value) |
| 93 |
int amqpvalue_get_symbol(AMQP_VALUE value, char** symbol_value) |
| 94 |
AMQP_VALUE amqpvalue_create_list() |
| 95 |
int amqpvalue_set_list_item_count(AMQP_VALUE list, stdint.uint32_t count) |
| 96 |
int amqpvalue_get_list_item_count(AMQP_VALUE list, stdint.uint32_t* count) |
| 97 |
int amqpvalue_set_list_item(AMQP_VALUE list, stdint.uint32_t index, AMQP_VALUE list_item_value) |
| 98 |
AMQP_VALUE amqpvalue_get_list_item(AMQP_VALUE list, size_t index) |
| 99 |
AMQP_VALUE amqpvalue_create_map() |
| 100 |
int amqpvalue_set_map_value(AMQP_VALUE map, AMQP_VALUE key, AMQP_VALUE value) |
| 101 |
AMQP_VALUE amqpvalue_get_map_value(AMQP_VALUE map, AMQP_VALUE key) |
| 102 |
int amqpvalue_get_map_pair_count(AMQP_VALUE map, stdint.uint32_t* pair_count) |
| 103 |
int amqpvalue_get_map_key_value_pair(AMQP_VALUE map, stdint.uint32_t index, AMQP_VALUE* key, AMQP_VALUE* value) |
| 104 |
int amqpvalue_get_map(AMQP_VALUE from_value, AMQP_VALUE* map) # TODO |
| 105 |
AMQP_TYPE_TAG amqpvalue_get_type(AMQP_VALUE value) |
| 106 |
void amqpvalue_destroy(AMQP_VALUE value) |
| 107 |
bint amqpvalue_are_equal(AMQP_VALUE value1, AMQP_VALUE value2) |
| 108 |
AMQP_VALUE amqpvalue_clone(AMQP_VALUE value) |
| 109 |
|
| 110 |
# encoding |
| 111 |
ctypedef int (*AMQPVALUE_ENCODER_OUTPUT)(void *context, unsigned char* bytes, size_t length) |
| 112 |
int amqpvalue_encode(AMQP_VALUE value, AMQPVALUE_ENCODER_OUTPUT encoder_output, void* context) |
| 113 |
int amqpvalue_get_encoded_size(AMQP_VALUE value, size_t* encoded_size) |
| 114 |
|
| 115 |
# decoding |
| 116 |
ctypedef struct AMQPVALUE_DECODER_HANDLE: |
| 117 |
pass |
| 118 |
ctypedef void(*ON_VALUE_DECODED)(void* context, AMQP_VALUE decoded_value) |
| 119 |
AMQPVALUE_DECODER_HANDLE amqpvalue_decoder_create(ON_VALUE_DECODED on_value_decoded, void* callback_context) |
| 120 |
void amqpvalue_decoder_destroy(AMQPVALUE_DECODER_HANDLE handle) |
| 121 |
int amqpvalue_decode_bytes(AMQPVALUE_DECODER_HANDLE handle, unsigned char* buffer, size_t size) |
| 122 |
|
| 123 |
# misc for now |
| 124 |
AMQP_VALUE amqpvalue_create_array() |
| 125 |
int amqpvalue_get_array_item_count(AMQP_VALUE value, stdint.uint32_t* count) |
| 126 |
int amqpvalue_add_array_item(AMQP_VALUE value, AMQP_VALUE array_item_value) |
| 127 |
AMQP_VALUE amqpvalue_get_array_item(AMQP_VALUE value, stdint.uint32_t index) |
| 128 |
int amqpvalue_get_array(AMQP_VALUE value, AMQP_VALUE* array_value) |
| 129 |
AMQP_VALUE amqpvalue_get_inplace_descriptor(AMQP_VALUE value) |
| 130 |
AMQP_VALUE amqpvalue_get_inplace_described_value(AMQP_VALUE value) |
| 131 |
AMQP_VALUE amqpvalue_create_composite(AMQP_VALUE descriptor, stdint.uint32_t list_size) |
| 132 |
int amqpvalue_set_composite_item(AMQP_VALUE value, stdint.uint32_t index, AMQP_VALUE item_value) |
| 133 |
AMQP_VALUE amqpvalue_get_composite_item(AMQP_VALUE value, size_t index) |
| 134 |
AMQP_VALUE amqpvalue_create_described(AMQP_VALUE descriptor, AMQP_VALUE value) |
| 135 |
AMQP_VALUE amqpvalue_create_composite_with_ulong_descriptor(stdint.uint64_t descriptor) |
| 136 |
AMQP_VALUE amqpvalue_get_list_item_in_place(AMQP_VALUE value, size_t index) |
| 137 |
AMQP_VALUE amqpvalue_get_composite_item_in_place(AMQP_VALUE value, size_t index) |
| 138 |
int amqpvalue_get_composite_item_count(AMQP_VALUE value, stdint.uint32_t* item_count) |