Merge branch 'master' of git://repo.or.cz/factor/jcg
commit
6d7a41a1b5
|
@ -62,6 +62,7 @@ SYMBOL: super-sent-messages
|
|||
"NSResponder"
|
||||
"NSSavePanel"
|
||||
"NSScreen"
|
||||
"NSString"
|
||||
"NSView"
|
||||
"NSWindow"
|
||||
"NSWorkspace"
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
USING: kernel cocoa cocoa.types alien.c-types locals math sequences
|
||||
vectors fry ;
|
||||
IN: cocoa.enumeration
|
||||
|
||||
: NS-EACH-BUFFER-SIZE 16 ; inline
|
||||
|
||||
: (allocate-enumeration-buffers) ( -- state stackbuf count )
|
||||
"NSFastEnumerationState" <c-object>
|
||||
NS-EACH-BUFFER-SIZE "id" <c-array>
|
||||
NS-EACH-BUFFER-SIZE ;
|
||||
|
||||
:: (NSFastEnumeration-each) ( object quot state stackbuf count -- )
|
||||
object state stackbuf count -> countByEnumeratingWithState:objects:count:
|
||||
dup zero? [ drop ] [
|
||||
[ stackbuf void*-nth quot call ] each
|
||||
object quot state stackbuf count (NSFastEnumeration-each)
|
||||
] if ; inline
|
||||
|
||||
: NSFastEnumeration-each ( object quot -- )
|
||||
(allocate-enumeration-buffers) (NSFastEnumeration-each) ; inline
|
||||
|
||||
: NSFastEnumeration-map ( object quot -- vector )
|
||||
NS-EACH-BUFFER-SIZE <vector> [ '[ @ , push ] NSFastEnumeration-each ] keep ; inline
|
||||
|
||||
: NSFastEnumeration>vector ( object -- vector )
|
||||
[ ] NSFastEnumeration-map ;
|
|
@ -64,3 +64,9 @@ C-STRUCT: CGAffineTransform
|
|||
{ "float" "d" }
|
||||
{ "float" "tx" }
|
||||
{ "float" "ty" } ;
|
||||
|
||||
C-STRUCT: NSFastEnumerationState
|
||||
{ "ulong" "state" }
|
||||
{ "id*" "itemsPtr" }
|
||||
{ "ulong*" "mutationsPtr" }
|
||||
{ "ulong[5]" "extra" } ;
|
||||
|
|
|
@ -24,7 +24,8 @@ FUNCTION: void CFArraySetValueAtIndex ( CFArrayRef array, CFIndex index, void* v
|
|||
|
||||
FUNCTION: CFIndex CFArrayGetCount ( CFArrayRef array ) ;
|
||||
|
||||
: kCFURLPOSIXPathStyle 0 ;
|
||||
: kCFURLPOSIXPathStyle 0 ; inline
|
||||
: kCFAllocatorDefault f ; inline
|
||||
|
||||
FUNCTION: CFURLRef CFURLCreateWithFileSystemPath ( CFAllocatorRef allocator, CFStringRef filePath, int pathStyle, Boolean isDirectory ) ;
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Joe Groff
|
|
@ -0,0 +1,114 @@
|
|||
USING: iokit alien.syntax alien.c-types kernel system ;
|
||||
IN: iokit.hid
|
||||
|
||||
: kIOHIDDeviceKey "IOHIDDevice" ; inline
|
||||
|
||||
: kIOHIDTransportKey "Transport" ; inline
|
||||
: kIOHIDVendorIDKey "VendorID" ; inline
|
||||
: kIOHIDVendorIDSourceKey "VendorIDSource" ; inline
|
||||
: kIOHIDProductIDKey "ProductID" ; inline
|
||||
: kIOHIDVersionNumberKey "VersionNumber" ; inline
|
||||
: kIOHIDManufacturerKey "Manufacturer" ; inline
|
||||
: kIOHIDProductKey "Product" ; inline
|
||||
: kIOHIDSerialNumberKey "SerialNumber" ; inline
|
||||
: kIOHIDCountryCodeKey "CountryCode" ; inline
|
||||
: kIOHIDLocationIDKey "LocationID" ; inline
|
||||
: kIOHIDDeviceUsageKey "DeviceUsage" ; inline
|
||||
: kIOHIDDeviceUsagePageKey "DeviceUsagePage" ; inline
|
||||
: kIOHIDDeviceUsagePairsKey "DeviceUsagePairs" ; inline
|
||||
: kIOHIDPrimaryUsageKey "PrimaryUsage" ; inline
|
||||
: kIOHIDPrimaryUsagePageKey "PrimaryUsagePage" ; inline
|
||||
: kIOHIDMaxInputReportSizeKey "MaxInputReportSize" ; inline
|
||||
: kIOHIDMaxOutputReportSizeKey "MaxOutputReportSize" ; inline
|
||||
: kIOHIDMaxFeatureReportSizeKey "MaxFeatureReportSize" ; inline
|
||||
: kIOHIDReportIntervalKey "ReportInterval" ; inline
|
||||
|
||||
: kIOHIDElementKey "Elements" ; inline
|
||||
|
||||
: kIOHIDElementCookieKey "ElementCookie" ; inline
|
||||
: kIOHIDElementTypeKey "Type" ; inline
|
||||
: kIOHIDElementCollectionTypeKey "CollectionType" ; inline
|
||||
: kIOHIDElementUsageKey "Usage" ; inline
|
||||
: kIOHIDElementUsagePageKey "UsagePage" ; inline
|
||||
: kIOHIDElementMinKey "Min" ; inline
|
||||
: kIOHIDElementMaxKey "Max" ; inline
|
||||
: kIOHIDElementScaledMinKey "ScaledMin" ; inline
|
||||
: kIOHIDElementScaledMaxKey "ScaledMax" ; inline
|
||||
: kIOHIDElementSizeKey "Size" ; inline
|
||||
: kIOHIDElementReportSizeKey "ReportSize" ; inline
|
||||
: kIOHIDElementReportCountKey "ReportCount" ; inline
|
||||
: kIOHIDElementReportIDKey "ReportID" ; inline
|
||||
: kIOHIDElementIsArrayKey "IsArray" ; inline
|
||||
: kIOHIDElementIsRelativeKey "IsRelative" ; inline
|
||||
: kIOHIDElementIsWrappingKey "IsWrapping" ; inline
|
||||
: kIOHIDElementIsNonLinearKey "IsNonLinear" ; inline
|
||||
: kIOHIDElementHasPreferredStateKey "HasPreferredState" ; inline
|
||||
: kIOHIDElementHasNullStateKey "HasNullState" ; inline
|
||||
: kIOHIDElementFlagsKey "Flags" ; inline
|
||||
: kIOHIDElementUnitKey "Unit" ; inline
|
||||
: kIOHIDElementUnitExponentKey "UnitExponent" ; inline
|
||||
: kIOHIDElementNameKey "Name" ; inline
|
||||
: kIOHIDElementValueLocationKey "ValueLocation" ; inline
|
||||
: kIOHIDElementDuplicateIndexKey "DuplicateIndex" ; inline
|
||||
: kIOHIDElementParentCollectionKey "ParentCollection" ; inline
|
||||
|
||||
: kIOHIDElementVendorSpecificKey
|
||||
cpu ppc? "VendorSpecifc" "VendorSpecific" ? ; inline
|
||||
|
||||
: kIOHIDElementCookieMinKey "ElementCookieMin" ; inline
|
||||
: kIOHIDElementCookieMaxKey "ElementCookieMax" ; inline
|
||||
: kIOHIDElementUsageMinKey "UsageMin" ; inline
|
||||
: kIOHIDElementUsageMaxKey "UsageMax" ; inline
|
||||
|
||||
: kIOHIDElementCalibrationMinKey "CalibrationMin" ; inline
|
||||
: kIOHIDElementCalibrationMaxKey "CalibrationMax" ; inline
|
||||
: kIOHIDElementCalibrationSaturationMinKey "CalibrationSaturationMin" ; inline
|
||||
: kIOHIDElementCalibrationSaturationMaxKey "CalibrationSaturationMax" ; inline
|
||||
: kIOHIDElementCalibrationDeadZoneMinKey "CalibrationDeadZoneMin" ; inline
|
||||
: kIOHIDElementCalibrationDeadZoneMaxKey "CalibrationDeadZoneMax" ; inline
|
||||
: kIOHIDElementCalibrationGranularityKey "CalibrationGranularity" ; inline
|
||||
|
||||
TYPEDEF: ptrdiff_t IOHIDElementCookie
|
||||
TYPEDEF: int IOHIDElementType
|
||||
TYPEDEF: int IOHIDElementCollectionType
|
||||
TYPEDEF: int IOHIDReportType
|
||||
TYPEDEF: uint IOHIDOptionsType
|
||||
TYPEDEF: uint IOHIDQueueOptionsType
|
||||
TYPEDEF: uint IOHIDElementFlags
|
||||
|
||||
: kIOHIDElementTypeInput_Misc 1 ; inline
|
||||
: kIOHIDElementTypeInput_Button 2 ; inline
|
||||
: kIOHIDElementTypeInput_Axis 3 ; inline
|
||||
: kIOHIDElementTypeInput_ScanCodes 4 ; inline
|
||||
: kIOHIDElementTypeOutput 129 ; inline
|
||||
: kIOHIDElementTypeFeature 257 ; inline
|
||||
: kIOHIDElementTypeCollection 513 ; inline
|
||||
|
||||
: kIOHIDElementCollectionTypePhysical HEX: 00 ; inline
|
||||
: kIOHIDElementCollectionTypeApplication HEX: 01 ; inline
|
||||
: kIOHIDElementCollectionTypeLogical HEX: 02 ; inline
|
||||
: kIOHIDElementCollectionTypeReport HEX: 03 ; inline
|
||||
: kIOHIDElementCollectionTypeNamedArray HEX: 04 ; inline
|
||||
: kIOHIDElementCollectionTypeUsageSwitch HEX: 05 ; inline
|
||||
: kIOHIDElementCollectionTypeUsageModifier HEX: 06 ; inline
|
||||
|
||||
: kIOHIDReportTypeInput 0 ; inline
|
||||
: kIOHIDReportTypeOutput 1 ; inline
|
||||
: kIOHIDReportTypeFeature 2 ; inline
|
||||
: kIOHIDReportTypeCount 3 ; inline
|
||||
|
||||
: kIOHIDOptionsTypeNone HEX: 00 ; inline
|
||||
: kIOHIDOptionsTypeSeizeDevice HEX: 01 ; inline
|
||||
|
||||
: kIOHIDQueueOptionsTypeNone HEX: 00 ; inline
|
||||
: kIOHIDQueueOptionsTypeEnqueueAll HEX: 01 ; inline
|
||||
|
||||
: kIOHIDElementFlagsConstantMask HEX: 0001 ; inline
|
||||
: kIOHIDElementFlagsVariableMask HEX: 0002 ; inline
|
||||
: kIOHIDElementFlagsRelativeMask HEX: 0004 ; inline
|
||||
: kIOHIDElementFlagsWrapMask HEX: 0008 ; inline
|
||||
: kIOHIDElementFlagsNonLinearMask HEX: 0010 ; inline
|
||||
: kIOHIDElementFlagsNoPreferredMask HEX: 0020 ; inline
|
||||
: kIOHIDElementFlagsNullStateMask HEX: 0040 ; inline
|
||||
: kIOHIDElementFlagsVolativeMask HEX: 0080 ; inline
|
||||
: kIOHIDElementFlagsBufferedByteMask HEX: 0100 ; inline
|
|
@ -0,0 +1,178 @@
|
|||
USING: alien.syntax alien.c-types cocoa core-foundation system
|
||||
combinators kernel sequences debugger io accessors ;
|
||||
IN: iokit
|
||||
|
||||
<< {
|
||||
{ [ os macosx? ] [ "/System/Library/Frameworks/IOKit.framework" load-framework ] }
|
||||
[ "IOKit only supported on Mac OS X" ]
|
||||
} cond >>
|
||||
|
||||
: kIOKitBuildVersionKey "IOKitBuildVersion" ; inline
|
||||
: kIOKitDiagnosticsKey "IOKitDiagnostics" ; inline
|
||||
|
||||
: kIORegistryPlanesKey "IORegistryPlanes" ; inline
|
||||
: kIOCatalogueKey "IOCatalogue" ; inline
|
||||
|
||||
: kIOServicePlane "IOService" ; inline
|
||||
: kIOPowerPlane "IOPower" ; inline
|
||||
: kIODeviceTreePlane "IODeviceTree" ; inline
|
||||
: kIOAudioPlane "IOAudio" ; inline
|
||||
: kIOFireWirePlane "IOFireWire" ; inline
|
||||
: kIOUSBPlane "IOUSB" ; inline
|
||||
|
||||
: kIOServiceClass "IOService" ; inline
|
||||
|
||||
: kIOResourcesClass "IOResources" ; inline
|
||||
|
||||
: kIOClassKey "IOClass" ; inline
|
||||
: kIOProbeScoreKey "IOProbeScore" ; inline
|
||||
: kIOKitDebugKey "IOKitDebug" ; inline
|
||||
|
||||
: kIOProviderClassKey "IOProviderClass" ; inline
|
||||
: kIONameMatchKey "IONameMatch" ; inline
|
||||
: kIOPropertyMatchKey "IOPropertyMatch" ; inline
|
||||
: kIOPathMatchKey "IOPathMatch" ; inline
|
||||
: kIOLocationMatchKey "IOLocationMatch" ; inline
|
||||
: kIOParentMatchKey "IOParentMatch" ; inline
|
||||
: kIOResourceMatchKey "IOResourceMatch" ; inline
|
||||
: kIOMatchedServiceCountKey "IOMatchedServiceCountMatch" ; inline
|
||||
|
||||
: kIONameMatchedKey "IONameMatched" ; inline
|
||||
|
||||
: kIOMatchCategoryKey "IOMatchCategory" ; inline
|
||||
: kIODefaultMatchCategoryKey "IODefaultMatchCategory" ; inline
|
||||
|
||||
: kIOUserClientClassKey "IOUserClientClass" ; inline
|
||||
|
||||
: kIOUserClientCrossEndianKey "IOUserClientCrossEndian" ; inline
|
||||
: kIOUserClientCrossEndianCompatibleKey "IOUserClientCrossEndianCompatible" ; inline
|
||||
: kIOUserClientSharedInstanceKey "IOUserClientSharedInstance" ; inline
|
||||
|
||||
: kIOPublishNotification "IOServicePublish" ; inline
|
||||
: kIOFirstPublishNotification "IOServiceFirstPublish" ; inline
|
||||
: kIOMatchedNotification "IOServiceMatched" ; inline
|
||||
: kIOFirstMatchNotification "IOServiceFirstMatch" ; inline
|
||||
: kIOTerminatedNotification "IOServiceTerminate" ; inline
|
||||
|
||||
: kIOGeneralInterest "IOGeneralInterest" ; inline
|
||||
: kIOBusyInterest "IOBusyInterest" ; inline
|
||||
: kIOAppPowerStateInterest "IOAppPowerStateInterest" ; inline
|
||||
: kIOPriorityPowerStateInterest "IOPriorityPowerStateInterest" ; inline
|
||||
|
||||
: kIOPlatformDeviceMessageKey "IOPlatformDeviceMessage" ; inline
|
||||
|
||||
: kIOCFPlugInTypesKey "IOCFPlugInTypes" ; inline
|
||||
|
||||
: kIOCommandPoolSizeKey "IOCommandPoolSize" ; inline
|
||||
|
||||
: kIOMaximumBlockCountReadKey "IOMaximumBlockCountRead" ; inline
|
||||
: kIOMaximumBlockCountWriteKey "IOMaximumBlockCountWrite" ; inline
|
||||
: kIOMaximumByteCountReadKey "IOMaximumByteCountRead" ; inline
|
||||
: kIOMaximumByteCountWriteKey "IOMaximumByteCountWrite" ; inline
|
||||
: kIOMaximumSegmentCountReadKey "IOMaximumSegmentCountRead" ; inline
|
||||
: kIOMaximumSegmentCountWriteKey "IOMaximumSegmentCountWrite" ; inline
|
||||
: kIOMaximumSegmentByteCountReadKey "IOMaximumSegmentByteCountRead" ; inline
|
||||
: kIOMaximumSegmentByteCountWriteKey "IOMaximumSegmentByteCountWrite" ; inline
|
||||
: kIOMinimumSegmentAlignmentByteCountKey "IOMinimumSegmentAlignmentByteCount" ; inline
|
||||
: kIOMaximumSegmentAddressableBitCountKey "IOMaximumSegmentAddressableBitCount" ; inline
|
||||
|
||||
: kIOIconKey "IOIcon" ; inline
|
||||
: kIOBundleResourceFileKey "IOBundleResourceFile" ; inline
|
||||
|
||||
: kIOBusBadgeKey "IOBusBadge" ; inline
|
||||
: kIODeviceIconKey "IODeviceIcon" ; inline
|
||||
|
||||
: kIOPlatformSerialNumberKey "IOPlatformSerialNumber" ; inline
|
||||
|
||||
: kIOPlatformUUIDKey "IOPlatformUUID" ; inline
|
||||
|
||||
: kIONVRAMDeletePropertyKey "IONVRAM-DELETE-PROPERTY" ; inline
|
||||
: kIODTNVRAMPanicInfoKey "aapl,panic-info" ; inline
|
||||
|
||||
: kIOBootDeviceKey "IOBootDevice" ; inline
|
||||
: kIOBootDevicePathKey "IOBootDevicePath" ; inline
|
||||
: kIOBootDeviceSizeKey "IOBootDeviceSize" ; inline
|
||||
|
||||
: kOSBuildVersionKey "OS Build Version" ; inline
|
||||
|
||||
: kNilOptions 0 ; inline
|
||||
|
||||
TYPEDEF: uint mach_port_t
|
||||
TYPEDEF: int kern_return_t
|
||||
TYPEDEF: int boolean_t
|
||||
TYPEDEF: mach_port_t io_object_t
|
||||
TYPEDEF: io_object_t io_iterator_t
|
||||
TYPEDEF: io_object_t io_registry_entry_t
|
||||
TYPEDEF: char[128] io_name_t
|
||||
TYPEDEF: char[512] io_string_t
|
||||
|
||||
TYPEDEF: uint IOOptionBits
|
||||
|
||||
: MACH_PORT_NULL 0 ; inline
|
||||
: KERN_SUCCESS 0 ; inline
|
||||
|
||||
FUNCTION: kern_return_t IOMasterPort ( mach_port_t bootstrap, mach_port_t* master ) ;
|
||||
|
||||
FUNCTION: NSDictionary* IOServiceMatching ( char* name ) ;
|
||||
FUNCTION: NSDictionary* IOServiceNameMatching ( char* name ) ;
|
||||
FUNCTION: NSDictionary* IOBSDNameMatching ( char* name ) ;
|
||||
|
||||
FUNCTION: kern_return_t IOObjectRetain ( io_object_t o ) ;
|
||||
FUNCTION: kern_return_t IOObjectRelease ( io_object_t o ) ;
|
||||
|
||||
FUNCTION: kern_return_t IOServiceGetMatchingServices ( mach_port_t master, NSDictionary* matchingDict, io_iterator_t* iterator ) ;
|
||||
|
||||
FUNCTION: io_object_t IOIteratorNext ( io_iterator_t i ) ;
|
||||
FUNCTION: void IOIteratorReset ( io_iterator_t i ) ;
|
||||
FUNCTION: boolean_t IOIteratorIsValid ( io_iterator_t i ) ;
|
||||
|
||||
FUNCTION: kern_return_t IORegistryEntryGetPath ( io_registry_entry_t entry, io_name_t plane, io_string_t path ) ;
|
||||
|
||||
FUNCTION: kern_return_t IORegistryEntryCreateCFProperties ( io_registry_entry_t entry, NSMutableDictionary** properties, CFAllocatorRef allocator, IOOptionBits options ) ;
|
||||
|
||||
FUNCTION: char* mach_error_string ( kern_return_t error ) ;
|
||||
|
||||
TUPLE: mach-error error-code ;
|
||||
C: <mach-error> mach-error
|
||||
|
||||
M: mach-error error.
|
||||
"IOKit call failed: " print error-code>> mach_error_string print ;
|
||||
|
||||
: mach-error ( return -- )
|
||||
dup KERN_SUCCESS = [ drop ] [ <mach-error> throw ] if ;
|
||||
|
||||
: master-port ( -- port )
|
||||
MACH_PORT_NULL 0 <uint> [ IOMasterPort mach-error ] keep *uint ;
|
||||
|
||||
: io-services-matching-dictionary ( nsdictionary -- iterator )
|
||||
master-port swap 0 <uint>
|
||||
[ IOServiceGetMatchingServices mach-error ] keep
|
||||
*uint ;
|
||||
|
||||
: io-services-matching-service ( service -- iterator )
|
||||
IOServiceMatching io-services-matching-dictionary ;
|
||||
: io-services-matching-service-name ( service-name -- iterator )
|
||||
IOServiceNameMatching io-services-matching-dictionary ;
|
||||
: io-services-matching-bsd-name ( bsd-name -- iterator )
|
||||
IOBSDNameMatching io-services-matching-dictionary ;
|
||||
|
||||
: retain-io-object ( o -- o )
|
||||
[ IOObjectRetain mach-error ] keep ;
|
||||
: release-io-object ( o -- )
|
||||
IOObjectRelease mach-error ;
|
||||
|
||||
: io-objects-from-iterator* ( i -- i array )
|
||||
[ dup IOIteratorNext dup MACH_PORT_NULL = not ]
|
||||
[ ]
|
||||
[ drop ] produce ;
|
||||
|
||||
: io-objects-from-iterator ( i -- array )
|
||||
io-objects-from-iterator* [ release-io-object ] dip ;
|
||||
|
||||
: properties-from-io-object ( o -- o nsdictionary )
|
||||
dup f <void*> [
|
||||
kCFAllocatorDefault kNilOptions
|
||||
IORegistryEntryCreateCFProperties mach-error
|
||||
]
|
||||
keep *void* ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
Bindings to Apple IOKit device interface
|
|
@ -0,0 +1,3 @@
|
|||
mac
|
||||
bindings
|
||||
system
|
Loading…
Reference in New Issue