Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Changes

Jump to: navigation, search

Howto:Extend Nasal

145 bytes added, 17:11, 16 April 2012
m
Hash Manipulation API
int naMember_cget(naRef obj, const char* field, naRef* out);
A common way to set up hash field members easily, is using a simple macro like:
<syntaxhighlight lang="C">
#define HASHSET(s,l,n) naHash_set(navdatanaHash, naStr_fromdata(naNewString(c),s,l),n)
//... do your hash setup here
#undef HASHSET
As you can see, this allows you to easily set up hash fields.
 
This will call the naHash_set() helper, with the target hash being its first argument, the key name coming next and the naRef (n) being last.
 
The macro can be even further simplified by automatically computing the length of the hash key using strlen() instead of the explicit length argument:
<syntaxhighlight lang="C">
#define HASHSET(s,n) naHash_set(navdatanaHash, naStr_fromdata(naNewString(c),s,strlen(s)),n)
//... do your hash setup here
#undef HASHSET
18,253
edits

Navigation menu