The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Undocumented Macro DATA_PTR

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Red Handed

Posts: 1158
Nickname: redhanded
Registered: Dec, 2004

Red Handed is a Ruby-focused group blog.
Undocumented Macro DATA_PTR Posted: Feb 9, 2005 9:51 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Red Handed.
Original Post: Undocumented Macro DATA_PTR
Feed Title: RedHanded
Feed URL: http://redhanded.hobix.com/index.xml
Feed Description: sneaking Ruby through the system
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Red Handed
Latest Posts From RedHanded

Advertisement

I’ve really got to remember this one. Tim Hunter on ruby-talk brought up this macro for replacing the pointer associated with a Ruby VALUE. Available since 1.7.

 VALUE my_obj;
 MyStruct my_struct;

 my_struct = ALLOC(MyStruct);
 DATA_PTR(my_obj) = my_struct;

Use this after initially assigning a pointer with Data_Wrap_Struct or Data_Make_Struct. Which means the same free and mark function pointers will still apply.

Note: While the DATA_PTR macro isn’t touched in the PickAxe II, I’ve found its coverage of the Ruby API to be indispensable. Nuances such as proper use of StringValue and the difference between 1.6 and 1.8 object allocation are essential.

Read: Undocumented Macro DATA_PTR

Topic: ruby2c 1.0.0 beta 1 is released Previous Topic   Next Topic Topic: Snowdevil: First e-tailer on Rails

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use