How do I build a Perl hash in C, using SWIG? -


I am trying to create a Pearl hash from within a C library. This is what I have so far received:

  Fixed zero add_string_to_perl_hash (HV * HV, four * key, four * value) {SV * obj = sv_2mortal (newSVpv (value, 0)) ; Hv_store (hv, (const char *) key, strlen (key), obj, 0); SvREFCNT_inc (obj); } SV * do_get_test_hash () {static char * foo = "foo"; Fixed four times = "bar"; HV * HV; HV = new HV (); Add_string_to_perl_hash (HV, "afu", afo); Add_string_to_perl_hash (HV, "bar", bar); Return sv_2mortal (newRV_noinc (SV *) HV)); }  

Try it: I do not get anything that makes me understand:

  use testlib; Use data: Dumper; Print dumper (testlab :: do_get_test_hash ()); $ VAR1 = Blessings (do {\ (my $ o = 5359872)}, '_p_SV');  

Thoughts?

look at example 6. It creates a bunch of hash and adds them to an array Finally, it gives a reference to the array. If you return a hash, then it will work practically the same.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -