2 /* =========================== Module _AH =========================== */
9 #include "pywintoolbox.h"
12 #include "pymactoolbox.h"
15 /* Macro to test whether a weak-loaded CFM function exists */
16 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
17 PyErr_SetString(PyExc_NotImplementedError, \
18 "Not available in this shared library/OS version"); \
23 #ifdef WITHOUT_FRAMEWORKS
24 #include <AppleHelp.h>
26 #include <Carbon/Carbon.h>
30 static PyObject
*Ah_Error
;
32 static PyObject
*Ah_AHSearch(PyObject
*_self
, PyObject
*_args
)
34 PyObject
*_res
= NULL
;
38 if (!PyArg_ParseTuple(_args
, "O&O&",
39 CFStringRefObj_Convert
, &bookname
,
40 CFStringRefObj_Convert
, &query
))
42 _err
= AHSearch(bookname
,
44 if (_err
!= noErr
) return PyMac_Error(_err
);
50 static PyObject
*Ah_AHGotoMainTOC(PyObject
*_self
, PyObject
*_args
)
52 PyObject
*_res
= NULL
;
55 if (!PyArg_ParseTuple(_args
, "h",
58 _err
= AHGotoMainTOC(toctype
);
59 if (_err
!= noErr
) return PyMac_Error(_err
);
65 static PyObject
*Ah_AHGotoPage(PyObject
*_self
, PyObject
*_args
)
67 PyObject
*_res
= NULL
;
72 if (!PyArg_ParseTuple(_args
, "O&O&O&",
73 CFStringRefObj_Convert
, &bookname
,
74 CFStringRefObj_Convert
, &path
,
75 CFStringRefObj_Convert
, &anchor
))
77 _err
= AHGotoPage(bookname
,
80 if (_err
!= noErr
) return PyMac_Error(_err
);
86 static PyObject
*Ah_AHLookupAnchor(PyObject
*_self
, PyObject
*_args
)
88 PyObject
*_res
= NULL
;
92 if (!PyArg_ParseTuple(_args
, "O&O&",
93 CFStringRefObj_Convert
, &bookname
,
94 CFStringRefObj_Convert
, &anchor
))
96 _err
= AHLookupAnchor(bookname
,
98 if (_err
!= noErr
) return PyMac_Error(_err
);
104 static PyObject
*Ah_AHRegisterHelpBook(PyObject
*_self
, PyObject
*_args
)
106 PyObject
*_res
= NULL
;
109 if (!PyArg_ParseTuple(_args
, "O&",
110 PyMac_GetFSRef
, &appBundleRef
))
112 _err
= AHRegisterHelpBook(&appBundleRef
);
113 if (_err
!= noErr
) return PyMac_Error(_err
);
119 static PyMethodDef Ah_methods
[] = {
120 {"AHSearch", (PyCFunction
)Ah_AHSearch
, 1,
121 PyDoc_STR("(CFStringRef bookname, CFStringRef query) -> None")},
122 {"AHGotoMainTOC", (PyCFunction
)Ah_AHGotoMainTOC
, 1,
123 PyDoc_STR("(AHTOCType toctype) -> None")},
124 {"AHGotoPage", (PyCFunction
)Ah_AHGotoPage
, 1,
125 PyDoc_STR("(CFStringRef bookname, CFStringRef path, CFStringRef anchor) -> None")},
126 {"AHLookupAnchor", (PyCFunction
)Ah_AHLookupAnchor
, 1,
127 PyDoc_STR("(CFStringRef bookname, CFStringRef anchor) -> None")},
128 {"AHRegisterHelpBook", (PyCFunction
)Ah_AHRegisterHelpBook
, 1,
129 PyDoc_STR("(FSRef appBundleRef) -> None")},
144 m
= Py_InitModule("_AH", Ah_methods
);
145 d
= PyModule_GetDict(m
);
146 Ah_Error
= PyMac_GetOSErrException();
147 if (Ah_Error
== NULL
||
148 PyDict_SetItemString(d
, "Error", Ah_Error
) != 0)
152 /* ========================= End module _AH ========================= */