PageRenderTime 43ms CodeModel.GetById 11ms RepoModel.GetById 1ms app.codeStats 0ms

/src/google/protobuf-c/protobuf-c-private.h

http://protobuf-c.googlecode.com/
C Header | 106 lines | 33 code | 12 blank | 61 comment | 0 complexity | 0963615cf009f20ee050d75e5f052d1e MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /* --- protobuf-c-private.h: private structures and functions --- */
  2. /*
  3. * Copyright (c) 2008-2011, Dave Benson.
  4. *
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with
  8. * or without modification, are permitted provided that the
  9. * following conditions are met:
  10. *
  11. * Redistributions of source code must retain the above
  12. * copyright notice, this list of conditions and the following
  13. * disclaimer.
  14. * Redistributions in binary form must reproduce
  15. * the above copyright notice, this list of conditions and
  16. * the following disclaimer in the documentation and/or other
  17. * materials provided with the distribution.
  18. *
  19. * Neither the name
  20. * of "protobuf-c" nor the names of its contributors
  21. * may be used to endorse or promote products derived from
  22. * this software without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  25. * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  26. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  27. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
  29. * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  30. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  31. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  32. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  33. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  34. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  35. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  36. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  37. * POSSIBILITY OF SUCH DAMAGE.
  38. */
  39. /* A little enum helper macro: this will ensure that your
  40. enum's size is sizeof(int). In protobuf, it need not
  41. be larger than 32-bits.
  42. This is written assuming it is appended to a list w/o a tail comma. */
  43. #ifndef _PROTOBUF_C_FORCE_ENUM_TO_BE_INT_SIZE
  44. #define _PROTOBUF_C_FORCE_ENUM_TO_BE_INT_SIZE(enum_name) \
  45. , _##enum_name##_IS_INT_SIZE = INT_MAX
  46. #endif
  47. /* === needs to be declared for the PROTOBUF_C_BUFFER_SIMPLE_INIT macro === */
  48. void protobuf_c_buffer_simple_append (ProtobufCBuffer *buffer,
  49. size_t len,
  50. const unsigned char *data);
  51. /* === stuff which needs to be declared for use in the generated code === */
  52. struct _ProtobufCEnumValueIndex
  53. {
  54. const char *name;
  55. unsigned index; /* into values[] array */
  56. };
  57. /* IntRange: helper structure for optimizing
  58. int => index lookups
  59. in the case where the keys are mostly consecutive values,
  60. as they presumably are for enums and fields.
  61. The data structures assumes that the values in the original
  62. array are sorted */
  63. struct _ProtobufCIntRange
  64. {
  65. int start_value;
  66. unsigned orig_index;
  67. /* NOTE: the number of values in the range can
  68. be inferred by looking at the next element's orig_index.
  69. a dummy element is added to make this simple */
  70. };
  71. /* === declared for exposition on ProtobufCIntRange === */
  72. /* note: ranges must have an extra sentinel IntRange at the end whose
  73. orig_index is set to the number of actual values in the original array */
  74. /* returns -1 if no orig_index found */
  75. int protobuf_c_int_ranges_lookup (unsigned n_ranges,
  76. ProtobufCIntRange *ranges);
  77. #define PROTOBUF_C_SERVICE_DESCRIPTOR_MAGIC 0x14159bc3
  78. #define PROTOBUF_C_MESSAGE_DESCRIPTOR_MAGIC 0x28aaeef9
  79. #define PROTOBUF_C_ENUM_DESCRIPTOR_MAGIC 0x114315af
  80. /* === behind the scenes on the generated service's __init functions */
  81. typedef void (*ProtobufCServiceDestroy) (ProtobufCService *service);
  82. void
  83. protobuf_c_service_generated_init (ProtobufCService *service,
  84. const ProtobufCServiceDescriptor *descriptor,
  85. ProtobufCServiceDestroy destroy);
  86. void
  87. protobuf_c_service_invoke_internal(ProtobufCService *service,
  88. unsigned method_index,
  89. const ProtobufCMessage *input,
  90. ProtobufCClosure closure,
  91. void *closure_data);