Changeset e7f5970bf7083cf17c2ed23381f4ff53816d7ffb

Show
Ignore:
Timestamp:
10/26/09 16:09:38 (4 weeks ago)
Author:
David Benjamin <davidben@mit.edu>
git-author:
David Benjamin <davidben@mit.edu> / 2009-10-06T13:32:11Z-0400
Parents:
02a72bfacefe24e332415bea7225142b5d609763
Children:
a01ed7cdca6315ea934496b953495210530f61f7
git-committer:
David Benjamin <davidben@mit.edu> / 2009-10-26T16:09:38Z-0400
Message:
Add owl_new_hv for future Perl code

While we're at it, might as well make it easy to export dictionaries in
future.

Signed-off-by: David Benjamin <davidben@mit.edu>
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • perlconfig.c

    re67359b re7f5970  
    4848    av_push(ret, to_sv(element)); 
    4949  } 
     50 
     51  return ret; 
     52} 
     53 
     54HV *owl_new_hv(const owl_dict *d, SV *(*to_sv)(const void *)) 
     55{ 
     56  HV *ret; 
     57  owl_list l; 
     58  const char *key; 
     59  void *element; 
     60  int i; 
     61 
     62  ret = newHV(); 
     63 
     64  /* TODO: add an iterator-like interface to owl_dict */ 
     65  owl_dict_get_keys(d, &l); 
     66  for (i = 0; i < owl_list_get_size(&l); i++) { 
     67    key = owl_list_get_element(&l, i); 
     68    element = owl_dict_find_element(d, key); 
     69    (void)hv_store(ret, key, strlen(key), to_sv(element), 0); 
     70  } 
     71  owl_list_free_all(&l, owl_free); 
    5072 
    5173  return ret;