Got angry and added support for pretty much the whole file and folder

manager. This should allow us the get rid of most of the FSSpecs, only
navigation services remains to be done.
This commit is contained in:
Jack Jansen 2002-11-22 14:58:35 +00:00
parent a191befb2d
commit e2ba87396c
11 changed files with 2761 additions and 0 deletions

1
Mac/Lib/Carbon/File.py Normal file
View File

@ -0,0 +1 @@
from _File import *

340
Mac/Lib/Carbon/Files.py Normal file
View File

@ -0,0 +1,340 @@
# Generated from 'Files.h'
def FOUR_CHAR_CODE(x): return x
true = True
false = False
fsCurPerm = 0x00
fsRdPerm = 0x01
fsWrPerm = 0x02
fsRdWrPerm = 0x03
fsRdWrShPerm = 0x04
fsRdDenyPerm = 0x10
fsWrDenyPerm = 0x20
fsRtParID = 1
fsRtDirID = 2
fsAtMark = 0
fsFromStart = 1
fsFromLEOF = 2
fsFromMark = 3
pleaseCacheBit = 4
pleaseCacheMask = 0x0010
noCacheBit = 5
noCacheMask = 0x0020
rdVerifyBit = 6
rdVerifyMask = 0x0040
rdVerify = 64
forceReadBit = 6
forceReadMask = 0x0040
newLineBit = 7
newLineMask = 0x0080
newLineCharMask = 0xFF00
fsSBPartialName = 1
fsSBFullName = 2
fsSBFlAttrib = 4
fsSBFlFndrInfo = 8
fsSBFlLgLen = 32
fsSBFlPyLen = 64
fsSBFlRLgLen = 128
fsSBFlRPyLen = 256
fsSBFlCrDat = 512
fsSBFlMdDat = 1024
fsSBFlBkDat = 2048
fsSBFlXFndrInfo = 4096
fsSBFlParID = 8192
fsSBNegate = 16384
fsSBDrUsrWds = 8
fsSBDrNmFls = 16
fsSBDrCrDat = 512
fsSBDrMdDat = 1024
fsSBDrBkDat = 2048
fsSBDrFndrInfo = 4096
fsSBDrParID = 8192
fsSBPartialNameBit = 0
fsSBFullNameBit = 1
fsSBFlAttribBit = 2
fsSBFlFndrInfoBit = 3
fsSBFlLgLenBit = 5
fsSBFlPyLenBit = 6
fsSBFlRLgLenBit = 7
fsSBFlRPyLenBit = 8
fsSBFlCrDatBit = 9
fsSBFlMdDatBit = 10
fsSBFlBkDatBit = 11
fsSBFlXFndrInfoBit = 12
fsSBFlParIDBit = 13
fsSBNegateBit = 14
fsSBDrUsrWdsBit = 3
fsSBDrNmFlsBit = 4
fsSBDrCrDatBit = 9
fsSBDrMdDatBit = 10
fsSBDrBkDatBit = 11
fsSBDrFndrInfoBit = 12
fsSBDrParIDBit = 13
bLimitFCBs = 31
bLocalWList = 30
bNoMiniFndr = 29
bNoVNEdit = 28
bNoLclSync = 27
bTrshOffLine = 26
bNoSwitchTo = 25
bNoDeskItems = 20
bNoBootBlks = 19
bAccessCntl = 18
bNoSysDir = 17
bHasExtFSVol = 16
bHasOpenDeny = 15
bHasCopyFile = 14
bHasMoveRename = 13
bHasDesktopMgr = 12
bHasShortName = 11
bHasFolderLock = 10
bHasPersonalAccessPrivileges = 9
bHasUserGroupList = 8
bHasCatSearch = 7
bHasFileIDs = 6
bHasBTreeMgr = 5
bHasBlankAccessPrivileges = 4
bSupportsAsyncRequests = 3
bSupportsTrashVolumeCache = 2
bIsEjectable = 0
bSupportsHFSPlusAPIs = 1
bSupportsFSCatalogSearch = 2
bSupportsFSExchangeObjects = 3
bSupports2TBFiles = 4
bSupportsLongNames = 5
bSupportsMultiScriptNames = 6
bSupportsNamedForks = 7
bSupportsSubtreeIterators = 8
bL2PCanMapFileBlocks = 9
bParentModDateChanges = 10
bAncestorModDateChanges = 11
bSupportsSymbolicLinks = 13
bIsAutoMounted = 14
bAllowCDiDataHandler = 17
kLargeIcon = 1
kLarge4BitIcon = 2
kLarge8BitIcon = 3
kSmallIcon = 4
kSmall4BitIcon = 5
kSmall8BitIcon = 6
kicnsIconFamily = 239
kLargeIconSize = 256
kLarge4BitIconSize = 512
kLarge8BitIconSize = 1024
kSmallIconSize = 64
kSmall4BitIconSize = 128
kSmall8BitIconSize = 256
kWidePosOffsetBit = 8
kUseWidePositioning = (1 << kWidePosOffsetBit)
kMaximumBlocksIn4GB = 0x007FFFFF
fsUnixPriv = 1
kNoUserAuthentication = 1
kPassword = 2
kEncryptPassword = 3
kTwoWayEncryptPassword = 6
kOwnerID2Name = 1
kGroupID2Name = 2
kOwnerName2ID = 3
kGroupName2ID = 4
kReturnNextUser = 1
kReturnNextGroup = 2
kReturnNextUG = 3
kVCBFlagsIdleFlushBit = 3
kVCBFlagsIdleFlushMask = 0x0008
kVCBFlagsHFSPlusAPIsBit = 4
kVCBFlagsHFSPlusAPIsMask = 0x0010
kVCBFlagsHardwareGoneBit = 5
kVCBFlagsHardwareGoneMask = 0x0020
kVCBFlagsVolumeDirtyBit = 15
kVCBFlagsVolumeDirtyMask = 0x8000
kioVAtrbDefaultVolumeBit = 5
kioVAtrbDefaultVolumeMask = 0x0020
kioVAtrbFilesOpenBit = 6
kioVAtrbFilesOpenMask = 0x0040
kioVAtrbHardwareLockedBit = 7
kioVAtrbHardwareLockedMask = 0x0080
kioVAtrbSoftwareLockedBit = 15
kioVAtrbSoftwareLockedMask = 0x8000
kioFlAttribLockedBit = 0
kioFlAttribLockedMask = 0x01
kioFlAttribResOpenBit = 2
kioFlAttribResOpenMask = 0x04
kioFlAttribDataOpenBit = 3
kioFlAttribDataOpenMask = 0x08
kioFlAttribDirBit = 4
kioFlAttribDirMask = 0x10
ioDirFlg = 4
ioDirMask = 0x10
kioFlAttribCopyProtBit = 6
kioFlAttribCopyProtMask = 0x40
kioFlAttribFileOpenBit = 7
kioFlAttribFileOpenMask = 0x80
kioFlAttribInSharedBit = 2
kioFlAttribInSharedMask = 0x04
kioFlAttribMountedBit = 3
kioFlAttribMountedMask = 0x08
kioFlAttribSharePointBit = 5
kioFlAttribSharePointMask = 0x20
kioFCBWriteBit = 8
kioFCBWriteMask = 0x0100
kioFCBResourceBit = 9
kioFCBResourceMask = 0x0200
kioFCBWriteLockedBit = 10
kioFCBWriteLockedMask = 0x0400
kioFCBLargeFileBit = 11
kioFCBLargeFileMask = 0x0800
kioFCBSharedWriteBit = 12
kioFCBSharedWriteMask = 0x1000
kioFCBFileLockedBit = 13
kioFCBFileLockedMask = 0x2000
kioFCBOwnClumpBit = 14
kioFCBOwnClumpMask = 0x4000
kioFCBModifiedBit = 15
kioFCBModifiedMask = 0x8000
kioACUserNoSeeFolderBit = 0
kioACUserNoSeeFolderMask = 0x01
kioACUserNoSeeFilesBit = 1
kioACUserNoSeeFilesMask = 0x02
kioACUserNoMakeChangesBit = 2
kioACUserNoMakeChangesMask = 0x04
kioACUserNotOwnerBit = 7
kioACUserNotOwnerMask = 0x80
kioACAccessOwnerBit = 31
# kioACAccessOwnerMask = (long)0x80000000
kioACAccessBlankAccessBit = 28
kioACAccessBlankAccessMask = 0x10000000
kioACAccessUserWriteBit = 26
kioACAccessUserWriteMask = 0x04000000
kioACAccessUserReadBit = 25
kioACAccessUserReadMask = 0x02000000
kioACAccessUserSearchBit = 24
kioACAccessUserSearchMask = 0x01000000
kioACAccessEveryoneWriteBit = 18
kioACAccessEveryoneWriteMask = 0x00040000
kioACAccessEveryoneReadBit = 17
kioACAccessEveryoneReadMask = 0x00020000
kioACAccessEveryoneSearchBit = 16
kioACAccessEveryoneSearchMask = 0x00010000
kioACAccessGroupWriteBit = 10
kioACAccessGroupWriteMask = 0x00000400
kioACAccessGroupReadBit = 9
kioACAccessGroupReadMask = 0x00000200
kioACAccessGroupSearchBit = 8
kioACAccessGroupSearchMask = 0x00000100
kioACAccessOwnerWriteBit = 2
kioACAccessOwnerWriteMask = 0x00000004
kioACAccessOwnerReadBit = 1
kioACAccessOwnerReadMask = 0x00000002
kioACAccessOwnerSearchBit = 0
kioACAccessOwnerSearchMask = 0x00000001
kfullPrivileges = 0x00070007
kownerPrivileges = 0x00000007
knoUser = 0
kadministratorUser = 1
knoGroup = 0
AppleShareMediaType = FOUR_CHAR_CODE('afpm')
volMountNoLoginMsgFlagBit = 0
volMountNoLoginMsgFlagMask = 0x0001
volMountExtendedFlagsBit = 7
volMountExtendedFlagsMask = 0x0080
volMountInteractBit = 15
volMountInteractMask = 0x8000
volMountChangedBit = 14
volMountChangedMask = 0x4000
volMountFSReservedMask = 0x00FF
volMountSysReservedMask = 0xFF00
kAFPExtendedFlagsAlternateAddressMask = 1
kAFPTagTypeIP = 0x01
kAFPTagTypeIPPort = 0x02
kAFPTagTypeDDP = 0x03
kAFPTagTypeDNS = 0x04
kAFPTagLengthIP = 0x06
kAFPTagLengthIPPort = 0x08
kAFPTagLengthDDP = 0x06
kFSInvalidVolumeRefNum = 0
kFSCatInfoNone = 0x00000000
kFSCatInfoTextEncoding = 0x00000001
kFSCatInfoNodeFlags = 0x00000002
kFSCatInfoVolume = 0x00000004
kFSCatInfoParentDirID = 0x00000008
kFSCatInfoNodeID = 0x00000010
kFSCatInfoCreateDate = 0x00000020
kFSCatInfoContentMod = 0x00000040
kFSCatInfoAttrMod = 0x00000080
kFSCatInfoAccessDate = 0x00000100
kFSCatInfoBackupDate = 0x00000200
kFSCatInfoPermissions = 0x00000400
kFSCatInfoFinderInfo = 0x00000800
kFSCatInfoFinderXInfo = 0x00001000
kFSCatInfoValence = 0x00002000
kFSCatInfoDataSizes = 0x00004000
kFSCatInfoRsrcSizes = 0x00008000
kFSCatInfoSharingFlags = 0x00010000
kFSCatInfoUserPrivs = 0x00020000
kFSCatInfoAllDates = 0x000003E0
kFSCatInfoGettableInfo = 0x0003FFFF
kFSCatInfoSettableInfo = 0x00001FE3
# kFSCatInfoReserved = (long)0xFFFC0000
kFSNodeLockedBit = 0
kFSNodeLockedMask = 0x0001
kFSNodeResOpenBit = 2
kFSNodeResOpenMask = 0x0004
kFSNodeDataOpenBit = 3
kFSNodeDataOpenMask = 0x0008
kFSNodeIsDirectoryBit = 4
kFSNodeIsDirectoryMask = 0x0010
kFSNodeCopyProtectBit = 6
kFSNodeCopyProtectMask = 0x0040
kFSNodeForkOpenBit = 7
kFSNodeForkOpenMask = 0x0080
kFSNodeInSharedBit = 2
kFSNodeInSharedMask = 0x0004
kFSNodeIsMountedBit = 3
kFSNodeIsMountedMask = 0x0008
kFSNodeIsSharePointBit = 5
kFSNodeIsSharePointMask = 0x0020
kFSIterateFlat = 0
kFSIterateSubtree = 1
kFSIterateDelete = 2
# kFSIterateReserved = (long)0xFFFFFFFC
fsSBNodeID = 0x00008000
fsSBAttributeModDate = 0x00010000
fsSBAccessDate = 0x00020000
fsSBPermissions = 0x00040000
fsSBNodeIDBit = 15
fsSBAttributeModDateBit = 16
fsSBAccessDateBit = 17
fsSBPermissionsBit = 18
kFSAllocDefaultFlags = 0x0000
kFSAllocAllOrNothingMask = 0x0001
kFSAllocContiguousMask = 0x0002
kFSAllocNoRoundUpMask = 0x0004
kFSAllocReservedMask = 0xFFF8
kFSVolInfoNone = 0x0000
kFSVolInfoCreateDate = 0x0001
kFSVolInfoModDate = 0x0002
kFSVolInfoBackupDate = 0x0004
kFSVolInfoCheckedDate = 0x0008
kFSVolInfoFileCount = 0x0010
kFSVolInfoDirCount = 0x0020
kFSVolInfoSizes = 0x0040
kFSVolInfoBlocks = 0x0080
kFSVolInfoNextAlloc = 0x0100
kFSVolInfoRsrcClump = 0x0200
kFSVolInfoDataClump = 0x0400
kFSVolInfoNextID = 0x0800
kFSVolInfoFinderInfo = 0x1000
kFSVolInfoFlags = 0x2000
kFSVolInfoFSInfo = 0x4000
kFSVolInfoDriveInfo = 0x8000
kFSVolInfoGettableInfo = 0xFFFF
kFSVolInfoSettableInfo = 0x3004
kFSVolFlagDefaultVolumeBit = 5
kFSVolFlagDefaultVolumeMask = 0x0020
kFSVolFlagFilesOpenBit = 6
kFSVolFlagFilesOpenMask = 0x0040
kFSVolFlagHardwareLockedBit = 7
kFSVolFlagHardwareLockedMask = 0x0080
kFSVolFlagSoftwareLockedBit = 15
kFSVolFlagSoftwareLockedMask = 0x8000
kFNDirectoryModifiedMessage = 1

