From fcbf63e62c627deae76c1b8cb8c0876c536ed811 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 16 Mar 2020 18:49:26 +0900 Subject: Fresh start --- jni/ruby/symbol.h | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 jni/ruby/symbol.h (limited to 'jni/ruby/symbol.h') diff --git a/jni/ruby/symbol.h b/jni/ruby/symbol.h new file mode 100644 index 0000000..5c52b97 --- /dev/null +++ b/jni/ruby/symbol.h @@ -0,0 +1,88 @@ +/********************************************************************** + + symbol.h - + + $Author$ + created at: Tue Jul 8 15:49:54 JST 2014 + + Copyright (C) 2014 Yukihiro Matsumoto + +**********************************************************************/ + +#ifndef RUBY_SYMBOL_H +#define RUBY_SYMBOL_H 1 + +#include "id.h" + +#define DYNAMIC_ID_P(id) (!(id&ID_STATIC_SYM)&&id>tLAST_OP_ID) +#define STATIC_ID2SYM(id) (((VALUE)(id)<tLAST_OP_ID) +#define is_local_id(id) (id_type(id)==ID_LOCAL) +#define is_global_id(id) (id_type(id)==ID_GLOBAL) +#define is_instance_id(id) (id_type(id)==ID_INSTANCE) +#define is_attrset_id(id) (id_type(id)==ID_ATTRSET) +#define is_const_id(id) (id_type(id)==ID_CONST) +#define is_class_id(id) (id_type(id)==ID_CLASS) +#define is_junk_id(id) (id_type(id)==ID_JUNK) + +static inline int +sym_type(VALUE sym) +{ + ID id; + if (STATIC_SYM_P(sym)) { + id = RSHIFT(sym, RUBY_SPECIAL_SHIFT); + if (id<=tLAST_OP_ID) { + return -1; + } + } + else { + id = RSYMBOL(sym)->id; + } + return (int)(id&ID_SCOPE_MASK); +} + +#define is_local_sym(sym) (sym_type(sym)==ID_LOCAL) +#define is_global_sym(sym) (sym_type(sym)==ID_GLOBAL) +#define is_instance_sym(sym) (sym_type(sym)==ID_INSTANCE) +#define is_attrset_sym(sym) (sym_type(sym)==ID_ATTRSET) +#define is_const_sym(sym) (sym_type(sym)==ID_CONST) +#define is_class_sym(sym) (sym_type(sym)==ID_CLASS) +#define is_junk_sym(sym) (sym_type(sym)==ID_JUNK) + +RUBY_FUNC_EXPORTED const unsigned int ruby_global_name_punct_bits[(0x7e - 0x20 + 31) / 32]; + +static inline int +is_global_name_punct(const int c) +{ + if (c <= 0x20 || 0x7e < c) return 0; + return (ruby_global_name_punct_bits[(c - 0x20) / 32] >> (c % 32)) & 1; +} + +ID rb_intern_cstr_without_pindown(const char *, long, rb_encoding *); + +#endif -- cgit v1.2.3