Ignore:
Timestamp:
Jul 9, 2020, 8:51:43 AM (4 years ago)
Author:
coas-nagasima
Message:

mrubyを2.1.1に更新

Location:
EcnlProtoTool/trunk/mruby-2.1.1
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-2.1.1/include/mruby/hash.h

    r331 r439  
    1 /*
    2 ** mruby/hash.h - Hash class
     1/**
     2** @file mruby/hash.h - Hash class
    33**
    44** See Copyright Notice in mruby.h
     
    99
    1010#include "common.h"
    11 #include <mruby/khash.h>
    1211
    1312/**
     
    1918  MRB_OBJECT_HEADER;
    2019  struct iv_tbl *iv;
    21   struct kh_ht *ht;
     20  struct htable *ht;
    2221};
    2322
     
    2524#define mrb_hash_value(p)  mrb_obj_value((void*)(p))
    2625
    27 MRB_API mrb_value mrb_hash_new_capa(mrb_state*, mrb_int);
     26MRB_API mrb_value mrb_hash_new_capa(mrb_state *mrb, mrb_int capa);
     27MRB_API mrb_value mrb_ensure_hash_type(mrb_state *mrb, mrb_value hash);
     28MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
    2829
    2930/*
     
    7576 * Equivalent to:
    7677 *
    77  *     hash.hash_key?(key) ? hash[key] : def
     78 *     hash.key?(key) ? hash[key] : def
    7879 *
    7980 * @param mrb The mruby state reference.
     
    9596 * @param hash The target hash.
    9697 * @param key The key to delete.
    97  * @return The deleted value.
     98 * @return The deleted value. This value is not protected from GC. Use `mrb_gc_protect()` if necessary.
    9899 */
    99100MRB_API mrb_value mrb_hash_delete_key(mrb_state *mrb, mrb_value hash, mrb_value key);
     
    111112 */
    112113MRB_API mrb_value mrb_hash_keys(mrb_state *mrb, mrb_value hash);
    113 MRB_API mrb_value mrb_check_hash_type(mrb_state *mrb, mrb_value hash);
     114/*
     115 * Check if the hash has the key.
     116 *
     117 * Equivalent to:
     118 *
     119 *     hash.key?(key)
     120 *
     121 * @param mrb The mruby state reference.
     122 * @param hash The target hash.
     123 * @param key The key to check existence.
     124 * @return True if the hash has the key
     125 */
     126MRB_API mrb_bool mrb_hash_key_p(mrb_state *mrb, mrb_value hash, mrb_value key);
    114127
    115128/*
     
    124137 * @return True if the hash is empty, false otherwise.
    125138 */
    126 MRB_API mrb_value mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
     139MRB_API mrb_bool mrb_hash_empty_p(mrb_state *mrb, mrb_value self);
    127140
    128141/*
     
    152165MRB_API mrb_value mrb_hash_clear(mrb_state *mrb, mrb_value hash);
    153166
    154 /* declaration of struct kh_ht */
    155 /* be careful when you touch the internal */
    156 typedef struct {
    157   mrb_value v;
    158   mrb_int n;
    159 } mrb_hash_value;
    160 
    161 KHASH_DECLARE(ht, mrb_value, mrb_hash_value, TRUE)
     167/*
     168 * Get hash size.
     169 *
     170 * Equivalent to:
     171 *
     172 *      hash.size
     173 *
     174 * @param mrb The mruby state reference.
     175 * @param hash The target hash.
     176 * @return The hash size.
     177 */
     178MRB_API mrb_int mrb_hash_size(mrb_state *mrb, mrb_value hash);
     179
     180/*
     181 * Copies the hash.
     182 *
     183 *
     184 * @param mrb The mruby state reference.
     185 * @param hash The target hash.
     186 * @return The copy of the hash
     187 */
     188MRB_API mrb_value mrb_hash_dup(mrb_state *mrb, mrb_value hash);
     189
     190/*
     191 * Merges two hashes. The first hash will be modified by the
     192 * second hash.
     193 *
     194 * @param mrb The mruby state reference.
     195 * @param hash1 The target hash.
     196 * @param hash2 Updating hash
     197 */
     198MRB_API void mrb_hash_merge(mrb_state *mrb, mrb_value hash1, mrb_value hash2);
    162199
    163200/* RHASH_TBL allocates st_table if not available. */
     
    166203#define RHASH_IFNONE(h)       mrb_iv_get(mrb, (h), mrb_intern_lit(mrb, "ifnone"))
    167204#define RHASH_PROCDEFAULT(h)  RHASH_IFNONE(h)
    168 MRB_API struct kh_ht * mrb_hash_tbl(mrb_state *mrb, mrb_value hash);
    169205
    170206#define MRB_HASH_DEFAULT      1
     
    178214void mrb_gc_free_hash(mrb_state*, struct RHash*);
    179215
     216/* return non zero to break the loop */
     217typedef int (mrb_hash_foreach_func)(mrb_state *mrb, mrb_value key, mrb_value val, void *data);
     218MRB_API void mrb_hash_foreach(mrb_state *mrb, struct RHash *hash, mrb_hash_foreach_func *func, void *p);
     219
    180220MRB_END_DECL
    181221
Note: See TracChangeset for help on using the changeset viewer.