Data Structures | Defines | Functions | Variables

ext/tk/tkutil/tkutil.c File Reference

#include "ruby.h"
#include "rubysig.h"
#include "st.h"
Include dependency graph for tkutil.c:

Go to the source code of this file.

Data Structures

struct  cbsubst_info

Defines

#define TKUTIL_RELEASE_DATE   "2010-03-26"
#define RHASH_TBL(h)   (RHASH(h)->tbl)
#define RSTRING_PTR(s)   (RSTRING(s)->ptr)
#define RSTRING_LEN(s)   (RSTRING(s)->len)
#define RARRAY_PTR(s)   (RARRAY(s)->ptr)
#define RARRAY_LEN(s)   (RARRAY(s)->len)
#define CBSUBST_TBL_MAX   (256)

Functions

static VALUE tk_s_new (int argc, VALUE *argv, VALUE klass)
static VALUE tkNone_to_s (VALUE self)
static VALUE tkNone_inspect (VALUE self)
static VALUE tk_obj_untrust (VALUE self, VALUE obj)
static VALUE tk_eval_cmd (int argc, argv, VALUE self)
static VALUE tk_do_callback (int argc, VALUE *argv, VALUE self)
static VALUE tk_install_cmd_core (VALUE cmd)
static VALUE tk_install_cmd (int argc, VALUE *argv, VALUE self)
static VALUE tk_uninstall_cmd (VALUE self, VALUE cmd_id)
static VALUE tk_toUTF8 (int argc, VALUE *argv, VALUE self)
static VALUE tk_fromUTF8 (int argc, VALUE *argv, VALUE self)
static VALUE fromDefaultEnc_toUTF8 (VALUE str, VALUE self)
static int to_strkey (VALUE key, VALUE value, VALUE hash)
static VALUE tk_symbolkey2str (VALUE self, VALUE keys)
static VALUE get_eval_string_core _ ((VALUE, VALUE, VALUE))
static VALUE hash2list _ ((VALUE, VALUE))
static VALUE ary2list (VALUE ary, VALUE enc_flag, VALUE self)
static VALUE ary2list2 (VALUE ary, VALUE enc_flag, VALUE self)
static VALUE key2keyname (VALUE key)
static VALUE assoc2kv (VALUE assoc, VALUE ary, VALUE self)
static VALUE assoc2kv_enc (VALUE assoc, VALUE ary, VALUE self)
static int push_kv (VALUE key, VALUE val, VALUE args)
static VALUE hash2kv (VALUE hash, VALUE ary, VALUE self)
static int push_kv_enc (VALUE key, VALUE val, VALUE args)
static VALUE hash2kv_enc (VALUE hash, VALUE ary, VALUE self)
static VALUE hash2list (VALUE hash, VALUE self)
static VALUE hash2list_enc (VALUE hash, VALUE self)
static VALUE tk_hash_kv (int argc, VALUE *argv, VALUE self)
static VALUE get_eval_string_core (VALUE obj, VALUE enc_flag, VALUE self)
static VALUE tk_get_eval_string (int argc, VALUE *argv, VALUE self)
static VALUE tk_get_eval_enc_str (VALUE self, VALUE obj)
static VALUE tk_conv_args (int argc, VALUE *argv, VALUE self)
static VALUE tcl2rb_bool (VALUE self, VALUE value)
static VALUE tkstr_to_int (VALUE value)
static VALUE tkstr_to_float (VALUE value)
static VALUE tkstr_invalid_numstr (VALUE value)
static VALUE tkstr_rescue_float (VALUE value)
static VALUE tkstr_to_number (VALUE value)
static VALUE tcl2rb_number (VALUE self, VALUE value)
static VALUE tkstr_to_str (VALUE value)
static VALUE tcl2rb_string (VALUE self, VALUE value)
static VALUE tcl2rb_num_or_str (VALUE self, VALUE value)
static VALUE tcl2rb_num_or_nil (VALUE self, VALUE value)
static void subst_mark (struct cbsubst_info *ptr)
static void subst_free (struct cbsubst_info *ptr)
static VALUE allocate_cbsubst_info (struct cbsubst_info **inf_ptr)
static void cbsubst_init ()
static VALUE cbsubst_initialize (int argc, VALUE *argv, VALUE self)
static VALUE cbsubst_ret_val (VALUE self, VALUE val)
static int each_attr_def (VALUE key, VALUE value, VALUE klass)
static VALUE cbsubst_def_attr_aliases (VALUE self, VALUE tbl)
static VALUE cbsubst_sym_to_subst (VALUE self, VALUE sym)
static VALUE cbsubst_get_subst_arg (int argc, VALUE *argv, VALUE self)
static VALUE cbsubst_get_subst_key (VALUE self, VALUE str)
static VALUE cbsubst_get_all_subst_keys (VALUE self)
static VALUE cbsubst_table_setup (int argc, VALUE *argv, VALUE self)
static VALUE cbsubst_get_extra_args_tbl (VALUE self)
static VALUE cbsubst_scan_args (VALUE self, VALUE arg_key, VALUE val_ary)
static VALUE cbsubst_inspect (VALUE self)
static VALUE substinfo_inspect (VALUE self)
static VALUE tk_cbe_inspect (VALUE self)
static VALUE tkobj_path (VALUE self)
void Init_tkutil ()

