View previous topic :: View next topic |
Author |
Message |
KyleW
Joined: 05 May 2011 Posts: 2
|
Posted: Thu May 05, 2011 7:23 am Post subject: Accessing tables from the host application |
|
|
Hi!
How would I go about to getting a MiniD-table off the stack?
stackmanip.getTable does not seem to be accessible from outside the MiniD library, is this intentional or is there another API-call that I'm supposed to use?
In any case, I love the language, it's so much sweeter than Lua.
/kw
[edit] (For now, I removed the package declaration in stackmanip.d and on a couple other places to get access to MDTable.data) |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Sun May 08, 2011 9:10 pm Post subject: |
|
|
You don't get a reference to any of the reference types in the MiniD API. You just manipulate them on the stack. Getting direct pointers to the objects is dangerous, as they could be collected out from under you.
What do you want to do with the table? If you want to iterate over it, look at foreachLoop; if you want to just get an item out or put one in, look at idx/idxa; if you want to actually store a reference to the table in D code, use the reference mechanism (pushRef/removeRef, and there's also a helper class in minid.ex). |
|
Back to top |
|
|
KyleW
Joined: 05 May 2011 Posts: 2
|
Posted: Mon May 09, 2011 1:13 pm Post subject: |
|
|
Ah! Now I get it. foreachLoop is exactly what I was looking for, missed that one.
Thanks for your response!
/kw |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon May 09, 2011 1:57 pm Post subject: |
|
|
My bad for not having finished the native API walkthrough.. X) |
|
Back to top |
|
|
|