| 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 |
# Python imports |
| 8 |
import logging |
| 9 |
|
| 10 |
# C imports |
| 11 |
from libc cimport stdint |
| 12 |
|
| 13 |
cimport c_amqpvalue |
| 14 |
cimport c_amqp_definitions |
| 15 |
cimport c_utils |
| 16 |
|
| 17 |
|
| 18 |
_logger = logging.getLogger(__name__) |
| 19 |
|
| 20 |
|
| 21 |
cpdef create_data(char* binary_data): |
| 22 |
cdef c_amqpvalue.AMQP_VALUE body_data |
| 23 |
cdef c_amqpvalue.amqp_binary _binary |
| 24 |
length = len(binary_data) |
| 25 |
_binary.length = length |
| 26 |
_binary.bytes = <void*>binary_data |
| 27 |
body_data = c_amqp_definitions.amqpvalue_create_data(_binary) |
| 28 |
if <void*>body_data == NULL: |
| 29 |
raise ValueError("Unable to create payload data") |
| 30 |
return value_factory(body_data) |
| 31 |
|
| 32 |
|
| 33 |
cpdef create_sequence(AMQPValue sequence_data): |
| 34 |
body_data = c_amqp_definitions.amqpvalue_create_amqp_sequence(<c_amqpvalue.AMQP_VALUE>sequence_data._c_value) |
| 35 |
if <void*>body_data == NULL: |
| 36 |
raise ValueError("Unable to create payload data") |
| 37 |
return value_factory(body_data) |