Variables

static VALUE cMethod
static VALUE cTclTkLib
static VALUE cTkObject
static VALUE cTkCallbackEntry
static VALUE TK_None
static VALUE cCB_SUBST
static VALUE cSUBST_INFO
static VALUE ENCODING_NAME_UTF8
static ID ID_split_tklist
static ID ID_toUTF8
static ID ID_fromUTF8
static ID ID_path
static ID ID_at_path
static ID ID_at_enc
static ID ID_to_eval
static ID ID_to_s
static ID ID_source
static ID ID_downcase
static ID ID_install_cmd
static ID ID_merge_tklist
static ID ID_encoding
static ID ID_encoding_system
static ID ID_call
static ID ID_SUBST_INFO
static VALUE CALLBACK_TABLE
static unsigned long CALLBACK_ID_NUM = 0
static const char cmd_id_head [] = "ruby_cmd TkUtil callback "
static const char cmd_id_prefix [] = "cmd"
const char tkutil_release_date [] = TKUTIL_RELEASE_DATE

Define Documentation

#define CBSUBST_TBL_MAX   (256)

Definition at line 1134 of file tkutil.c.

Referenced by cbsubst_get_all_subst_keys().

#define RARRAY_LEN (   s  )     (RARRAY(s)->len)
#define RARRAY_PTR (   s  )     (RARRAY(s)->ptr)
#define RHASH_TBL (   h  )     (RHASH(h)->tbl)
#define RSTRING_LEN (   s  )     (RSTRING(s)->len)
#define RSTRING_PTR (   s  )     (RSTRING(s)->ptr)
#define TKUTIL_RELEASE_DATE   "2010-03-26"

Definition at line 10 of file tkutil.c.


Function Documentation