1
Mac/Lib/Carbon/Folder.py Normal file
View File

@ -0,0 +1 @@
from _Folder import *

185
Mac/Lib/Carbon/Folders.py Normal file
View File

@ -0,0 +1,185 @@
# Generated from 'Folders.h'
def FOUR_CHAR_CODE(x): return x
true = True
false = False
kOnSystemDisk = -32768L
kOnAppropriateDisk = -32767
kSystemDomain = -32766
kLocalDomain = -32765
kNetworkDomain = -32764
kUserDomain = -32763
kClassicDomain = -32762
kCreateFolder = true
kDontCreateFolder = false
kSystemFolderType = FOUR_CHAR_CODE('macs')
kDesktopFolderType = FOUR_CHAR_CODE('desk')
kSystemDesktopFolderType = FOUR_CHAR_CODE('sdsk')
kTrashFolderType = FOUR_CHAR_CODE('trsh')
kSystemTrashFolderType = FOUR_CHAR_CODE('strs')
kWhereToEmptyTrashFolderType = FOUR_CHAR_CODE('empt')
kPrintMonitorDocsFolderType = FOUR_CHAR_CODE('prnt')
kStartupFolderType = FOUR_CHAR_CODE('strt')
kShutdownFolderType = FOUR_CHAR_CODE('shdf')
kAppleMenuFolderType = FOUR_CHAR_CODE('amnu')
kControlPanelFolderType = FOUR_CHAR_CODE('ctrl')
kSystemControlPanelFolderType = FOUR_CHAR_CODE('sctl')
kExtensionFolderType = FOUR_CHAR_CODE('extn')
kFontsFolderType = FOUR_CHAR_CODE('font')
kPreferencesFolderType = FOUR_CHAR_CODE('pref')
kSystemPreferencesFolderType = FOUR_CHAR_CODE('sprf')
kTemporaryFolderType = FOUR_CHAR_CODE('temp')
kExtensionDisabledFolderType = FOUR_CHAR_CODE('extD')
kControlPanelDisabledFolderType = FOUR_CHAR_CODE('ctrD')
kSystemExtensionDisabledFolderType = FOUR_CHAR_CODE('macD')
kStartupItemsDisabledFolderType = FOUR_CHAR_CODE('strD')
kShutdownItemsDisabledFolderType = FOUR_CHAR_CODE('shdD')
kApplicationsFolderType = FOUR_CHAR_CODE('apps')
kDocumentsFolderType = FOUR_CHAR_CODE('docs')
kVolumeRootFolderType = FOUR_CHAR_CODE('root')
kChewableItemsFolderType = FOUR_CHAR_CODE('flnt')
kApplicationSupportFolderType = FOUR_CHAR_CODE('asup')
kTextEncodingsFolderType = FOUR_CHAR_CODE('\xc4tex')
kStationeryFolderType = FOUR_CHAR_CODE('odst')
kOpenDocFolderType = FOUR_CHAR_CODE('odod')
kOpenDocShellPlugInsFolderType = FOUR_CHAR_CODE('odsp')
kEditorsFolderType = FOUR_CHAR_CODE('oded')
kOpenDocEditorsFolderType = FOUR_CHAR_CODE('\xc4odf')
kOpenDocLibrariesFolderType = FOUR_CHAR_CODE('odlb')
kGenEditorsFolderType = FOUR_CHAR_CODE('\xc4edi')
kHelpFolderType = FOUR_CHAR_CODE('\xc4hlp')
kInternetPlugInFolderType = FOUR_CHAR_CODE('\xc4net')
kModemScriptsFolderType = FOUR_CHAR_CODE('\xc4mod')
kPrinterDescriptionFolderType = FOUR_CHAR_CODE('ppdf')
kPrinterDriverFolderType = FOUR_CHAR_CODE('\xc4prd')
kScriptingAdditionsFolderType = FOUR_CHAR_CODE('\xc4scr')
kSharedLibrariesFolderType = FOUR_CHAR_CODE('\xc4lib')
kVoicesFolderType = FOUR_CHAR_CODE('fvoc')
kControlStripModulesFolderType = FOUR_CHAR_CODE('sdev')
kAssistantsFolderType = FOUR_CHAR_CODE('ast\xc4')
kUtilitiesFolderType = FOUR_CHAR_CODE('uti\xc4')
kAppleExtrasFolderType = FOUR_CHAR_CODE('aex\xc4')
kContextualMenuItemsFolderType = FOUR_CHAR_CODE('cmnu')
kMacOSReadMesFolderType = FOUR_CHAR_CODE('mor\xc4')
kALMModulesFolderType = FOUR_CHAR_CODE('walk')
kALMPreferencesFolderType = FOUR_CHAR_CODE('trip')
kALMLocationsFolderType = FOUR_CHAR_CODE('fall')
kColorSyncProfilesFolderType = FOUR_CHAR_CODE('prof')
kThemesFolderType = FOUR_CHAR_CODE('thme')
kFavoritesFolderType = FOUR_CHAR_CODE('favs')
kInternetFolderType = FOUR_CHAR_CODE('int\xc4')
kAppearanceFolderType = FOUR_CHAR_CODE('appr')
kSoundSetsFolderType = FOUR_CHAR_CODE('snds')
kDesktopPicturesFolderType = FOUR_CHAR_CODE('dtp\xc4')
kInternetSearchSitesFolderType = FOUR_CHAR_CODE('issf')
kFindSupportFolderType = FOUR_CHAR_CODE('fnds')
kFindByContentFolderType = FOUR_CHAR_CODE('fbcf')
kInstallerLogsFolderType = FOUR_CHAR_CODE('ilgf')
kScriptsFolderType = FOUR_CHAR_CODE('scr\xc4')
kFolderActionsFolderType = FOUR_CHAR_CODE('fasf')
kLauncherItemsFolderType = FOUR_CHAR_CODE('laun')
kRecentApplicationsFolderType = FOUR_CHAR_CODE('rapp')
kRecentDocumentsFolderType = FOUR_CHAR_CODE('rdoc')
kRecentServersFolderType = FOUR_CHAR_CODE('rsvr')
kSpeakableItemsFolderType = FOUR_CHAR_CODE('spki')
kKeychainFolderType = FOUR_CHAR_CODE('kchn')
kQuickTimeExtensionsFolderType = FOUR_CHAR_CODE('qtex')
kDisplayExtensionsFolderType = FOUR_CHAR_CODE('dspl')
kMultiprocessingFolderType = FOUR_CHAR_CODE('mpxf')
kPrintingPlugInsFolderType = FOUR_CHAR_CODE('pplg')
kDomainTopLevelFolderType = FOUR_CHAR_CODE('dtop')
kDomainLibraryFolderType = FOUR_CHAR_CODE('dlib')
kColorSyncFolderType = FOUR_CHAR_CODE('sync')
kColorSyncCMMFolderType = FOUR_CHAR_CODE('ccmm')
kColorSyncScriptingFolderType = FOUR_CHAR_CODE('cscr')
kPrintersFolderType = FOUR_CHAR_CODE('impr')
kSpeechFolderType = FOUR_CHAR_CODE('spch')
kCarbonLibraryFolderType = FOUR_CHAR_CODE('carb')
kDocumentationFolderType = FOUR_CHAR_CODE('info')
kDeveloperDocsFolderType = FOUR_CHAR_CODE('ddoc')
kDeveloperHelpFolderType = FOUR_CHAR_CODE('devh')
kISSDownloadsFolderType = FOUR_CHAR_CODE('issd')
kUserSpecificTmpFolderType = FOUR_CHAR_CODE('utmp')
kCachedDataFolderType = FOUR_CHAR_CODE('cach')
kFrameworksFolderType = FOUR_CHAR_CODE('fram')
kPrivateFrameworksFolderType = FOUR_CHAR_CODE('pfrm')
kClassicDesktopFolderType = FOUR_CHAR_CODE('sdsk')
kDeveloperFolderType = FOUR_CHAR_CODE('devf')
kSystemSoundsFolderType = FOUR_CHAR_CODE('ssnd')
kComponentsFolderType = FOUR_CHAR_CODE('cmpd')
kQuickTimeComponentsFolderType = FOUR_CHAR_CODE('wcmp')
kCoreServicesFolderType = FOUR_CHAR_CODE('csrv')
kPictureDocumentsFolderType = FOUR_CHAR_CODE('pdoc')
kMovieDocumentsFolderType = FOUR_CHAR_CODE('mdoc')
kMusicDocumentsFolderType = FOUR_CHAR_CODE('\xb5doc')
kInternetSitesFolderType = FOUR_CHAR_CODE('site')
kPublicFolderType = FOUR_CHAR_CODE('pubb')
kAudioSupportFolderType = FOUR_CHAR_CODE('adio')
kAudioSoundsFolderType = FOUR_CHAR_CODE('asnd')
kAudioSoundBanksFolderType = FOUR_CHAR_CODE('bank')
kAudioAlertSoundsFolderType = FOUR_CHAR_CODE('alrt')
kAudioPlugInsFolderType = FOUR_CHAR_CODE('aplg')
kAudioComponentsFolderType = FOUR_CHAR_CODE('acmp')
kKernelExtensionsFolderType = FOUR_CHAR_CODE('kext')
kDirectoryServicesFolderType = FOUR_CHAR_CODE('dsrv')
kDirectoryServicesPlugInsFolderType = FOUR_CHAR_CODE('dplg')
kLocalesFolderType = FOUR_CHAR_CODE('\xc4loc')
kFindByContentPluginsFolderType = FOUR_CHAR_CODE('fbcp')
kUsersFolderType = FOUR_CHAR_CODE('usrs')
kCurrentUserFolderType = FOUR_CHAR_CODE('cusr')
kCurrentUserRemoteFolderLocation = FOUR_CHAR_CODE('rusf')
kCurrentUserRemoteFolderType = FOUR_CHAR_CODE('rusr')
kSharedUserDataFolderType = FOUR_CHAR_CODE('sdat')
kVolumeSettingsFolderType = FOUR_CHAR_CODE('vsfd')
kAppleshareAutomountServerAliasesFolderType = FOUR_CHAR_CODE('srv\xc4')
kPreMacOS91ApplicationsFolderType = FOUR_CHAR_CODE('\x8cpps')
kPreMacOS91InstallerLogsFolderType = FOUR_CHAR_CODE('\x94lgf')
kPreMacOS91AssistantsFolderType = FOUR_CHAR_CODE('\x8cst\xc4')
kPreMacOS91UtilitiesFolderType = FOUR_CHAR_CODE('\x9fti\xc4')
kPreMacOS91AppleExtrasFolderType = FOUR_CHAR_CODE('\x8cex\xc4')
kPreMacOS91MacOSReadMesFolderType = FOUR_CHAR_CODE('\xb5or\xc4')
kPreMacOS91InternetFolderType = FOUR_CHAR_CODE('\x94nt\xc4')
kPreMacOS91AutomountedServersFolderType = FOUR_CHAR_CODE('\xa7rv\xc4')
kPreMacOS91StationeryFolderType = FOUR_CHAR_CODE('\xbfdst')
kCreateFolderAtBoot = 0x00000002
kCreateFolderAtBootBit = 1
kFolderCreatedInvisible = 0x00000004
kFolderCreatedInvisibleBit = 2
kFolderCreatedNameLocked = 0x00000008
kFolderCreatedNameLockedBit = 3
kFolderCreatedAdminPrivs = 0x00000010
kFolderCreatedAdminPrivsBit = 4
kFolderInUserFolder = 0x00000020
kFolderInUserFolderBit = 5
kFolderTrackedByAlias = 0x00000040
kFolderTrackedByAliasBit = 6
kFolderInRemoteUserFolderIfAvailable = 0x00000080
kFolderInRemoteUserFolderIfAvailableBit = 7
kFolderNeverMatchedInIdentifyFolder = 0x00000100
kFolderNeverMatchedInIdentifyFolderBit = 8
kFolderMustStayOnSameVolume = 0x00000200
kFolderMustStayOnSameVolumeBit = 9
kFolderManagerFolderInMacOS9FolderIfMacOSXIsInstalledMask = 0x00000400
kFolderManagerFolderInMacOS9FolderIfMacOSXIsInstalledBit = 10
kFolderInLocalOrRemoteUserFolder = kFolderInUserFolder | kFolderInRemoteUserFolderIfAvailable
kRelativeFolder = FOUR_CHAR_CODE('relf')
kSpecialFolder = FOUR_CHAR_CODE('spcf')
kBlessedFolder = FOUR_CHAR_CODE('blsf')
kRootFolder = FOUR_CHAR_CODE('rotf')
kCurrentUserFolderLocation = FOUR_CHAR_CODE('cusf')
kFindFolderRedirectionFlagUseDistinctUserFoldersBit = 0
kFindFolderRedirectionFlagUseGivenVRefAndDirIDAsUserFolderBit = 1
kFindFolderRedirectionFlagsUseGivenVRefNumAndDirIDAsRemoteUserFolderBit = 2
kFolderManagerUserRedirectionGlobalsCurrentVersion = 1
kFindFolderExtendedFlagsDoNotFollowAliasesBit = 0
kFindFolderExtendedFlagsDoNotUseUserFolderBit = 1
kFindFolderExtendedFlagsUseOtherUserRecord = 0x01000000
kFolderManagerNotificationMessageUserLogIn = FOUR_CHAR_CODE('log+')
kFolderManagerNotificationMessagePreUserLogIn = FOUR_CHAR_CODE('logj')
kFolderManagerNotificationMessageUserLogOut = FOUR_CHAR_CODE('log-')
kFolderManagerNotificationMessagePostUserLogOut = FOUR_CHAR_CODE('logp')
kFolderManagerNotificationDiscardCachedData = FOUR_CHAR_CODE('dche')
kFolderManagerNotificationMessageLoginStartup = FOUR_CHAR_CODE('stup')
kDoNotRemoveWhenCurrentApplicationQuitsBit = 0
kDoNotRemoveWheCurrentApplicationQuitsBit = kDoNotRemoveWhenCurrentApplicationQuitsBit
kStopIfAnyNotificationProcReturnsErrorBit = 31

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
# 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 = "Files"
SHORT = "file"
OBJECT = "NOTUSED"
def main():
input = LONG + ".h"
output = SHORT + "gen.py"
defsoutput = TOOLBOXDIR + LONG + ".py"
scanner = MyScanner(input, output, defsoutput)
scanner.scan()
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
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 [
# Constants with incompatible definitions
"kioACAccessOwnerMask",
"kFSCatInfoReserved",
"kFSIterateReserved",
"FSRefMakePath", # Do this manually
"FSRead", # Couldn't be bothered
"FSWrite", # ditto
"FSReadFork", # ditto
"FSWriteFork", # ditto
# Old routines:
"GetWDInfo",
"OpenWD",
"CloseWD",
"FInitQueue",
"rstflock",
"setflock",
"setfinfo",
"fsrename",
"fsdelete",
"create",
"flushvol",
"eject",
"umountvol",
"setvol",
"getvol",
"getfinfo",
"getvinfo",
"fsopen",
"RstFLock",
"SetFLock",
"SetFInfo",
"Rename",
"OpenRF",
"FSDelete",
"Create",
"GetVol",
"GetFInfo",
"GetVInfo",
"FSOpen",
"Eject",
"SetVol",
"openrf",
"unmountvol",
"OpenDF",
]
def makeblacklisttypes(self):
return [
"CInfoPBPtr", # Old stuff
"CMovePBPtr", # Old stuff
"ParmBlkPtr", # Old stuff
"HParmBlkPtr", # Old stuff
"DTPBPtr", # Old stuff
"FCBPBPtr", # Old stuff
"QHdrPtr", # Old stuff
"CSParamPtr", # Old stuff
"FSCatalogBulkParam", # old stuff
"FSForkCBInfoParam", # old stuff
"FSForkIOParam", # old stuff
"FSRefParam", # old stuff
"FSVolumeInfoParam", # old stuff
"WDPBPtr", # old stuff
"XCInfoPBPtr", # old stuff
"XVolumeParamPtr", # old stuff
"CatPositionRec", # State variable, not too difficult
"FSCatalogInfo", # Lots of fields, difficult struct
"FSCatalogInfo_ptr", # Lots of fields, difficult struct
"FSIterator", # Should become an object
"FSForkInfo", # Lots of fields, difficult struct
"FSSearchParams", # Also catsearch stuff
"FSVolumeInfo", # big struct
"FSVolumeInfo_ptr", # big struct
"IOCompletionProcPtr", # proc pointer
"IOCompletionUPP", # Proc pointer
]
def makerepairinstructions(self):
return [
# Various ways to give pathnames
([('UInt8_ptr', 'path', 'InMode')],
[('stringptr', 'path', 'InMode')]
),
([('char_ptr', '*', 'InMode')],
[('stringptr', '*', 'InMode')]
),
# Unicode filenames passed as length, buffer
([('UniCharCount', '*', 'InMode'),
('UniChar_ptr', '*', 'InMode')],
[('UnicodeReverseInBuffer', '*', 'InMode')]
),
]
def writeinitialdefs(self):
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
self.defsfile.write("true = True\n")
self.defsfile.write("false = False\n")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,156 @@
# 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 = 'Files.h' # The Apple header file
MODNAME = '_File' # The name of the module
# The following is *usually* unchanged but may still require tuning
MODPREFIX = 'File' # 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
#ConstStrFileNameParam = ConstStr255Param
#StrFileName = Str255
#FolderClass = OSTypeType("FolderClass")
# FolderDesc
#FolderDescFlags = Type("FolderDescFlags", "l")
#FolderLocation = OSTypeType("FolderLocation")
# FolderRouting
#FolderType = OSTypeType("FolderType")
#RoutingFlags = Type("RoutingFlags", "l")
class UniCharCountBuffer(InputOnlyType):
pass
#CatPositionRec
ConstStr63Param = OpaqueArrayType("Str63", "PyMac_BuildStr255", "PyMac_GetStr255")
FInfo = OpaqueByValueStructType("FInfo", "PyMac_BuildFInfo", "PyMac_GetFInfo")
FInfo_ptr = OpaqueType("FInfo", "PyMac_BuildFInfo", "PyMac_GetFInfo")
FNMessage = Type("FNMessage", "l")
FSAllocationFlags = Type("FSAllocationFlags", "H")
#FSCatalogInfo
FSCatalogInfoBitmap = Type("FSCatalogInfoBitmap", "l")
#FSForkInfo
#FSIterator
FSIteratorFlags = Type("FSIteratorFlags", "l")
#FSVolumeInfo
FSVolumeRefNum = Type("FSVolumeRefNum", "h")
HFSUniStr255 = OpaqueType("HFSUniStr255", "PyMac_BuildHFSUniStr255", "PyMac_GetHFSUniStr255")
SInt64 = Type("SInt64", "L")
UInt64 = Type("UInt64", "L")
#UInt8_ptr
#UniCharCount
#char_ptr
#void_ptr
includestuff = includestuff + """
#ifdef WITHOUT_FRAMEWORKS
#include <Files.h>
#else
#include <Carbon/Carbon.h>
#endif
/*
** Parse/generate objsect
*/
static PyObject *
PyMac_BuildHFSUniStr255(HFSUniStr255 *itself)
{
return Py_BuildValue("u#", itself->unicode, itself->length);
}
#if 0
static int
PyMac_GetHFSUniStr255(PyObject *v, HFSUniStr255 *itself)
{
return PyArg_ParseTuple(v, "O&O&O&O&O&",
PyMac_GetFixed, &itself->ascent,
PyMac_GetFixed, &itself->descent,
PyMac_GetFixed, &itself->leading,
PyMac_GetFixed, &itself->widMax,
ResObj_Convert, &itself->wTabHandle);
}
#endif
/*
** Parse/generate objsect
*/
static PyObject *
PyMac_BuildFInfo(FInfo *itself)
{
return Py_BuildValue("O&O&HO&h",
PyMac_BuildOSType, itself->fdType,
PyMac_BuildOSType, itself->fdCreator,
itself->fdFlags,
PyMac_BuildPoint, &itself->fdLocation,
itself->fdFldr);
}
static int
PyMac_GetFInfo(PyObject *v, FInfo *itself)
{
return PyArg_ParseTuple(v, "O&O&HO&h",
PyMac_GetOSType, &itself->fdType,
PyMac_GetOSType, &itself->fdCreator,
&itself->fdFlags,
PyMac_GetPoint, &itself->fdLocation,
&itself->fdFldr);
}
"""
execfile(string.lower(MODPREFIX) + 'typetest.py')
# 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)
# Manual generators:
FSRefMakePath_body = """
OSStatus _err;
FSRef ref;
#define MAXPATHNAME 1024
UInt8 path[MAXPATHNAME];
UInt32 maxPathSize = MAXPATHNAME;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetFSRef, &ref))
return NULL;
_err = FSRefMakePath(&ref,
path,
maxPathSize);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("s", path);
return _res;
"""
f = ManualGenerator("FSRefMakePath", FSRefMakePath_body)
f.docstring = lambda: "(FSRef) -> string"
functions.append(f)
# 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()

