Changeset e7f5970 for perlconfig.c


Ignore:
Timestamp:
Oct 26, 2009, 4:09:38 PM (12 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
a01ed7c
Parents:
02a72bf
git-author:
David Benjamin <davidben@mit.edu> (10/06/09 13:32:11)
git-committer:
David Benjamin <davidben@mit.edu> (10/26/09 16:09:38)
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>
File:
1 edited

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;
Note: See TracChangeset for help on using the changeset viewer.