update
[sdlgit/SDL-Site.git] / pages / blog-0023.html-inc
CommitLineData
ec946b6b 1<div class="blog">
2<h1 id="NAME">
56d4907c 3Design of SDL::Rect
ec946b6b 4</h1>
5<div class="CONTENT">
56d4907c 6<div style="text-align: right;"><i><br />
7you say things,<br />
8I hear,<br />
9but don't listen,<br />
10<br />
11you show things,<br />
12I see,<br />
13but don't understand,<br />
14<br />
15you write things,<br />
16I read,<br />
17but don't know.<br />
18</i></div><br />
19Lately we have been working on cleaning up the XS name spaces of SDL perl. After some bumps and falls we came up with a separated Rect module. Rect is one of the most simple C struct as shown below. <br />
20<br />
21<script src="http://gist.github.com/185940.js">
22</script><br />
23<br />
24Using the awesome <a href="http://cpansearch.perl.org/src/DMR/CookBookB-19960430/perlobject.map">perlobject.map</a> as a reference I was able to create a <a href="http://github.com/kthakore/SDL_perl/blob/a1b835c168ec184abc01edbc01862ffa15624c26/lib/SDL/Rect.pm">blessed perl</a> object in <a href="http://github.com/kthakore/SDL_perl/blob/a1b835c168ec184abc01edbc01862ffa15624c26/src/Rect.xs">XS</a>. So now SDL::Rect-&gt;new(...) gave us a blessed reference ready to go. And as an icing it would destroy itself properly no matter where it was used. But once I brought it into our existing code base, garu pointed out the extending it was a little bit of a mess. So far to extend Rect we have to something like below. Any comment or advice would be much appreciated.<br />
25<br />
26<br />
27<script src="http://gist.github.com/185938.js">
28</script><br />
29<br />
30<br />
31Have at it I am a big boy. You can grab the code like this.<br />
32Only If you don't already have a local git repo:<br />
33<br />
34<blockquote>mkdir SDL<br />
35cd SDL<br />
36git init .</blockquote><br />
37Then do this or skip to this if you already have a local git repo<br />
38<blockquote>git pull git://github.com/kthakore/SDL_perl.git experimental</blockquote><div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3102167581424744259-3340771783563950133?l=yapgh.blogspot.com' alt='' /></div>
39<p><a href="http://feedads.g.doubleclick.net/~a/KEhhydXQVOQIR77sDEUjV6-zh0M/0/da"><img src="http://feedads.g.doubleclick.net/~a/KEhhydXQVOQIR77sDEUjV6-zh0M/0/di" border="0" ismap="true"></img></a><br/>
40<a href="http://feedads.g.doubleclick.net/~a/KEhhydXQVOQIR77sDEUjV6-zh0M/1/da"><img src="http://feedads.g.doubleclick.net/~a/KEhhydXQVOQIR77sDEUjV6-zh0M/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/YetAnotherPerlGameHackeryapgh/~4/6i-HmfODM5o" height="1" width="1"/></div></div>