summaryrefslogtreecommitdiff
path: root/include/ruby/encoding.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ruby/encoding.h')
-rw-r--r--include/ruby/encoding.h88
1 files changed, 41 insertions, 47 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index 5ea2cda116..07e6c9a671 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -1,28 +1,22 @@
-/**********************************************************************
-
- encoding.h -
-
- $Author: matz $
- created at: Thu May 24 11:49:41 JST 2007
-
- Copyright (C) 2007 Yukihiro Matsumoto
-
-**********************************************************************/
-
-#ifndef RUBY_ENCODING_H
+#ifndef RUBY_ENCODING_H /*-*-C++-*-vi:se ft=cpp:*/
#define RUBY_ENCODING_H 1
-
-#if defined(__cplusplus)
-extern "C" {
-#if 0
-} /* satisfy cc-mode */
-#endif
-#endif
-
+/**
+ * @file
+ * @author $Author: matz $
+ * @date Thu May 24 11:49:41 JST 2007
+ * @copyright Copyright (C) 2007 Yukihiro Matsumoto
+ * @copyright This file is a part of the programming language Ruby.
+ * Permission is hereby granted, to either redistribute and/or
+ * modify this file, provided that the conditions mentioned in the
+ * file COPYING are met. Consult the file for details.
+ */
+#include "ruby/internal/config.h"
#include <stdarg.h>
+#include "ruby/ruby.h"
#include "ruby/oniguruma.h"
+#include "ruby/internal/dllexport.h"
-RUBY_SYMBOL_EXPORT_BEGIN
+RBIMPL_SYMBOL_EXPORT_BEGIN()
enum ruby_encoding_consts {
RUBY_ENCODING_INLINE_MAX = 127,
@@ -113,11 +107,13 @@ int rb_char_to_option_kcode(int c, int *option, int *kcode);
int rb_enc_replicate(const char *, rb_encoding *);
int rb_define_dummy_encoding(const char *);
-int rb_enc_dummy_p(rb_encoding *enc);
-int rb_enc_to_index(rb_encoding *enc);
+PUREFUNC(int rb_enc_dummy_p(rb_encoding *enc));
+PUREFUNC(int rb_enc_to_index(rb_encoding *enc));
int rb_enc_get_index(VALUE obj);
void rb_enc_set_index(VALUE obj, int encindex);
+int rb_enc_capable(VALUE obj);
int rb_enc_find_index(const char *name);
+int rb_enc_alias(const char *alias, const char *orig);
int rb_to_encoding_index(VALUE);
rb_encoding *rb_to_encoding(VALUE);
rb_encoding *rb_find_encoding(VALUE);
@@ -131,6 +127,8 @@ void rb_enc_copy(VALUE dst, VALUE src);
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
VALUE rb_enc_str_new_static(const char*, long, rb_encoding*);
+VALUE rb_enc_interned_str(const char *, long, rb_encoding *);
+VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *);
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
@@ -145,19 +143,17 @@ VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
-#if defined(__GNUC__) && !defined(__PCC__)
-#define rb_enc_str_new(str, len, enc) __extension__ ( \
-{ \
+#ifdef HAVE_BUILTIN___BUILTIN_CONSTANT_P
+#define rb_enc_str_new(str, len, enc) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str) && __builtin_constant_p(len)) ? \
rb_enc_str_new_static((str), (len), (enc)) : \
- rb_enc_str_new((str), (len), (enc)); \
-})
-#define rb_enc_str_new_cstr(str, enc) __extension__ ( \
-{ \
+ rb_enc_str_new((str), (len), (enc)) \
+)
+#define rb_enc_str_new_cstr(str, enc) RB_GNUC_EXTENSION_BLOCK( \
(__builtin_constant_p(str)) ? \
rb_enc_str_new_static((str), (long)strlen(str), (enc)) : \
- rb_enc_str_new_cstr((str), (enc)); \
-})
+ rb_enc_str_new_cstr((str), (enc)) \
+)
#endif
PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
@@ -232,11 +228,16 @@ int rb_enc_code_to_mbclen(int code, rb_encoding *enc);
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE((enc),(c))
#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT((enc),(c))
-#define rb_enc_asciicompat(enc) (rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc))
+static inline int
+rb_enc_asciicompat_inline(rb_encoding *enc)
+{
+ return rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc);
+}
+#define rb_enc_asciicompat(enc) rb_enc_asciicompat_inline(enc)
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
-int rb_enc_toupper(int c, rb_encoding *enc);
-int rb_enc_tolower(int c, rb_encoding *enc);
+CONSTFUNC(int rb_enc_toupper(int c, rb_encoding *enc));
+CONSTFUNC(int rb_enc_tolower(int c, rb_encoding *enc));
ID rb_intern3(const char*, long, rb_encoding*);
ID rb_interned_id_p(const char *, long, rb_encoding *);
int rb_enc_symname_p(const char*, rb_encoding*);
@@ -246,7 +247,7 @@ long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, i
int rb_enc_str_asciionly_p(VALUE);
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
VALUE rb_enc_from_encoding(rb_encoding *enc);
-int rb_enc_unicode_p(rb_encoding *enc);
+PUREFUNC(int rb_enc_unicode_p(rb_encoding *enc));
rb_encoding *rb_ascii8bit_encoding(void);
rb_encoding *rb_utf8_encoding(void);
rb_encoding *rb_usascii_encoding(void);
@@ -255,13 +256,13 @@ rb_encoding *rb_filesystem_encoding(void);
rb_encoding *rb_default_external_encoding(void);
rb_encoding *rb_default_internal_encoding(void);
#ifndef rb_ascii8bit_encindex
-int rb_ascii8bit_encindex(void);
+CONSTFUNC(int rb_ascii8bit_encindex(void));
#endif
#ifndef rb_utf8_encindex
-int rb_utf8_encindex(void);
+CONSTFUNC(int rb_utf8_encindex(void));
#endif
#ifndef rb_usascii_encindex
-int rb_usascii_encindex(void);
+CONSTFUNC(int rb_usascii_encindex(void));
#endif
int rb_locale_encindex(void);
int rb_filesystem_encindex(void);
@@ -407,13 +408,6 @@ enum ruby_econv_flag_type {
/* end of flags for rb_econv_convert */
RUBY_ECONV_FLAGS_PLACEHOLDER};
-RUBY_SYMBOL_EXPORT_END
-
-#if defined(__cplusplus)
-#if 0
-{ /* satisfy cc-mode */
-#endif
-} /* extern "C" { */
-#endif
+RBIMPL_SYMBOL_EXPORT_END()
#endif /* RUBY_ENCODING_H */