Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d59f8d06
Commit
d59f8d06
authored
Aug 22, 2002
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interface to Apple Help Manager.
parent
f34a8bce
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
255 additions
and
0 deletions
+255
-0
Mac/Modules/ah/_AHmodule.c
Mac/Modules/ah/_AHmodule.c
+153
-0
Mac/Modules/ah/ahscan.py
Mac/Modules/ah/ahscan.py
+52
-0
Mac/Modules/ah/ahsupport.py
Mac/Modules/ah/ahsupport.py
+50
-0
No files found.
Mac/Modules/ah/_AHmodule.c
0 → 100644
View file @
d59f8d06
/* =========================== Module _AH =========================== */
#include "Python.h"
#ifdef _WIN32
#include "pywintoolbox.h"
#else
#include "macglue.h"
#include "pymactoolbox.h"
#endif
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return NULL; \
}} while(0)
#ifdef WITHOUT_FRAMEWORKS
#include <AppleHelp.h>
#else
#include <Carbon/Carbon.h>
#endif
static
PyObject
*
Ah_Error
;
static
PyObject
*
Ah_AHSearch
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
CFStringRef
bookname
;
CFStringRef
query
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&O&"
,
CFStringRefObj_Convert
,
&
bookname
,
CFStringRefObj_Convert
,
&
query
))
return
NULL
;
_err
=
AHSearch
(
bookname
,
query
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
Ah_AHGotoMainTOC
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
AHTOCType
toctype
;
if
(
!
PyArg_ParseTuple
(
_args
,
"s"
,
&
toctype
))
return
NULL
;
_err
=
AHGotoMainTOC
(
toctype
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
Ah_AHGotoPage
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
CFStringRef
bookname
;
CFStringRef
path
;
CFStringRef
anchor
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&O&O&"
,
CFStringRefObj_Convert
,
&
bookname
,
CFStringRefObj_Convert
,
&
path
,
CFStringRefObj_Convert
,
&
anchor
))
return
NULL
;
_err
=
AHGotoPage
(
bookname
,
path
,
anchor
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
Ah_AHLookupAnchor
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
CFStringRef
bookname
;
CFStringRef
anchor
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&O&"
,
CFStringRefObj_Convert
,
&
bookname
,
CFStringRefObj_Convert
,
&
anchor
))
return
NULL
;
_err
=
AHLookupAnchor
(
bookname
,
anchor
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
Ah_AHRegisterHelpBook
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
FSRef
appBundleRef
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
PyMac_GetFSRef
,
&
appBundleRef
))
return
NULL
;
_err
=
AHRegisterHelpBook
(
&
appBundleRef
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyMethodDef
Ah_methods
[]
=
{
{
"AHSearch"
,
(
PyCFunction
)
Ah_AHSearch
,
1
,
PyDoc_STR
(
"(CFStringRef bookname, CFStringRef query) -> None"
)},
{
"AHGotoMainTOC"
,
(
PyCFunction
)
Ah_AHGotoMainTOC
,
1
,
PyDoc_STR
(
"(AHTOCType toctype) -> None"
)},
{
"AHGotoPage"
,
(
PyCFunction
)
Ah_AHGotoPage
,
1
,
PyDoc_STR
(
"(CFStringRef bookname, CFStringRef path, CFStringRef anchor) -> None"
)},
{
"AHLookupAnchor"
,
(
PyCFunction
)
Ah_AHLookupAnchor
,
1
,
PyDoc_STR
(
"(CFStringRef bookname, CFStringRef anchor) -> None"
)},
{
"AHRegisterHelpBook"
,
(
PyCFunction
)
Ah_AHRegisterHelpBook
,
1
,
PyDoc_STR
(
"(FSRef appBundleRef) -> None"
)},
{
NULL
,
NULL
,
0
}
};
void
init_AH
(
void
)
{
PyObject
*
m
;
PyObject
*
d
;
m
=
Py_InitModule
(
"_AH"
,
Ah_methods
);
d
=
PyModule_GetDict
(
m
);
Ah_Error
=
PyMac_GetOSErrException
();
if
(
Ah_Error
==
NULL
||
PyDict_SetItemString
(
d
,
"Error"
,
Ah_Error
)
!=
0
)
return
;
}
/* ========================= End module _AH ========================= */
Mac/Modules/ah/ahscan.py
0 → 100644
View file @
d59f8d06
# Scan an Apple header file, generating a Python file of generator calls.
import
sys
import
os
from
bgenlocations
import
TOOLBOXDIR
,
BGENDIR
sys
.
path
.
append
(
BGENDIR
)
from
scantools
import
Scanner_OSX
LONG
=
"AppleHelp"
SHORT
=
"ah"
OBJECT
=
"NOTUSED"
def
main
():
input
=
LONG
+
".h"
output
=
SHORT
+
"gen.py"
defsoutput
=
TOOLBOXDIR
+
LONG
+
".py"
scanner
=
MyScanner
(
input
,
output
,
defsoutput
)
scanner
.
scan
()
scanner
.
close
()
print
"=== Testing definitions output code ==="
execfile
(
defsoutput
,
{},
{})
print
"=== Done scanning and generating, now importing the generated code... ==="
exec
"import "
+
SHORT
+
"support"
print
"=== Done. It's up to you to compile it now! ==="
class
MyScanner
(
Scanner_OSX
):
def
destination
(
self
,
type
,
name
,
arglist
):
classname
=
"Function"
listname
=
"functions"
if
arglist
:
t
,
n
,
m
=
arglist
[
0
]
# This is non-functional today
if
t
==
OBJECT
and
m
==
"InMode"
:
classname
=
"Method"
listname
=
"methods"
return
classname
,
listname
def
makeblacklistnames
(
self
):
return
[
]
def
makeblacklisttypes
(
self
):
return
[
]
def
makerepairinstructions
(
self
):
return
[
]
if
__name__
==
"__main__"
:
main
()
Mac/Modules/ah/ahsupport.py
0 → 100644
View file @
d59f8d06
# This script generates a Python interface for an Apple Macintosh Manager.
# It uses the "bgen" package to generate C code.
# The function specifications are generated by scanning the mamager's header file,
# using the "scantools" package (customized for this particular manager).
import
string
# Declarations that change for each manager
MACHEADERFILE
=
'AppleHelp.h'
# The Apple header file
MODNAME
=
'_AH'
# The name of the module
# The following is *usually* unchanged but may still require tuning
MODPREFIX
=
'Ah'
# The prefix for module-wide routines
INPUTFILE
=
string
.
lower
(
MODPREFIX
)
+
'gen.py'
# The file generated by the scanner
OUTPUTFILE
=
MODNAME
+
"module.c"
# The file generated by this program
from
macsupport
import
*
# Create the type objects
AHTOCType
=
Type
(
"AHTOCType"
,
"s"
)
includestuff
=
includestuff
+
"""
#ifdef WITHOUT_FRAMEWORKS
#include <AppleHelp.h>
#else
#include <Carbon/Carbon.h>
#endif
"""
# From here on it's basically all boiler plate...
# Create the generator groups and link them
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
)
# Create the generator classes used to populate the lists
Function
=
OSErrFunctionGenerator
# Create and populate the lists
functions
=
[]
execfile
(
INPUTFILE
)
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
for
f
in
functions
:
module
.
add
(
f
)
# generate output (open the output file as late as possible)
SetOutputFileName
(
OUTPUTFILE
)
module
.
generate
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment