<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: Setting and getting attributes</title>
		<atom:link href="http://cycling74.com/forums/topic/setting-and-getting-attributes/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/setting-and-getting-attributes/feed</link>
		<description></description>
		<pubDate>Thu, 20 Jun 2013 02:16:01 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/setting-and-getting-attributes/#post-35327</guid>
					<title><![CDATA[Setting and getting attributes]]></title>
					<link>http://cycling74.com/forums/topic/setting-and-getting-attributes/#post-35327</link>
					<pubDate>Fri, 11 Jan 2008 22:58:27 +0000</pubDate>
					<dc:creator>Luigi Castelli</dc:creator>

					<description>
						<![CDATA[
						<p>Hi there,</p>
<p>I have a data structure as follows:</p>
<p>typedef struct myData {<br />
     UInt32 a;<br />
     UInt32 b;<br />
     UInt32 c;<br />
} myData;</p>
<p>
typedef struct _myobj {<br />
    t_object   ob;<br />
    void        *obex;<br />
    void        *out;<br />
    myData   *data;<br />
} t_myobj;</p>
<p>Now I want to create attributes to get and set a, b and c.</p>
<p>So, clearly, all three will have a custom set and get method, however I am confused, because obviously the typical way of doing it in this case doesn&#8217;t work:</p>
<p>attr = attr_offset_new(&#8220;a&#8221;, _sym_long, attrflags, (method)myobj_a_get, (method)myobj_a_set, calcoffset(t_continuum, a));<br />
class_addattr(c, attr);</p>
<p>So, what&#8217;s the correct form to declare the attributes in this case ?</p>
<p>Thanks.</p>
<p>- Luigi</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
 THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.  ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED.  IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT <a href="mailto:SUPERBIGIO@YAHOO.COM">SUPERBIGIO@YAHOO.COM</a> AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC 1-207.<br />
 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>Looking for last minute shopping deals?  <br />
Find them fast with Yahoo! Search.  <a href="http://tools.search.yahoo.com/newsearch/category.php?category=shopping" rel="nofollow">http://tools.search.yahoo.com/newsearch/category.php?category=shopping</a></p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/setting-and-getting-attributes/#post-120292</guid>
					<title><![CDATA[Re: Setting and getting attributes]]></title>
					<link>http://cycling74.com/forums/topic/setting-and-getting-attributes/#post-120292</link>
					<pubDate>Sat, 12 Jan 2008 18:09:06 +0000</pubDate>
					<dc:creator>Joshua Kit Clayton</dc:creator>

					<description>
						<![CDATA[
						<p>
On Jan 11, 2008, at 2:58 PM, Luigi Castelli wrote:</p>
<p>> So, clearly, all three will have a custom set and get method,  <br />
> however I am confused, because obviously the typical way of doing  <br />
> it in this case doesn&#8217;t work:<br />
><br />
> attr = attr_offset_new(&#8220;a&#8221;, _sym_long, attrflags, (method) <br />
> myobj_a_get, (method)myobj_a_set, calcoffset(t_continuum, a));<br />
> class_addattr(c, attr);<br />
><br />
> So, what&#8217;s the correct form to declare the attributes in this case ?</p>
<p>
Just give an offset of zero. This is ignored if you have both custom  <br />
getter and setter&#8211;i.e.</p>
<p>attr = attr_offset_new(&#8220;a&#8221;, _sym_long, attrflags, (method) <br />
myobj_a_get, (method)myobj_a_set, 0);</p>
<p>
Alternately, you could avoid allocating your &#8220;myData&#8221; struct and  <br />
simply embed in your object, which would permit default accessors&#8211; i.e.</p>
<p>typedef struct _myobj {<br />
     t_object   ob;<br />
     void        *obex;<br />
     void        *out;<br />
     myData   data; 	// embed, not a pointer<br />
} t_myobj;</p>
<p>// notice the data.a notation to use embedded structs.<br />
attr = attr_offset_new(&#8220;a&#8221;, _sym_long, attrflags, (method)NULL,  <br />
(method)NULL, calcoffset(t_myobj, data.a));</p>
<p>
-Joshua</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

