39 #ifndef PYTHONINCLUDES_H_
40 #define PYTHONINCLUDES_H_
43 #if defined(_MSC_VER) && defined(_DEBUG)
60 # include <sys/stat.h>
65 # define _CRT_NOFORCE_MANIFEST 1
68 # include <frameobject.h>
69 # include <structmember.h>
75 # include <frameobject.h>
76 # include <structmember.h>
78 # pragma GCC diagnostic push
79 # pragma GCC diagnostic ignored "-pedantic"
81 # pragma GCC diagnostic pop
84 static const sipAPIDef *getSipAPI() {
85 #if defined(SIP_USE_PYCAPSULE)
86 return (
const sipAPIDef *)PyCapsule_Import(
"sip._C_API", 0);
89 PyObject *sip_module_dict;
93 sip_module = PyImport_ImportModule(
"sip");
95 if (sip_module == NULL)
99 sip_module_dict = PyModule_GetDict(sip_module);
102 c_api = PyDict_GetItemString(sip_module_dict,
"_C_API");
108 if (!PyCObject_Check(c_api))
112 return (
const sipAPIDef *)PyCObject_AsVoidPtr(c_api);
116 static const sipAPIDef *sipAPI = NULL;
118 static void initSipAPI() {
120 sipAPI = getSipAPI();
124 #define sipMalloc sipAPI->api_malloc
125 #define sipFree sipAPI->api_free
126 #define sipBuildResult sipAPI->api_build_result
127 #define sipCallMethod sipAPI->api_call_method
128 #define sipParseResult sipAPI->api_parse_result
129 #define sipParseArgs sipAPI->api_parse_args
130 #define sipParseKwdArgs sipAPI->api_parse_kwd_args
131 #define sipParsePair sipAPI->api_parse_pair
132 #define sipCommonDtor sipAPI->api_common_dtor
133 #define sipConvertFromSequenceIndex sipAPI->api_convert_from_sequence_index
134 #define sipConvertFromVoidPtr sipAPI->api_convert_from_void_ptr
135 #define sipConvertToVoidPtr sipAPI->api_convert_to_void_ptr
136 #define sipAddException sipAPI->api_add_exception
137 #define sipNoFunction sipAPI->api_no_function
138 #define sipNoMethod sipAPI->api_no_method
139 #define sipAbstractMethod sipAPI->api_abstract_method
140 #define sipBadClass sipAPI->api_bad_class
141 #define sipBadCatcherResult sipAPI->api_bad_catcher_result
142 #define sipBadCallableArg sipAPI->api_bad_callable_arg
143 #define sipBadOperatorArg sipAPI->api_bad_operator_arg
144 #define sipTrace sipAPI->api_trace
145 #define sipTransferBack sipAPI->api_transfer_back
146 #define sipTransferTo sipAPI->api_transfer_to
147 #define sipTransferBreak sipAPI->api_transfer_break
148 #define sipSimpleWrapper_Type sipAPI->api_simplewrapper_type
149 #define sipWrapper_Type sipAPI->api_wrapper_type
150 #define sipWrapperType_Type sipAPI->api_wrappertype_type
151 #define sipVoidPtr_Type sipAPI->api_voidptr_type
152 #define sipGetPyObject sipAPI->api_get_pyobject
153 #define sipGetAddress sipAPI->api_get_address
154 #define sipGetCppPtr sipAPI->api_get_cpp_ptr
155 #define sipGetComplexCppPtr sipAPI->api_get_complex_cpp_ptr
156 #define sipIsPyMethod sipAPI->api_is_py_method
157 #define sipCallHook sipAPI->api_call_hook
158 #define sipStartThread sipAPI->api_start_thread
159 #define sipEndThread sipAPI->api_end_thread
160 #define sipConnectRx sipAPI->api_connect_rx
161 #define sipDisconnectRx sipAPI->api_disconnect_rx
162 #define sipRaiseUnknownException sipAPI->api_raise_unknown_exception
163 #define sipRaiseTypeException sipAPI->api_raise_type_exception
164 #define sipBadLengthForSlice sipAPI->api_bad_length_for_slice
165 #define sipAddTypeInstance sipAPI->api_add_type_instance
166 #define sipFreeSipslot sipAPI->api_free_sipslot
167 #define sipSameSlot sipAPI->api_same_slot
168 #define sipPySlotExtend sipAPI->api_pyslot_extend
169 #define sipConvertRx sipAPI->api_convert_rx
170 #define sipAddDelayedDtor sipAPI->api_add_delayed_dtor
171 #define sipCanConvertToType sipAPI->api_can_convert_to_type
172 #define sipConvertToType sipAPI->api_convert_to_type
173 #define sipForceConvertToType sipAPI->api_force_convert_to_type
174 #define sipCanConvertToEnum sipAPI->api_can_convert_to_enum
175 #define sipReleaseType sipAPI->api_release_type
176 #define sipConvertFromType sipAPI->api_convert_from_type
177 #define sipConvertFromNewType sipAPI->api_convert_from_new_type
178 #define sipConvertFromEnum sipAPI->api_convert_from_enum
179 #define sipGetState sipAPI->api_get_state
180 #define sipLong_AsUnsignedLong sipAPI->api_long_as_unsigned_long
181 #define sipExportSymbol sipAPI->api_export_symbol
182 #define sipImportSymbol sipAPI->api_import_symbol
183 #define sipFindType sipAPI->api_find_type
184 #define sipFindNamedEnum sipAPI->api_find_named_enum
185 #define sipBytes_AsChar sipAPI->api_bytes_as_char
186 #define sipBytes_AsString sipAPI->api_bytes_as_string
187 #define sipString_AsASCIIChar sipAPI->api_string_as_ascii_char
188 #define sipString_AsASCIIString sipAPI->api_string_as_ascii_string
189 #define sipString_AsLatin1Char sipAPI->api_string_as_latin1_char
190 #define sipString_AsLatin1String sipAPI->api_string_as_latin1_string
191 #define sipString_AsUTF8Char sipAPI->api_string_as_utf8_char
192 #define sipString_AsUTF8String sipAPI->api_string_as_utf8_string
193 #define sipUnicode_AsWChar sipAPI->api_unicode_as_wchar
194 #define sipUnicode_AsWString sipAPI->api_unicode_as_wstring
195 #define sipConvertFromConstVoidPtr sipAPI->api_convert_from_const_void_ptr
196 #define sipConvertFromVoidPtrAndSize sipAPI->api_convert_from_void_ptr_and_size
197 #define sipConvertFromConstVoidPtrAndSize sipAPI->api_convert_from_const_void_ptr_and_size
198 #define sipInvokeSlot sipAPI->api_invoke_slot
199 #define sipSaveSlot sipAPI->api_save_slot
200 #define sipClearAnySlotReference sipAPI->api_clear_any_slot_reference
201 #define sipVisitSlot sipAPI->api_visit_slot
202 #define sipWrappedTypeName(wt) ((wt)->type->td_cname)
203 #define sipDeprecated sipAPI->api_deprecated
204 #define sipKeepReference sipAPI->api_keep_reference
205 #define sipRegisterPyType sipAPI->api_register_py_type
206 #define sipTypeFromPyTypeObject sipAPI->api_type_from_py_type_object
207 #define sipTypeScope sipAPI->api_type_scope
208 #define sipResolveTypedef sipAPI->api_resolve_typedef
209 #define sipRegisterAttributeGetter sipAPI->api_register_attribute_getter
210 #define sipIsAPIEnabled sipAPI->api_is_api_enabled
211 #define sipExportModule sipAPI->api_export_module
212 #define sipInitModule sipAPI->api_init_module