Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [RubyCocoa] C pointers, and documentation

Reply
Thread Tools

[RubyCocoa] C pointers, and documentation

 
 
Christophe Mckeon
Guest
Posts: n/a
 
      12-17-2008
hi,

how are C pointers handled on the rubycocoa side?
for example a method like the following:

- (BOOL)validateValueid *)ioValue
forKeyNSString *)key
errorNSError **)outError

is there a standard way of handling it? is this
kind of thing documented anywhere?

thanks for any tips,
_c
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Brian Marick
Guest
Posts: n/a
 
      12-18-2008

On Dec 17, 2008, at 12:13 PM, Christophe Mckeon wrote:
> errorNSError **)outError
>
> is there a standard way of handling it? is this
> kind of thing documented anywhere?


There's a class called ObjcPtr that's used to translate to/from such
arguments. Google around for that word and you'll find sketchy
documentation. Here's an example of stuffing a value into such an
"out" parameter:

def getObjectValue_forString_errorDescription(objptr, s, errdesc)
case s.to_ruby.downcase
when 'yes': objptr.assign(true)
when 'no': objptr.assign(false)
else return false
end
true
end

To pull an object out of a pointer-to-object, you do this:

def observeValueForKeyPath_ofObject_change_context(
keyPath, object, change, rawContext)
context = rawContext.cast_as('@')
puts "Context: #{context.inspect}"
end

The '@' identifies the thing-being-pointed-to as an object. There are
other symbols to identify things like raw machine integers, etc. I
forget where you find them, but they're not RubyCocoa-specific, so
they're somewhere in Apple documentation.

For non-objects there are also methods like "int_at", "bool_at",
"bool", and "int". I haven't had reason to use them yet, so I don't
know the details.

-----
Brian Marick, independent consultant
Mostly on agile methods with a testing slant
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick

-----
Brian Marick, independent consultant
Mostly on agile methods with a testing slant
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Buffering of sys.stdout and sys.stderr in python3 (and documentation) Geoff Bache Python 4 11-12-2013 05:53 AM
converting XSD documentation to HTML documentation kev.sully@gmail.com XML 1 09-16-2006 12:09 PM
XML Documentation and Web References Ryan Columbus ASP .Net 0 11-16-2004 09:55 PM
Python documentation: How about structured documentation? Looking for comments/suggestions Kenneth McDonald Python 2 05-06-2004 04:11 AM
Principles of documentation (was: Python Documentation Blows!) Cameron Laird Python 1 04-03-2004 06:54 PM



Advertisments