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