how to access OpenDirectory C constants from MacRuby?
Hi All, I'm trying to use MacRuby (0.5) to poke at OpenDirectory, but can't figure out how to get the ruby environment to see constants defined in the CFOpenDirectory subframework of the OpenDirectory framework. http://gist.github.com/358599 is a simple case of what I can't work out. Constants like ODSessionProxyAddress are visible when I'm opening a connection to a remote OD server, but the kSomeConstant ones aren't available under their obj-c or capitalised-K versions (as vaguely implied in http://www.macruby.org/recipes/embed-a-custom-font.html). The bridgesupport files in OpenDirectory.framework also don't contain entries for these constants. Is there some way of getting access to these constants, or do I need to find and use their literal values instead? cheers Russell
On 07/04/2010, at 4:48 PM, russell muetzelfeldt wrote:
Is there some way of getting access to these constants, or do I need to find and use their literal values instead?
On further investigation it looks like just defining the constants in ruby myself will do. Some of them exist in CFOpenDirectoryConstants.h as enum items which I can easily enough pull across, but others are defined like this - /*! @const kODRecordTypeUsers @abstract Identifies user records. @discussion Identifies user records. */ CF_EXPORT const ODRecordType kODRecordTypeUsers; which I assume is a CF_EXPORT macro doing some preprocessor magic to fill in a value for kODRecordTypeUsers... does anyone know how to work out the actual value of this constant (and others defined in the same way)? cheers Russell
On 07/04/2010, at 5:56 PM, russell muetzelfeldt wrote:
/*! @const kODRecordTypeUsers @abstract Identifies user records. @discussion Identifies user records. */ CF_EXPORT const ODRecordType kODRecordTypeUsers;
which I assume is a CF_EXPORT macro doing some preprocessor magic to fill in a value for kODRecordTypeUsers... does anyone know how to work out the actual value of this constant (and others defined in the same way)?
turns out these items aren't actually constants but are rather static variables defined in the framework dylib objects - for example, kODAttributeTypeUniqueID is actually an NSString pointer referencing a static @"dsAttrTypeStandard:UniqueID" in CFOpenDirectory.framework/Versions/A/CFOpenDirectory is there any way in MacRuby to access these variables defined in a loaded framework? cheers Russell
Hi Russell, Sorry for the late response. OpenDirectory.framework ships with BridgeSupport annotations, so doing "framework 'OpenDirectory'" should merge all symbols into MacRuby. If some are missing, it's likely a bug in the BridgeSupport generator, that should be reported via http://bugreport.apple.com. Fortunately, we are working on a new BridgeSupport generator which might already fix this issue, but it's not ready yet for prime time. In the meantime I recommend to wrap the symbols/APIs you need inside an Objective-C class and call it from MacRuby. Laurent On Apr 7, 2010, at 6:32 PM, russell muetzelfeldt wrote:
On 07/04/2010, at 5:56 PM, russell muetzelfeldt wrote:
/*! @const kODRecordTypeUsers @abstract Identifies user records. @discussion Identifies user records. */ CF_EXPORT const ODRecordType kODRecordTypeUsers;
which I assume is a CF_EXPORT macro doing some preprocessor magic to fill in a value for kODRecordTypeUsers... does anyone know how to work out the actual value of this constant (and others defined in the same way)?
turns out these items aren't actually constants but are rather static variables defined in the framework dylib objects - for example, kODAttributeTypeUniqueID is actually an NSString pointer referencing a static @"dsAttrTypeStandard:UniqueID" in CFOpenDirectory.framework/Versions/A/CFOpenDirectory
is there any way in MacRuby to access these variables defined in a loaded framework?
cheers
Russell
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (2)
-
Laurent Sansonetti
-
russell muetzelfeldt