View File

@ -0,0 +1,347 @@
/* ========================= Module _Folder ========================= */
#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 <Folders.h>
#else
#include <Carbon/Carbon.h>
#endif
static PyObject *Folder_Error;
static PyObject *Folder_FindFolder(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
OSType folderType;
Boolean createFolder;
short foundVRefNum;
long foundDirID;
if (!PyArg_ParseTuple(_args, "hO&b",
&vRefNum,
PyMac_GetOSType, &folderType,
&createFolder))
return NULL;
_err = FindFolder(vRefNum,
folderType,
createFolder,
&foundVRefNum,
&foundDirID);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("hl",
foundVRefNum,
foundDirID);
return _res;
}
static PyObject *Folder_ReleaseFolder(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
OSType folderType;
if (!PyArg_ParseTuple(_args, "hO&",
&vRefNum,
PyMac_GetOSType, &folderType))
return NULL;
_err = ReleaseFolder(vRefNum,
folderType);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_FSFindFolder(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
OSType folderType;
Boolean createFolder;
FSRef foundRef;
if (!PyArg_ParseTuple(_args, "hO&b",
&vRefNum,
PyMac_GetOSType, &folderType,
&createFolder))
return NULL;
_err = FSFindFolder(vRefNum,
folderType,
createFolder,
&foundRef);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
PyMac_BuildFSRef, &foundRef);
return _res;
}
static PyObject *Folder_AddFolderDescriptor(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
FolderType foldType;
FolderDescFlags flags;
FolderClass foldClass;
FolderLocation foldLocation;
OSType badgeSignature;
OSType badgeType;
Str255 name;
Boolean replaceFlag;
if (!PyArg_ParseTuple(_args, "O&lO&O&O&O&O&b",
PyMac_GetOSType, &foldType,
&flags,
PyMac_GetOSType, &foldClass,
PyMac_GetOSType, &foldLocation,
PyMac_GetOSType, &badgeSignature,
PyMac_GetOSType, &badgeType,
PyMac_GetStr255, name,
&replaceFlag))
return NULL;
_err = AddFolderDescriptor(foldType,
flags,
foldClass,
foldLocation,
badgeSignature,
badgeType,
name,
replaceFlag);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_GetFolderTypes(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
UInt32 requestedTypeCount;
UInt32 totalTypeCount;
FolderType theTypes;
if (!PyArg_ParseTuple(_args, "l",
&requestedTypeCount))
return NULL;
_err = GetFolderTypes(requestedTypeCount,
&totalTypeCount,
&theTypes);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("lO&",
totalTypeCount,
PyMac_BuildOSType, theTypes);
return _res;
}
static PyObject *Folder_RemoveFolderDescriptor(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
FolderType foldType;
if (!PyArg_ParseTuple(_args, "O&",
PyMac_GetOSType, &foldType))
return NULL;
_err = RemoveFolderDescriptor(foldType);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_GetFolderName(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
OSType foldType;
short foundVRefNum;
Str255 name;
if (!PyArg_ParseTuple(_args, "hO&O&",
&vRefNum,
PyMac_GetOSType, &foldType,
PyMac_GetStr255, name))
return NULL;
_err = GetFolderName(vRefNum,
foldType,
&foundVRefNum,
name);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("h",
foundVRefNum);
return _res;
}
static PyObject *Folder_AddFolderRouting(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
OSType fileType;
FolderType routeFromFolder;
FolderType routeToFolder;
RoutingFlags flags;
Boolean replaceFlag;
if (!PyArg_ParseTuple(_args, "O&O&O&lb",
PyMac_GetOSType, &fileType,
PyMac_GetOSType, &routeFromFolder,
PyMac_GetOSType, &routeToFolder,
&flags,
&replaceFlag))
return NULL;
_err = AddFolderRouting(fileType,
routeFromFolder,
routeToFolder,
flags,
replaceFlag);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_RemoveFolderRouting(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
OSType fileType;
FolderType routeFromFolder;
if (!PyArg_ParseTuple(_args, "O&O&",
PyMac_GetOSType, &fileType,
PyMac_GetOSType, &routeFromFolder))
return NULL;
_err = RemoveFolderRouting(fileType,
routeFromFolder);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_FindFolderRouting(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
OSType fileType;
FolderType routeFromFolder;
FolderType routeToFolder;
RoutingFlags flags;
if (!PyArg_ParseTuple(_args, "O&O&",
PyMac_GetOSType, &fileType,
PyMac_GetOSType, &routeFromFolder))
return NULL;
_err = FindFolderRouting(fileType,
routeFromFolder,
&routeToFolder,
&flags);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&l",
PyMac_BuildOSType, routeToFolder,
flags);
return _res;
}
static PyObject *Folder_InvalidateFolderDescriptorCache(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
long dirID;
if (!PyArg_ParseTuple(_args, "hl",
&vRefNum,
&dirID))
return NULL;
_err = InvalidateFolderDescriptorCache(vRefNum,
dirID);
if (_err != noErr) return PyMac_Error(_err);
Py_INCREF(Py_None);
_res = Py_None;
return _res;
}
static PyObject *Folder_IdentifyFolder(PyObject *_self, PyObject *_args)
{
PyObject *_res = NULL;
OSErr _err;
short vRefNum;
long dirID;
FolderType foldType;
if (!PyArg_ParseTuple(_args, "hl",
&vRefNum,
&dirID))
return NULL;
_err = IdentifyFolder(vRefNum,
dirID,
&foldType);
if (_err != noErr) return PyMac_Error(_err);
_res = Py_BuildValue("O&",
PyMac_BuildOSType, foldType);
return _res;
}
static PyMethodDef Folder_methods[] = {
{"FindFolder", (PyCFunction)Folder_FindFolder, 1,
PyDoc_STR("(short vRefNum, OSType folderType, Boolean createFolder) -> (short foundVRefNum, long foundDirID)")},
{"ReleaseFolder", (PyCFunction)Folder_ReleaseFolder, 1,
PyDoc_STR("(short vRefNum, OSType folderType) -> None")},
{"FSFindFolder", (PyCFunction)Folder_FSFindFolder, 1,
PyDoc_STR("(short vRefNum, OSType folderType, Boolean createFolder) -> (FSRef foundRef)")},
{"AddFolderDescriptor", (PyCFunction)Folder_AddFolderDescriptor, 1,
PyDoc_STR("(FolderType foldType, FolderDescFlags flags, FolderClass foldClass, FolderLocation foldLocation, OSType badgeSignature, OSType badgeType, Str255 name, Boolean replaceFlag) -> None")},
{"GetFolderTypes", (PyCFunction)Folder_GetFolderTypes, 1,
PyDoc_STR("(UInt32 requestedTypeCount) -> (UInt32 totalTypeCount, FolderType theTypes)")},
{"RemoveFolderDescriptor", (PyCFunction)Folder_RemoveFolderDescriptor, 1,
PyDoc_STR("(FolderType foldType) -> None")},
{"GetFolderName", (PyCFunction)Folder_GetFolderName, 1,
PyDoc_STR("(short vRefNum, OSType foldType, Str255 name) -> (short foundVRefNum)")},
{"AddFolderRouting", (PyCFunction)Folder_AddFolderRouting, 1,
PyDoc_STR("(OSType fileType, FolderType routeFromFolder, FolderType routeToFolder, RoutingFlags flags, Boolean replaceFlag) -> None")},
{"RemoveFolderRouting", (PyCFunction)Folder_RemoveFolderRouting, 1,
PyDoc_STR("(OSType fileType, FolderType routeFromFolder) -> None")},
{"FindFolderRouting", (PyCFunction)Folder_FindFolderRouting, 1,
PyDoc_STR("(OSType fileType, FolderType routeFromFolder) -> (FolderType routeToFolder, RoutingFlags flags)")},
{"InvalidateFolderDescriptorCache", (PyCFunction)Folder_InvalidateFolderDescriptorCache, 1,
PyDoc_STR("(short vRefNum, long dirID) -> None")},
{"IdentifyFolder", (PyCFunction)Folder_IdentifyFolder, 1,
PyDoc_STR("(short vRefNum, long dirID) -> (FolderType foldType)")},
{NULL, NULL, 0}
};
void init_Folder(void)
{
PyObject *m;
PyObject *d;
m = Py_InitModule("_Folder", Folder_methods);
d = PyModule_GetDict(m);
Folder_Error = PyMac_GetOSErrException();
if (Folder_Error == NULL ||
PyDict_SetItemString(d, "Error", Folder_Error) != 0)
return;
}
/* ======================= End module _Folder ======================= */

View File

@ -0,0 +1,68 @@
# 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 = "Folders"
SHORT = "folder"
OBJECT = "NOTUSED"
def main():
input = LONG + ".h"
output = SHORT + "gen.py"
defsoutput = TOOLBOXDIR + LONG + ".py"
scanner = MyScanner(input, output, defsoutput)
scanner.scan()
scanner.close()
scanner.gentypetest(SHORT+"typetest.py")
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 [
"FindFolderExtended", # Has funny void* argument
"FSFindFolderExtended", # ditto
"FolderManagerRegisterCallNotificationProcs", # ditto
"FindFolderEx", # Non-MacOS routine
]
def makeblacklisttypes(self):
return [
"FolderManagerNotificationProcPtr",
"FolderManagerNotificationUPP",
"FolderRouting", # To be done, not difficult
"FolderDesc", # To be done, not difficult
]
def makerepairinstructions(self):
return [
]
def writeinitialdefs(self):
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
self.defsfile.write("true = True\n")
self.defsfile.write("false = False\n")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,61 @@
# 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 = 'Folders.h' # The Apple header file
MODNAME = '_Folder' # The name of the module
# The following is *usually* unchanged but may still require tuning
MODPREFIX = 'Folder' # 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
ConstStrFileNameParam = ConstStr255Param
StrFileName = Str255
FolderClass = OSTypeType("FolderClass")
# FolderDesc
FolderDescFlags = Type("FolderDescFlags", "l")
FolderLocation = OSTypeType("FolderLocation")
# FolderRouting
FolderType = OSTypeType("FolderType")
RoutingFlags = Type("RoutingFlags", "l")
includestuff = includestuff + """
#ifdef WITHOUT_FRAMEWORKS
#include <Folders.h>
#else
#include <Carbon/Carbon.h>
#endif
"""
execfile(string.lower(MODPREFIX) + 'typetest.py')
# 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()

View File

@ -745,6 +745,10 @@ class PyBuildExt(build_ext):
extra_link_args=['-framework', 'Carbon']) )
exts.append( Extension('_Evt', ['evt/_Evtmodule.c'],
extra_link_args=['-framework', 'Carbon']) )
exts.append( Extension('_File', ['file/_Filemodule.c'],
extra_link_args=['-framework', 'Carbon']) )
exts.append( Extension('_Folder', ['folder/_Foldermodule.c'],
extra_link_args=['-framework', 'Carbon']) )
exts.append( Extension('_Fm', ['fm/_Fmmodule.c'],
extra_link_args=['-framework', 'Carbon']) )
exts.append( Extension('_Help', ['help/_Helpmodule.c'],