本文整理汇总了C++中rb_define_const函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_define_const函数的具体用法?C++ rb_define_const怎么用?C++ rb_define_const使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_define_const函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init_spidermonkey
void Init_spidermonkey()
{
JS_SetCStringsAreUTF8();
VALUE johnson = rb_const_get(rb_mKernel, rb_intern("Johnson"));
VALUE spidermonkey = rb_define_module_under(johnson, "SpiderMonkey");
init_Johnson_SpiderMonkey_Context(spidermonkey);
init_Johnson_SpiderMonkey_Proxy(spidermonkey);
init_Johnson_SpiderMonkey_Debugger(spidermonkey);
init_Johnson_SpiderMonkey_Immutable_Node(spidermonkey);
init_Johnson_SpiderMonkey_Runtime(spidermonkey);
rb_define_const(spidermonkey, "VERSION",
rb_obj_freeze(rb_str_new2(JS_GetImplementationVersion())));
}
示例2: cov_generate_coverage_info
static VALUE
cov_generate_coverage_info(VALUE self)
{
VALUE cover;
if(rb_const_defined_at(mRCOV__, id_cover)) {
rb_mod_remove_const(mRCOV__, ID2SYM(id_cover));
}
cover = rb_hash_new();
if(coverinfo)
st_foreach(coverinfo, populate_cover, cover);
rb_define_const(mRCOV__, "COVER", cover);
return cover;
}
示例3: Init_session_ext
void Init_session_ext() {
curl_global_init(CURL_GLOBAL_ALL);
rb_require("patron/error");
mPatron = rb_define_module("Patron");
ePatronError = rb_const_get(mPatron, rb_intern("Error"));
eUnsupportedProtocol = rb_const_get(mPatron, rb_intern("UnsupportedProtocol"));
eURLFormatError = rb_const_get(mPatron, rb_intern("URLFormatError"));
eHostResolutionError = rb_const_get(mPatron, rb_intern("HostResolutionError"));
eConnectionFailed = rb_const_get(mPatron, rb_intern("ConnectionFailed"));
ePartialFileError = rb_const_get(mPatron, rb_intern("PartialFileError"));
eTimeoutError = rb_const_get(mPatron, rb_intern("TimeoutError"));
eTooManyRedirects = rb_const_get(mPatron, rb_intern("TooManyRedirects"));
rb_define_module_function(mPatron, "libcurl_version", libcurl_version, 0);
cSession = rb_define_class_under(mPatron, "Session", rb_cObject);
cRequest = rb_define_class_under(mPatron, "Request", rb_cObject);
rb_define_alloc_func(cSession, session_alloc);
rb_define_method(cSession, "ext_initialize", session_ext_initialize, 0);
rb_define_method(cSession, "escape", session_escape, 1);
rb_define_method(cSession, "unescape", session_unescape, 1);
rb_define_method(cSession, "handle_request", session_handle_request, 1);
rb_define_method(cSession, "enable_cookie_session", enable_cookie_session, 1);
rb_define_const(cRequest, "AuthBasic", INT2FIX(CURLAUTH_BASIC));
rb_define_const(cRequest, "AuthDigest", INT2FIX(CURLAUTH_DIGEST));
rb_define_const(cRequest, "AuthAny", INT2FIX(CURLAUTH_ANY));
mProxyType = rb_define_module_under(mPatron, "ProxyType");
rb_define_const(mProxyType, "HTTP", INT2FIX(CURLPROXY_HTTP));
rb_define_const(mProxyType, "HTTP_1_0", INT2FIX(CURLPROXY_HTTP_1_0));
rb_define_const(mProxyType, "SOCKS4", INT2FIX(CURLPROXY_SOCKS4));
rb_define_const(mProxyType, "SOCKS5", INT2FIX(CURLPROXY_SOCKS5));
rb_define_const(mProxyType, "SOCKS4A", INT2FIX(CURLPROXY_SOCKS4A));
rb_define_const(mProxyType, "SOCKS5_HOSTNAME", INT2FIX(CURLPROXY_SOCKS5_HOSTNAME));
}
示例4: interp_register_builtin
static void
interp_register_builtin()
{
VALUE hVIPSInterpolators = rb_hash_new();
/* Hash of available interpolators. Keys are the symbols, and values are
* interpolator objects.
*/
rb_define_const(cVIPSInterpolator, "INTERPOLATORS", hVIPSInterpolators);
vips_class_map_concrete_all(
g_type_from_name( "VipsInterpolate" ),
(void *) interp_register,
(void *) hVIPSInterpolators
);
}
示例5: Init_msgpack
/**
* Document-module: MessagePack
*
* MessagePack is a binary-based efficient object serialization library.
* It enables to exchange structured objects between many languages like JSON.
* But unlike JSON, it is very fast and small.
*
* You can install MessagePack with rubygems.
*
* gem install msgpack
*
* Simple usage is as follows:
*
* require 'msgpack'
* msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"
* MessagePack.unpack(msg) #=> [1,2,3]
*
* Use Unpacker class for streaming deserialization.
*
*/
void Init_msgpack(void)
{
mMessagePack = rb_define_module("MessagePack");
rb_define_const(mMessagePack, "VERSION", rb_str_new2(MESSAGEPACK_VERSION));
#ifdef COMPAT_HAVE_ENCODING
s_enc_ascii8bit = rb_ascii8bit_encindex();
s_enc_utf8 = rb_utf8_encindex();
s_enc_usascii = rb_usascii_encindex();
s_enc_utf8_value = rb_enc_from_encoding(rb_utf8_encoding());
#endif
Init_msgpack_unpack(mMessagePack);
Init_msgpack_pack(mMessagePack);
}
示例6: Init_gtk_textview
void
Init_gtk_textview()
{
VALUE cTextView = G_DEF_CLASS(GTK_TYPE_TEXT_VIEW, "TextView", mGtk);
id_buffer = rb_intern("buffer");
rb_define_method(cTextView, "initialize", textview_initialize, -1);
G_REPLACE_SET_PROPERTY(cTextView, "buffer", textview_set_buffer, 1);
G_REPLACE_GET_PROPERTY(cTextView, "buffer", textview_get_buffer, 0);
rb_define_method(cTextView, "scroll_to_mark", textview_scroll_to_mark, 5);
rb_define_method(cTextView, "scroll_to_iter", textview_scroll_to_iter, 5);
rb_define_method(cTextView, "scroll_mark_onscreen", textview_scroll_mark_onscreen, 1);
rb_define_method(cTextView, "move_mark_onscreen", textview_move_mark_onscreen, 1);
rb_define_method(cTextView, "place_cursor_onscreen", textview_place_cursor_onscreen, 0);
rb_define_method(cTextView, "visible_rect", textview_get_visible_rect, 0);
rb_define_method(cTextView, "get_iter_location", textview_get_iter_location, 1);
rb_define_method(cTextView, "get_line_at_y", textview_get_line_at_y, 1);
rb_define_method(cTextView, "get_line_yrange", textview_get_line_yrange, 1);
rb_define_method(cTextView, "get_iter_at_location", textview_get_iter_at_location, 2);
#if GTK_CHECK_VERSION(2,6,0)
rb_define_method(cTextView, "get_iter_at_position", textview_get_iter_at_position, 2);
#endif
rb_define_method(cTextView, "buffer_to_window_coords", textview_buffer_to_window_coords, 3);
rb_define_method(cTextView, "window_to_buffer_coords", textview_window_to_buffer_coords, 3);
rb_define_method(cTextView, "get_window", textview_get_window, 1);
rb_define_method(cTextView, "get_window_type", textview_get_window_type, 1);
rb_define_method(cTextView, "set_border_window_size", textview_set_border_window_size, 2);
G_DEF_SETTER(cTextView, "border_window_size");
rb_define_method(cTextView, "get_border_window_size", textview_get_border_window_size, 1);
rb_define_method(cTextView, "forward_display_line", textview_forward_display_line, 1);
rb_define_method(cTextView, "backward_display_line", textview_backward_display_line, 1);
rb_define_method(cTextView, "forward_display_line_end", textview_forward_display_line_end, 1);
rb_define_method(cTextView, "backward_display_line_start", textview_backward_display_line_start, 1);
rb_define_method(cTextView, "starts_display_line", textview_starts_display_line, 1);
rb_define_method(cTextView, "move_visually", textview_move_visually, 2);
rb_define_method(cTextView, "add_child_at_anchor", textview_add_child_at_anchor, 2);
rb_define_method(cTextView, "add_child_in_window", textview_add_child_in_window, 4);
rb_define_method(cTextView, "move_child", textview_move_child, 3);
rb_define_method(cTextView, "default_attributes", textview_get_default_attributes, 0);
/* GtkTextWindowType */
G_DEF_CLASS(GTK_TYPE_TEXT_WINDOW_TYPE, "WindowType", cTextView);
G_DEF_CONSTANTS(cTextView, GTK_TYPE_TEXT_WINDOW_TYPE, "GTK_TEXT_");
rb_define_const(cTextView, "PRIORITY_VALIDATE", INT2FIX(GTK_TEXT_VIEW_PRIORITY_VALIDATE));
}
示例7: rb_grn_init_runtime_version
static void
rb_grn_init_runtime_version (VALUE mGrn)
{
const char *component_start, *component_end;
int component_length;
VALUE runtime_version;
VALUE major, minor, micro, tag;
runtime_version = rb_ary_new();
component_start = grn_get_version();
component_end = strstr(component_start, ".");
component_length = component_end - component_start;
major = rb_str_new(component_start, component_length);
rb_ary_push(runtime_version, rb_Integer(major));
component_start = component_end + 1;
component_end = strstr(component_start, ".");
component_length = component_end - component_start;
minor = rb_str_new(component_start, component_length);
rb_ary_push(runtime_version, rb_Integer(minor));
component_start = component_end + 1;
component_end = strstr(component_start, "-");
if (component_end) {
component_length = component_end - component_start;
} else {
component_length = strlen(component_start);
}
micro = rb_str_new(component_start, component_length);
rb_ary_push(runtime_version, rb_Integer(micro));
if (component_end) {
tag = rb_str_new2(component_end + 1);
} else {
tag = Qnil;
}
rb_ary_push(runtime_version, tag);
rb_obj_freeze(runtime_version);
/*
* 利用しているgroongaのバージョン。 @[メジャーバージョ
* ン, マイナーバージョン, マイクロバージョン, タグ]@ の
* 配列。
*/
rb_define_const(mGrn, "VERSION", runtime_version);
}
示例8: Init_hashpipe
void Init_hashpipe()
{
VALUE mHashpipe;
VALUE cStatus;
mHashpipe = rb_define_module("Hashpipe");
cStatus = rb_define_class_under(mHashpipe, "Status", rb_cObject);
// RECORD_SIZE constant
rb_define_const(cStatus, "RECORD_SIZE",
INT2FIX(HASHPIPE_STATUS_RECORD_SIZE));
rb_define_alloc_func(cStatus, rb_hps_alloc);
rb_define_singleton_method(cStatus, "exists?", rb_hps_exists, 1);
rb_define_method(cStatus, "initialize", rb_hps_init, -1);
rb_define_method(cStatus, "attach", rb_hps_attach, -1);
rb_define_method(cStatus, "detach", rb_hps_detach, 0);
rb_define_method(cStatus, "attached?", rb_hps_attached_p, 0);
rb_define_method(cStatus, "instance_id", rb_hps_instance_id, 0);
rb_define_method(cStatus, "unlock", rb_hps_unlock, 0);
rb_define_method(cStatus, "lock", rb_hps_lock, 0);
rb_define_method(cStatus, "clear!", rb_hps_clear_bang, 0);
rb_define_method(cStatus, "delete", rb_hps_delete, 1);
rb_define_method(cStatus, "buf", rb_hps_buf, 0);
rb_define_method(cStatus, "length", rb_hps_length, 0);
// hget methods
HGET_METHOD(cStatus, i2);
HGET_METHOD(cStatus, i4);
HGET_METHOD(cStatus, i8);
HGET_METHOD(cStatus, u4);
HGET_METHOD(cStatus, u8);
HGET_METHOD(cStatus, r4);
HGET_METHOD(cStatus, r8);
HGET_METHOD(cStatus, s);
// hput methods
HPUT_METHOD(cStatus, i2);
HPUT_METHOD(cStatus, i4);
HPUT_METHOD(cStatus, i8);
HPUT_METHOD(cStatus, u4);
HPUT_METHOD(cStatus, u8);
HPUT_METHOD(cStatus, r4);
HPUT_METHOD(cStatus, r8);
HPUT_METHOD(cStatus, s);
}
示例9: Init_gtk_paper_size
void
Init_gtk_paper_size()
{
#if GTK_CHECK_VERSION(2,10,0)
VALUE gPaperSize = G_DEF_CLASS(GTK_TYPE_PAPER_SIZE, "PaperSize", mGtk);
rb_define_singleton_method(gPaperSize, "default", ps_s_get_default, 0);
rb_define_const(gPaperSize, "A3", rb_str_new2(GTK_PAPER_NAME_A3));
rb_define_const(gPaperSize, "A4", rb_str_new2(GTK_PAPER_NAME_A4));
rb_define_const(gPaperSize, "A5", rb_str_new2(GTK_PAPER_NAME_A5));
rb_define_const(gPaperSize, "B5", rb_str_new2(GTK_PAPER_NAME_B5));
rb_define_const(gPaperSize, "LETTER", rb_str_new2(GTK_PAPER_NAME_LETTER));
rb_define_const(gPaperSize, "EXECUTIVE",
rb_str_new2(GTK_PAPER_NAME_EXECUTIVE));
rb_define_const(gPaperSize, "LEGAL", rb_str_new2(GTK_PAPER_NAME_LEGAL));
rb_define_method(gPaperSize, "initialize", ps_initialize, -1);
rb_define_method(gPaperSize, "==", ps_is_equal, 1);
rb_define_method(gPaperSize, "name", ps_get_name, 0);
rb_define_method(gPaperSize, "display_name", ps_get_display_name, 0);
rb_define_method(gPaperSize, "ppd_name", ps_get_ppd_name, 0);
rb_define_method(gPaperSize, "get_width", ps_get_width, 1);
rb_define_method(gPaperSize, "get_height", ps_get_height, 1);
rb_define_method(gPaperSize, "custom?", ps_is_custom, 0);
rb_define_method(gPaperSize, "set_size", ps_set_size, 3);
rb_define_method(gPaperSize, "get_default_top_margin",
ps_get_default_top_margin, 1);
rb_define_method(gPaperSize, "get_default_bottom_margin",
ps_get_default_bottom_margin, 1);
rb_define_method(gPaperSize, "get_default_left_margin",
ps_get_default_left_margin, 1);
rb_define_method(gPaperSize, "get_default_right_margin",
ps_get_default_right_margin, 1);
G_DEF_SETTERS(gPaperSize);
/* GtkUnit */
G_DEF_CLASS(GTK_TYPE_UNIT, "Unit", gPaperSize);
G_DEF_CONSTANTS(gPaperSize, GTK_TYPE_UNIT, "GTK_");
#endif
}
示例10: rbffi_NullPointer_Init
void
rbffi_NullPointer_Init(VALUE moduleFFI)
{
rbffi_NullPointerClass = rb_define_class_under(moduleFFI, "NullPointer", rbffi_PointerClass);
rb_global_variable(&rbffi_NullPointerClass);
NullPointerErrorClass = rb_define_class_under(moduleFFI, "NullPointerError", rb_eRuntimeError);
rb_global_variable(&NullPointerErrorClass);
rb_define_alloc_func(rbffi_NullPointerClass, nullptr_allocate);
rb_define_method(rbffi_NullPointerClass, "inspect", nullptr_inspect, 0);
rb_define_method(rbffi_NullPointerClass, "+", nullptr_op, -1);
rb_define_method(rbffi_NullPointerClass, "null?", nullptr_null_p, 0);
rb_define_method(rbffi_NullPointerClass, "address", nullptr_address, 0);
rb_define_method(rbffi_NullPointerClass, "==", nullptr_equals, 1);
#define NOP(name) \
rb_define_method(rbffi_NullPointerClass, "get_" #name, nullptr_op, -1); \
rb_define_method(rbffi_NullPointerClass, "put_" #name, nullptr_op, -1); \
rb_define_method(rbffi_NullPointerClass, "get_array_of_" #name, nullptr_op, -1); \
rb_define_method(rbffi_NullPointerClass, "put_array_of_" #name, nullptr_op, -1); \
NOP(int8); NOP(uint8); NOP(int16); NOP(uint16);
NOP(int32); NOP(uint32); NOP(int64); NOP(uint64); NOP(long); NOP(ulong);
NOP(float32); NOP(float64);
NOP(char); NOP(uchar); NOP(short); NOP(ushort);
NOP(int); NOP(uint); NOP(long_long); NOP(ulong_long);
NOP(float); NOP(double);
#undef NOP
#define NOP(name) \
rb_define_method(rbffi_NullPointerClass, "get_" #name, nullptr_op, -1); \
rb_define_method(rbffi_NullPointerClass, "put_" #name, nullptr_op, -1);
NOP(string); NOP(bytes); NOP(pointer); NOP(callback);
rb_define_method(rbffi_NullPointerClass, "clear", nullptr_op, -1); \
rb_define_method(rbffi_NullPointerClass, "total", nullptr_op, -1);
// Create a singleton instance of NullPointer that can be shared
rbffi_NullPointerSingleton = nullptr_allocate(rbffi_NullPointerClass);
rb_global_variable(&rbffi_NullPointerSingleton);
rb_define_const(rbffi_PointerClass, "NULL", rbffi_NullPointerSingleton);
}
示例11: init_ruby_class
void
init_ruby_class()
{
#if 0
// For documentation using YARD
VALUE opencv = rb_define_module("OpenCV");
VALUE cvseq = rb_define_class_under(opencv, "CvSeq");
VALUE curve = rb_define_module_under(opencv, "Curve");
VALUE pointset = rb_define_module_under(opencv, "PointSet");
#endif
if (rb_klass)
return;
VALUE opencv = rb_module_opencv();
VALUE cvseq = cCvSeq::rb_class();
VALUE curve = mCurve::rb_module();
VALUE pointset = mPointSet::rb_module();
rb_klass = rb_define_class_under(opencv, "CvContour", cvseq);
rb_include_module(rb_klass, curve);
rb_include_module(rb_klass, pointset);
rb_define_alloc_func(rb_klass, rb_allocate);
VALUE approx_option = rb_hash_new();
rb_define_const(rb_klass, "APPROX_OPTION", approx_option);
rb_hash_aset(approx_option, ID2SYM(rb_intern("method")), INT2FIX(CV_POLY_APPROX_DP));
rb_hash_aset(approx_option, ID2SYM(rb_intern("accuracy")), rb_float_new(1.0));
rb_hash_aset(approx_option, ID2SYM(rb_intern("recursive")), Qfalse);
rb_define_method(rb_klass, "initialize", RUBY_METHOD_FUNC(rb_initialize), -1);
rb_define_method(rb_klass, "rect", RUBY_METHOD_FUNC(rb_rect), 0);
rb_define_method(rb_klass, "color", RUBY_METHOD_FUNC(rb_color), 0);
rb_define_method(rb_klass, "color=", RUBY_METHOD_FUNC(rb_set_color), 1);
rb_define_method(rb_klass, "reserved", RUBY_METHOD_FUNC(rb_reserved), 0);
rb_define_method(rb_klass, "approx_poly", RUBY_METHOD_FUNC(rb_approx_poly), -1);
rb_define_alias(rb_klass, "approx", "approx_poly");
rb_define_method(rb_klass, "bounding_rect", RUBY_METHOD_FUNC(rb_bounding_rect), 0);
rb_define_method(rb_klass, "create_tree", RUBY_METHOD_FUNC(rb_create_tree), -1);
rb_define_method(rb_klass, "in?", RUBY_METHOD_FUNC(rb_in_q), 1);
rb_define_method(rb_klass, "measure_distance", RUBY_METHOD_FUNC(rb_measure_distance), 1);
rb_define_method(rb_klass, "point_polygon_test", RUBY_METHOD_FUNC(rb_point_polygon_test), 2);
rb_define_method(rb_klass, "match_shapes", RUBY_METHOD_FUNC(rb_match_shapes), -1);
}
示例12: add_obj_name_const
static void
add_obj_name_const(VALUE klass, struct objlist *nobj, const char *name)
{
const char *obj_name;
char str[64];
VALUE val;
if (nobj == NULL) {
val = Qnil;
} else {
obj_name = ngraph_get_object_name(nobj);
strncpy(str, obj_name, sizeof(str) - 1);
str[sizeof(str) - 1] = '\0';
str[0] = toupper(str[0]);
val = ID2SYM(rb_intern(str));
}
rb_define_const(klass, name, val);
}
示例13: Init_pango_main
void
Init_pango_main()
{
rb_define_module_function(mPango, "reorder_items", rpango_reorder_items, 1);
#if PANGO_CHECK_VERSION(1,4,0)
rb_define_module_function(mPango, "unichar_direction", rpango_unichar_direction, 1);
rb_define_module_function(mPango, "find_base_dir", rpango_find_base_dir, 1);
#endif
rb_define_module_function(mPango, "break", rpango_break, 2);
rb_define_module_function(mPango, "get_log_attrs", rpango_get_log_attrs, 3);
rb_define_module_function(mPango, "find_paragraph_boundary", rpango_find_paragraph_boundary, 1);
rb_define_module_function(mPango, "shape", rpango_shape, 2);
rb_define_module_function(mPango, "parse_markup", rpango_parse_markup, -1);
rb_define_module_function(mPango, "pixels", rpango_pixels, 1);
rb_define_const(mPango, "SCALE", INT2FIX(PANGO_SCALE));
}
示例14: Init_ca_obj_unbound_repeat
void
Init_ca_obj_unbound_repeat ()
{
/* rb_cCAUnboudRepeat, CA_OBJ_UNBOUND_REPEAT are defined in rb_carray.c */
rb_define_const(rb_cObject, "CA_OBJ_UNBOUND_REPEAT", INT2NUM(CA_OBJ_UNBOUND_REPEAT));
rb_define_method(rb_cCArray, "unbound_repeat", rb_ca_unbound_repeat, -1);
rb_define_alloc_func(rb_cCAUnboundRepeat, rb_ca_ubrep_s_allocate);
rb_define_method(rb_cCAUnboundRepeat, "initialize_copy",
rb_ca_ubrep_initialize_copy, 1);
rb_define_method(rb_cCAUnboundRepeat, "bind", rb_ca_ubrep_bind, -1);
rb_define_method(rb_cCAUnboundRepeat, "bind_with", ca_ubrep_bind_with, 1);
rb_define_method(rb_cCAUnboundRepeat, "spec", rb_ca_ubrep_spec, 0);
}
示例15: Init_gdk_atom
void
Init_gdk_atom(VALUE mGdk)
{
VALUE none;
VALUE RG_TARGET_NAMESPACE = G_DEF_CLASS(GDK_TYPE_ATOM, "Atom", mGdk);
RG_DEF_SMETHOD(intern, -1);
RG_DEF_METHOD(initialize, 1);
RG_DEF_METHOD(name, 0);
RG_DEF_METHOD(to_i, 0);
RG_DEF_METHOD_OPERATOR("==", equal, 1);
/* This is a trick to define GDK_NONE as a BOXED object */
none = GDKATOM2RVAL((gpointer)1);
rb_define_const(RG_TARGET_NAMESPACE, "NONE", none);
_SELF(none) = GDK_NONE;
}