static VALUE hash2kv_enc _ ( (VALUE, VALUE, VALUE  )  [static]
static VALUE hash2list_enc _ ( (VALUE, VALUE  )  [static]
static VALUE allocate_cbsubst_info ( struct cbsubst_info **  inf_ptr  )  [static]
static VALUE ary2list ( VALUE  ary,
VALUE  enc_flag,
VALUE  self 
) [static]
static VALUE ary2list2 ( VALUE  ary,
VALUE  enc_flag,
VALUE  self 
) [static]
static VALUE assoc2kv ( VALUE  assoc,
VALUE  ary,
VALUE  self 
) [static]

Definition at line 549 of file tkutil.c.

References key2keyname(), len, NIL_P, RARRAY_LEN, RARRAY_PTR, rb_ary_new2(), rb_ary_plus(), rb_ary_push(), T_ARRAY, and TYPE.

Referenced by tk_hash_kv().

static VALUE assoc2kv_enc ( VALUE  assoc,
VALUE  ary,
VALUE  self 
) [static]
static VALUE cbsubst_def_attr_aliases ( VALUE  self,
VALUE  tbl 
) [static]
static VALUE cbsubst_get_all_subst_keys ( VALUE  self  )  [static]
static VALUE cbsubst_get_extra_args_tbl ( VALUE  self  )  [static]

Definition at line 1636 of file tkutil.c.

References rb_ary_new().

Referenced by Init_tkutil().

static VALUE cbsubst_get_subst_arg ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE cbsubst_get_subst_key ( VALUE  self,
VALUE  str 
) [static]
static void cbsubst_init (  )  [static]

Definition at line 1200 of file tkutil.c.

References allocate_cbsubst_info(), cCB_SUBST, ID_SUBST_INFO, NULL, and rb_const_set().

Referenced by Init_tkutil().

static VALUE cbsubst_initialize ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE cbsubst_inspect ( VALUE  self  )  [static]

Definition at line 1695 of file tkutil.c.

References rb_str_new2().

Referenced by Init_tkutil().

static VALUE cbsubst_ret_val ( VALUE  self,
VALUE  val 
) [static]

Definition at line 1229 of file tkutil.c.

Referenced by Init_tkutil().

static VALUE cbsubst_scan_args ( VALUE  self,
VALUE  arg_key,
VALUE  val_ary 
) [static]
static VALUE cbsubst_sym_to_subst ( VALUE  self,
VALUE  sym 
) [static]
static VALUE cbsubst_table_setup ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static int each_attr_def ( VALUE  key,
VALUE  value,
VALUE  klass 
) [static]

Definition at line 1240 of file tkutil.c.

References Qundef, rb_alias(), rb_eArgError, rb_intern, rb_raise(), RSTRING_PTR, SYM2ID, T_STRING, T_SYMBOL, and TYPE.

Referenced by cbsubst_def_attr_aliases().

static VALUE fromDefaultEnc_toUTF8 ( VALUE  str,
VALUE  self 
) [static]

Definition at line 240 of file tkutil.c.

References argv, and tk_toUTF8().

Referenced by get_eval_string_core().

static VALUE get_eval_string_core ( VALUE  obj,
VALUE  enc_flag,
VALUE  self 
) [static]
static VALUE hash2kv ( VALUE  hash,
VALUE  ary,
VALUE  self 
) [static]
static VALUE hash2kv_enc ( VALUE  hash,
VALUE  ary,
VALUE  self 
) [static]
static VALUE hash2list ( VALUE  hash,
VALUE  self 
) [static]

Definition at line 732 of file tkutil.c.

References ary2list2(), hash2kv(), Qfalse, and Qnil.

Referenced by ary2list(), ary2list2(), and get_eval_string_core().

static VALUE hash2list_enc ( VALUE  hash,
VALUE  self 
) [static]

Definition at line 741 of file tkutil.c.

References ary2list2(), hash2kv_enc(), Qfalse, and Qnil.

Referenced by ary2list(), ary2list2(), and get_eval_string_core().

void Init_tkutil (  ) 
static VALUE key2keyname ( VALUE  key  )  [static]

Definition at line 542 of file tkutil.c.

References ID_to_s, rb_funcall(), rb_str_append(), and rb_str_new2().

Referenced by assoc2kv(), assoc2kv_enc(), push_kv(), and push_kv_enc().

static int push_kv ( VALUE  key,
VALUE  val,
VALUE  args 
) [static]

Definition at line 645 of file tkutil.c.

References get_eval_string_core(), key2keyname(), Qnil, Qundef, RARRAY_PTR, rb_ary_push(), and TK_None.

Referenced by hash2kv().

static int push_kv_enc ( VALUE  key,
VALUE  val,
VALUE  args 
) [static]

Definition at line 687 of file tkutil.c.

References get_eval_string_core(), key2keyname(), Qtrue, Qundef, RARRAY_PTR, rb_ary_push(), and TK_None.

Referenced by hash2kv_enc().

static void subst_free ( struct cbsubst_info ptr  )  [static]

Definition at line 1154 of file tkutil.c.

References free, NULL, and xfree().

Referenced by allocate_cbsubst_info().

static void subst_mark ( struct cbsubst_info ptr  )  [static]

Definition at line 1146 of file tkutil.c.

References rb_gc_mark().

Referenced by allocate_cbsubst_info().

static VALUE substinfo_inspect ( VALUE  self  )  [static]

Definition at line 1702 of file tkutil.c.

References rb_str_new2().

Referenced by Init_tkutil().

static VALUE tcl2rb_bool ( VALUE  self,
VALUE  value 
) [static]

Definition at line 982 of file tkutil.c.

References ID_downcase, NULL, NUM2INT, rb_check_type(), rb_funcall(), RSTRING_PTR, T_FALSE, T_FIXNUM, T_STRING, T_TRUE, and TYPE.

Referenced by Init_tkutil().

static VALUE tcl2rb_num_or_nil ( VALUE  self,
VALUE  value 
) [static]

Definition at line 1120 of file tkutil.c.

References rb_check_type(), RSTRING_LEN, T_STRING, and tkstr_to_number().

Referenced by Init_tkutil().

static VALUE tcl2rb_num_or_str ( VALUE  self,
VALUE  value 
) [static]
static VALUE tcl2rb_number ( VALUE  self,
VALUE  value 
) [static]

Definition at line 1070 of file tkutil.c.

References tkstr_to_number().

Referenced by Init_tkutil().

static VALUE tcl2rb_string ( VALUE  self,
VALUE  value 
) [static]

Definition at line 1094 of file tkutil.c.

References NULL, rb_check_type(), rb_tainted_str_new2(), RSTRING_PTR, T_STRING, and tkstr_to_str().

Referenced by Init_tkutil().

static VALUE tk_cbe_inspect ( VALUE  self  )  [static]

Definition at line 1711 of file tkutil.c.

References rb_str_new2().

Referenced by Init_tkutil().

static VALUE tk_conv_args ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE tk_do_callback ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 146 of file tkutil.c.

References CALLBACK_TABLE, id, ID_call, rb_apply(), rb_funcall2(), rb_hash_aref(), and rb_scan_args().

Referenced by Init_tkutil().

static VALUE tk_eval_cmd ( int  argc,
argv  ,
VALUE  self 
) [static]

Definition at line 134 of file tkutil.c.

References rb_eval_cmd(), and rb_scan_args().

Referenced by Init_tkutil().

static VALUE tk_fromUTF8 ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 231 of file tkutil.c.

References cTclTkLib, ID_fromUTF8, and rb_funcall2().

Referenced by Init_tkutil().

static VALUE tk_get_eval_enc_str ( VALUE  self,
VALUE  obj 
) [static]

Definition at line 921 of file tkutil.c.

References get_eval_string_core(), Qtrue, and TK_None.

Referenced by Init_tkutil().

static VALUE tk_get_eval_string ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 906 of file tkutil.c.

References get_eval_string_core(), and rb_scan_args().

Referenced by Init_tkutil().

static VALUE tk_hash_kv ( int  argc,
VALUE argv,
VALUE  self 
) [static]
static VALUE tk_install_cmd ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 179 of file tkutil.c.

References rb_block_proc(), rb_scan_args(), and tk_install_cmd_core().

Referenced by Init_tkutil().

static VALUE tk_install_cmd_core ( VALUE  cmd  )  [static]
static VALUE tk_obj_untrust ( VALUE  self,
VALUE  obj 
) [static]

Definition at line 119 of file tkutil.c.

References rb_obj_taint(), and rb_obj_untrust().

Referenced by Init_tkutil().

static VALUE tk_s_new ( int  argc,
VALUE argv,
VALUE  klass 
) [static]
static VALUE tk_symbolkey2str ( VALUE  self,
VALUE  keys 
) [static]

Definition at line 275 of file tkutil.c.

References NIL_P, rb_convert_type(), rb_hash_new(), RHASH_TBL, st_foreach(), T_HASH, and to_strkey().

Referenced by Init_tkutil().

static VALUE tk_toUTF8 ( int  argc,
VALUE argv,
VALUE  self 
) [static]

Definition at line 222 of file tkutil.c.

References cTclTkLib, ID_toUTF8, and rb_funcall2().

Referenced by fromDefaultEnc_toUTF8(), and Init_tkutil().

static VALUE tk_uninstall_cmd ( VALUE  self,
VALUE  cmd_id 
) [static]

Definition at line 201 of file tkutil.c.

References CALLBACK_TABLE, rb_hash_delete(), rb_str_new2(), RSTRING_PTR, and StringValue.

Referenced by Init_tkutil().

static VALUE tkNone_inspect ( VALUE  self  )  [static]

Definition at line 110 of file tkutil.c.

References rb_str_new2().

Referenced by Init_tkutil().

static VALUE tkNone_to_s ( VALUE  self  )  [static]

Definition at line 103 of file tkutil.c.

References rb_str_new2().

Referenced by Init_tkutil().

static VALUE tkobj_path ( VALUE  self  )  [static]

Definition at line 1720 of file tkutil.c.

References ID_at_path, and rb_ivar_get().

Referenced by Init_tkutil().

static VALUE tkstr_invalid_numstr ( VALUE  value  )  [static]

Definition at line 1039 of file tkutil.c.

References rb_eArgError, rb_raise(), and RSTRING_PTR.

Referenced by tkstr_rescue_float().

static VALUE tkstr_rescue_float ( VALUE  value  )  [static]

Definition at line 1048 of file tkutil.c.

References rb_eArgError, rb_rescue2(), tkstr_invalid_numstr(), and tkstr_to_float().

Referenced by tkstr_to_number().

static VALUE tkstr_to_float ( VALUE  value  )  [static]

Definition at line 1032 of file tkutil.c.

References rb_cstr_to_dbl(), rb_float_new(), and RSTRING_PTR.

Referenced by tkstr_rescue_float().

static VALUE tkstr_to_int ( VALUE  value  )  [static]

Definition at line 1025 of file tkutil.c.

References rb_cstr_to_inum(), and RSTRING_PTR.

Referenced by tkstr_to_number().

static VALUE tkstr_to_number ( VALUE  value  )  [static]
static VALUE tkstr_to_str ( VALUE  value  )  [static]

Definition at line 1078 of file tkutil.c.

References len, rb_str_new(), RSTRING_LEN, and RSTRING_PTR.

Referenced by tcl2rb_num_or_str(), and tcl2rb_string().

static int to_strkey ( VALUE  key,
VALUE  value,
VALUE  hash 
) [static]

Definition at line 264 of file tkutil.c.

References ID_to_s, Qundef, rb_funcall(), and rb_hash_aset().

Referenced by tk_symbolkey2str().


Variable Documentation

unsigned long CALLBACK_ID_NUM = 0 [static]

Definition at line 75 of file tkutil.c.

Referenced by tk_install_cmd_core().

Definition at line 74 of file tkutil.c.

Referenced by Init_tkutil(), tk_do_callback(), tk_install_cmd_core(), and tk_uninstall_cmd().

VALUE cCB_SUBST [static]

Definition at line 51 of file tkutil.c.

Referenced by cbsubst_init(), and Init_tkutil().

const char cmd_id_head[] = "ruby_cmd TkUtil callback " [static]

Definition at line 162 of file tkutil.c.

const char cmd_id_prefix[] = "cmd" [static]

Definition at line 163 of file tkutil.c.

VALUE cMethod [static]

Definition at line 42 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

VALUE cSUBST_INFO [static]

Definition at line 52 of file tkutil.c.

Referenced by allocate_cbsubst_info(), and Init_tkutil().

VALUE cTclTkLib [static]

Definition at line 44 of file tkutil.c.

Referenced by ary2list(), ary2list2(), cbsubst_get_subst_key(), Init_tkutil(), tk_fromUTF8(), and tk_toUTF8().

Definition at line 47 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

VALUE cTkObject [static]

Definition at line 46 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

Definition at line 54 of file tkutil.c.

Referenced by ary2list(), ary2list2(), and Init_tkutil().

ID ID_at_enc [static]

Definition at line 61 of file tkutil.c.

Referenced by ary2list(), ary2list2(), and Init_tkutil().

ID ID_at_path [static]

Definition at line 60 of file tkutil.c.

Referenced by Init_tkutil(), and tkobj_path().

ID ID_call [static]

Definition at line 70 of file tkutil.c.

Referenced by cbsubst_scan_args(), Init_tkutil(), and tk_do_callback().

ID ID_downcase [static]

Definition at line 65 of file tkutil.c.

Referenced by Init_tkutil(), and tcl2rb_bool().

ID ID_encoding [static]

Definition at line 68 of file tkutil.c.

Referenced by ary2list(), ary2list2(), and Init_tkutil().

Definition at line 69 of file tkutil.c.

Referenced by ary2list(), ary2list2(), and Init_tkutil().

ID ID_fromUTF8 [static]

Definition at line 58 of file tkutil.c.

Referenced by ary2list(), ary2list2(), Init_tkutil(), and tk_fromUTF8().

ID ID_install_cmd [static]

Definition at line 66 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

ID ID_merge_tklist [static]

Definition at line 67 of file tkutil.c.

Referenced by ary2list(), ary2list2(), and Init_tkutil().

ID ID_path [static]

Definition at line 59 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

ID ID_source [static]

Definition at line 64 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

ID ID_split_tklist [static]

Definition at line 56 of file tkutil.c.

Referenced by cbsubst_get_subst_key(), and Init_tkutil().

ID ID_SUBST_INFO [static]
ID ID_to_eval [static]

Definition at line 62 of file tkutil.c.

Referenced by get_eval_string_core(), and Init_tkutil().

ID ID_to_s [static]
ID ID_toUTF8 [static]

Definition at line 57 of file tkutil.c.

Referenced by ary2list(), ary2list2(), get_eval_string_core(), Init_tkutil(), and tk_toUTF8().

VALUE TK_None [static]
const char tkutil_release_date[] = TKUTIL_RELEASE_DATE

Definition at line 1729 of file tkutil.c.