FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Accessing tables from the host application

 
Post new topic   Reply to topic     Forum Index -> MiniD
View previous topic :: View next topic  
Author Message
KyleW



Joined: 05 May 2011
Posts: 2

PostPosted: Thu May 05, 2011 7:23 am    Post subject: Accessing tables from the host application Reply with quote

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? Smile


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
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Sun May 08, 2011 9:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
KyleW



Joined: 05 May 2011
Posts: 2

PostPosted: Mon May 09, 2011 1:13 pm    Post subject: Reply with quote

Ah! Now I get it. foreachLoop is exactly what I was looking for, missed that one.

Thanks for your response!

/kw
Back to top
View user's profile Send private message
JarrettBillingsley



Joined: 20 Jun 2006
Posts: 457
Location: Pennsylvania!

PostPosted: Mon May 09, 2011 1:57 pm    Post subject: Reply with quote

My bad for not having finished the native API walkthrough.. X)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> MiniD All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group