当前位置: 首页>>代码示例>>C++>>正文


C++ rb_const_set函数代码示例

本文整理汇总了C++中rb_const_set函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_const_set函数的具体用法?C++ rb_const_set怎么用?C++ rb_const_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rb_const_set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Init_native

void Init_native()
{
  mQuail = rb_define_module("Quail");
  rb_const_set(mQuail, rb_intern("LOCAL"), INT2NUM(CZMQ_SCOPE_LOCAL));
  rb_const_set(mQuail, rb_intern("GLOBAL"), INT2NUM(CZMQ_SCOPE_GLOBAL));
  czmq_set_error_handler(error_handler);

  Init_Quail_Handle(mQuail);
  Init_Quail_Exchange(mQuail);
  Init_Quail_Queue(mQuail);
}
开发者ID:tenderlove,项目名称:quail,代码行数:11,代码来源:native.c

示例2: init_libssh2_global

void init_libssh2_global() {
    rb_const_set(rb_mLibSSH2_Native,
            rb_intern("SESSION_BLOCK_INBOUND"),
            INT2FIX(LIBSSH2_SESSION_BLOCK_INBOUND));

    rb_const_set(rb_mLibSSH2_Native,
            rb_intern("SESSION_BLOCK_OUTBOUND"),
            INT2FIX(LIBSSH2_SESSION_BLOCK_OUTBOUND));

    rb_define_singleton_method(rb_mLibSSH2_Native, "exit", libexit, 0);
    rb_define_singleton_method(rb_mLibSSH2_Native, "init", init, 0);
    rb_define_singleton_method(rb_mLibSSH2_Native, "version", version, 0);
}
开发者ID:ccyphers,项目名称:libssh2-ruby,代码行数:13,代码来源:global.c

示例3: Init_nokogiri

void Init_nokogiri()
{
  xmlMemSetup(
      (xmlFreeFunc)ruby_xfree,
      (xmlMallocFunc)ruby_xmalloc,
      (xmlReallocFunc)ruby_xrealloc,
      strdup
  );

  mNokogiri         = rb_define_module("Nokogiri");
  mNokogiriXml      = rb_define_module_under(mNokogiri, "XML");
  mNokogiriHtml     = rb_define_module_under(mNokogiri, "HTML");
  mNokogiriXslt     = rb_define_module_under(mNokogiri, "XSLT");
  mNokogiriXmlSax   = rb_define_module_under(mNokogiriXml, "SAX");
  mNokogiriHtmlSax  = rb_define_module_under(mNokogiriHtml, "SAX");

  rb_const_set( mNokogiri,
                rb_intern("LIBXML_VERSION"),
                NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION, "UTF-8")
              );
  rb_const_set( mNokogiri,
                rb_intern("LIBXML_PARSER_VERSION"),
                NOKOGIRI_STR_NEW2(xmlParserVersion, "UTF-8")
              );

  init_xml_document();
  init_html_document();
  init_xml_node();
  init_xml_document_fragment();
  init_xml_text();
  init_xml_cdata();
  init_xml_processing_instruction();
  init_xml_attr();
  init_xml_entity_reference();
  init_xml_comment();
  init_xml_node_set();
  init_xml_xpath_context();
  init_xml_xpath();
  init_xml_sax_parser();
  init_xml_sax_push_parser();
  init_xml_reader();
  init_xml_dtd();
  init_xml_namespace();
  init_html_sax_parser();
  init_xslt_stylesheet();
  init_xml_syntax_error();
  init_html_entity_lookup();
  init_html_element_description();
  init_xml_schema();
  init_xml_relax_ng();
}
开发者ID:BMorearty,项目名称:Webiva,代码行数:51,代码来源:nokogiri.c

示例4: Init_nyara

void Init_nyara() {
  u8_encoding = rb_utf8_encoding();
  set_fd_limit(20000);

  nyara = rb_define_module("Nyara");
# include "inc/version.inc"
  rb_const_set(nyara, rb_intern("VERSION"), rb_enc_str_new(NYARA_VERSION, strlen(NYARA_VERSION), u8_encoding));

  // utils: hashes
  Init_hashes(nyara);

  // utils: method map
  volatile VALUE method_map = rb_class_new_instance(0, NULL, nyara_param_hash_class);
  rb_const_set(nyara, rb_intern("HTTP_METHODS"), method_map);
  VALUE tmp_key = Qnil;
# define METHOD_STR2NUM(n, name, string) \
    tmp_key = rb_enc_str_new(#string, strlen(#string), u8_encoding);\
    OBJ_FREEZE(tmp_key);\
    rb_hash_aset(method_map, tmp_key, INT2FIX(n));
  HTTP_METHOD_MAP(METHOD_STR2NUM);
# undef METHOD_STR2NUM
  OBJ_FREEZE(method_map);

  // utils: status codes
  volatile VALUE status_map = rb_hash_new();
  rb_const_set(nyara, rb_intern("HTTP_STATUS_CODES"), status_map);
  VALUE tmp_value = Qnil;
# define STATUS_DESC(status, desc) \
    tmp_value = rb_enc_str_new(desc, strlen(desc), u8_encoding);\
    OBJ_FREEZE(tmp_value);\
    rb_hash_aset(status_map, INT2FIX(status), tmp_value);
  HTTP_STATUS_CODES(STATUS_DESC);
# undef STATUS_DESC
  OBJ_FREEZE(status_map);

  VALUE ext = rb_define_module_under(nyara, "Ext");
  rb_define_singleton_method(ext, "rdtsc_start", ext_rdtsc_start, 0);
  rb_define_singleton_method(ext, "rdtsc", ext_rdtsc, 0);

  Init_accept(ext);
  Init_mime(ext);
  Init_request(nyara, ext);
  Init_request_parse(nyara, ext);
  Init_test_response(nyara);
  Init_event(ext);
  Init_route(nyara, ext);
  Init_url_encoded(ext);
}
开发者ID:fsword,项目名称:nyara,代码行数:48,代码来源:nyara.c

示例5: rb_define_class_under

VALUE
rb_define_class_under(VALUE outer, const char *name, VALUE super)
{
    VALUE klass;
    ID id;

    id = rb_intern(name);
    if (rb_const_defined_at(outer, id)) {
	klass = rb_const_get_at(outer, id);
	if (TYPE(klass) != T_CLASS) {
	    rb_raise(rb_eTypeError, "%s is not a class", name);
	}
	if (RCLASS_RUBY(klass)) {
	    // Only for pure Ruby classes, as Objective-C classes
	    // might be returned from the dynamic resolver.
	    if (rb_class_real(RCLASS_SUPER(klass), true) != super) {
		rb_name_error(id, "%s is already defined", name);
	    }
	    return klass;
	}
    }
    if (!super) {
	rb_warn("no super class for `%s::%s', Object assumed",
		rb_class2name(outer), name);
    }
    klass = rb_define_class_id(id, super);
    rb_set_class_path(klass, outer, name);
    rb_const_set(outer, id, klass);
    rb_class_inherited(super, klass);

    return klass;
}
开发者ID:MSch,项目名称:MacRuby,代码行数:32,代码来源:class.c

示例6: rb_define_class

/*!
 * Defines a top-level class.
 * \param name   name of the class
 * \param super  a class from which the new class will derive.
 *               NULL means \c Object class.
 * \return the created class
 * \throw TypeError if the constant name \a name is already taken but
 *                  the constant is not a \c Class.
 * \throw NameError if the class is already defined but the class can not
 *                  be reopened because its superclass is not \a super.
 * \post top-level constant named \a name refers the returned class.
 *
 * \note if a class named \a name is already defined and its superclass is
 *       \a super, the function just returns the defined class.
 */
VALUE
rb_define_class(const char *name, VALUE super)
{
    VALUE klass;
    ID id;

    id = rb_intern(name);
    if (rb_const_defined(rb_cObject, id)) {
	klass = rb_const_get(rb_cObject, id);
	if (!RB_TYPE_P(klass, T_CLASS)) {
	    rb_raise(rb_eTypeError, "%s is not a class", name);
	}
	if (rb_class_real(RCLASS_SUPER(klass)) != super) {
	    rb_raise(rb_eTypeError, "superclass mismatch for class %s", name);
	}
	return klass;
    }
    if (!super) {
	rb_warn("no super class for `%s', Object assumed", name);
    }
    klass = rb_define_class_id(id, super);
    rb_vm_add_root_module(id, klass);
    rb_name_class(klass, id);
    rb_const_set(rb_cObject, id, klass);
    rb_class_inherited(super, klass);

    return klass;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:43,代码来源:class.c

示例7: Init_rcovrt

void Init_rcovrt() {
  ID id_rcov = rb_intern("Rcov");
  ID id_coverage__ = rb_intern("RCOV__");
  ID id_script_lines__ = rb_intern("SCRIPT_LINES__");
 
  id_cover = rb_intern("COVER");
  
  if(rb_const_defined(rb_cObject, id_rcov)) 
    mRcov = rb_const_get(rb_cObject, id_rcov);
  else
    mRcov = rb_define_module("Rcov");
  
  if(rb_const_defined(mRcov, id_coverage__))
    mRCOV__ = rb_const_get_at(mRcov, id_coverage__);
  else
    mRCOV__ = rb_define_module_under(mRcov, "RCOV__");
  
  if(rb_const_defined(rb_cObject, id_script_lines__))
    oSCRIPT_LINES__ = rb_const_get(rb_cObject, rb_intern("SCRIPT_LINES__"));
  else {
    oSCRIPT_LINES__ = rb_hash_new();
    rb_const_set(rb_cObject, id_script_lines__, oSCRIPT_LINES__);
  }
  
  coverage_hook_set_p = 0;
  
  rb_define_singleton_method(mRCOV__, "install_coverage_hook", cov_install_coverage_hook, 0);
  rb_define_singleton_method(mRCOV__, "remove_coverage_hook",  cov_remove_coverage_hook, 0);
  rb_define_singleton_method(mRCOV__, "generate_coverage_info", cov_generate_coverage_info, 0);
  rb_define_singleton_method(mRCOV__, "reset_coverage", cov_reset_coverage, 0);
  rb_define_singleton_method(mRCOV__, "ABI", cov_ABI, 0);
  
  Init_rcov_callsite();
}
开发者ID:CoralineAda,项目名称:rcov,代码行数:34,代码来源:rcovrt.c

示例8: rb_define_class_id_under

/*!
 * Defines a class under the namespace of \a outer.
 * \param outer  a class which contains the new class.
 * \param id     name of the new class
 * \param super  a class from which the new class will derive.
 *               NULL means \c Object class.
 * \return the created class
 * \throw TypeError if the constant name \a name is already taken but
 *                  the constant is not a \c Class.
 * \throw NameError if the class is already defined but the class can not
 *                  be reopened because its superclass is not \a super.
 * \post top-level constant named \a name refers the returned class.
 *
 * \note if a class named \a name is already defined and its superclass is
 *       \a super, the function just returns the defined class.
 */
VALUE
rb_define_class_id_under(VALUE outer, ID id, VALUE super)
{
    VALUE klass;

    if (rb_const_defined_at(outer, id)) {
	klass = rb_const_get_at(outer, id);
	if (TYPE(klass) != T_CLASS) {
	    rb_raise(rb_eTypeError, "%s is not a class", rb_id2name(id));
	}
	if (rb_class_real(RCLASS_SUPER(klass)) != super) {
	    rb_name_error(id, "%s is already defined", rb_id2name(id));
	}
	return klass;
    }
    if (!super) {
	rb_warn("no super class for `%s::%s', Object assumed",
		rb_class2name(outer), rb_id2name(id));
    }
    klass = rb_define_class_id(id, super);
    rb_set_class_path_string(klass, outer, rb_id2str(id));
    rb_const_set(outer, id, klass);
    rb_class_inherited(super, klass);
    rb_gc_register_mark_object(klass);

    return klass;
}
开发者ID:fi8on,项目名称:ruby,代码行数:43,代码来源:class.c

示例9: rb_define_class

VALUE
rb_define_class(const char *name, VALUE super)
{
    VALUE klass;
    ID id;

    id = rb_intern(name);
    if (rb_const_defined(rb_cObject, id)) {
	klass = rb_const_get(rb_cObject, id);
	if (TYPE(klass) != T_CLASS) {
	    rb_raise(rb_eTypeError, "%s is not a class", name);
	}
	if (rb_class_real(RCLASS_SUPER(klass)) != super) {
	    rb_name_error(id, "%s is already defined", name);
	}
	return klass;
    }
    if (!super) {
	rb_warn("no super class for `%s', Object assumed", name);
    }
    klass = rb_define_class_id(id, super);
    st_add_direct(rb_class_tbl, id, klass);
    rb_name_class(klass, id);
    rb_const_set(rb_cObject, id, klass);
    rb_class_inherited(super, klass);

    return klass;
}
开发者ID:technohippy,项目名称:oruby,代码行数:28,代码来源:class.c

示例10: Init_PNG

void
Init_PNG()
{
    VALUE mAxon, mPNG, cPNGReader;

    mAxon = rb_define_module("Axon");
    mPNG = rb_define_module_under(mAxon, "PNG");
    rb_const_set(mPNG, rb_intern("LIB_VERSION"), INT2FIX(PNG_LIBPNG_VER));
    rb_define_singleton_method(mPNG, "write", write_png, 2);

    cPNGReader = rb_define_class_under(mPNG, "Reader", rb_cObject);
    rb_define_alloc_func(cPNGReader, allocate);
    rb_define_method(cPNGReader, "initialize", initialize, 1);
    rb_define_method(cPNGReader, "color_model", color_model, 0);
    rb_define_method(cPNGReader, "components", components, 0);
    rb_define_method(cPNGReader, "width", width, 0);
    rb_define_method(cPNGReader, "height", height, 0);
    rb_define_method(cPNGReader, "gets", p_gets, 0);
    rb_define_method(cPNGReader, "lineno", lineno, 0);

    id_GRAYSCALE = rb_intern("GRAYSCALE");
    id_RGB = rb_intern("RGB");
    id_GRAYSCALE = rb_intern("GRAYSCALE_ALPHA");
    id_RGB = rb_intern("RGB_ALPHA");
    id_write = rb_intern("write");
    id_read = rb_intern("read");
    id_gets = rb_intern("gets");
    id_width = rb_intern("width");
    id_height = rb_intern("height");
    id_color_model = rb_intern("color_model");
    id_components = rb_intern("components");
}
开发者ID:ender672,项目名称:axon,代码行数:32,代码来源:png.c

示例11: Init_native

void Init_native()
{
  mNokogiri = rb_const_get(rb_cObject, rb_intern("Nokogiri"));
  mNokogiriXml = rb_const_get(mNokogiri, rb_intern("XML"));
  mNokogiriHtml = rb_const_get(mNokogiri, rb_intern("HTML"));
  mNokogiriXslt = rb_const_get(mNokogiri, rb_intern("XSLT"));
  mNokogiriXmlSax = rb_const_get(mNokogiriXml, rb_intern("SAX"));
  mNokogiriHtmlSax = rb_const_get(mNokogiriHtml, rb_intern("SAX"));

  rb_const_set( mNokogiri,
                rb_intern("LIBXML_VERSION"),
                rb_str_new2(LIBXML_DOTTED_VERSION)
              );

  xmlSetStructuredErrorFunc(NULL, Nokogiri_error_handler);

  init_xml_document();
  init_html_document();
  init_xml_node();
  init_xml_text();
  init_xml_cdata();
  init_xml_node_set();
  init_xml_xpath_context();
  init_xml_xpath();
  init_xml_sax_parser();
  init_xml_reader();
  init_xml_dtd();
  init_html_sax_parser();
  init_xslt_stylesheet();
  init_xml_syntax_error();
}
开发者ID:TheDragon,项目名称:merb-book,代码行数:31,代码来源:native.c

示例12: rb_define_class_under

VALUE
rb_define_class_under(VALUE outer, const char *name, VALUE super)
{
    VALUE klass;
    ID id;

    id = rb_intern(name);
    if (rb_const_defined_at(outer, id)) {
	klass = rb_const_get_at(outer, id);
	if (TYPE(klass) != T_CLASS) {
	    rb_raise(rb_eTypeError, "%s is not a class", name);
	}
	if (rb_class_real(RCLASS_SUPER(klass)) != super) {
	    rb_name_error(id, "%s is already defined", name);
	}
	return klass;
    }
    if (!super) {
	rb_warn("no super class for `%s::%s', Object assumed",
		rb_class2name(outer), name);
    }
    klass = rb_define_class_id(id, super);
    rb_set_class_path(klass, outer, name);
    rb_const_set(outer, id, klass);
    rb_class_inherited(super, klass);

    return klass;
}
开发者ID:technohippy,项目名称:oruby,代码行数:28,代码来源:class.c

示例13: Init_request_parse

void Init_request_parse(VALUE nyara) {
  str_accept = rb_enc_str_new("Accept", strlen("Accept"), u8_encoding);
  rb_gc_register_mark_object(str_accept);
  method_override_key = rb_enc_str_new("_method", strlen("_method"), u8_encoding);
  OBJ_FREEZE(method_override_key);
  rb_const_set(nyara, rb_intern("METHOD_OVERRIDE_KEY"), method_override_key);
  nyara_http_methods = rb_const_get(nyara, rb_intern("HTTP_METHODS"));
}
开发者ID:hooopo,项目名称:nyara,代码行数:8,代码来源:request_parse.c

示例14: Init_rugged_index

/*
 *  Document-class: Rugged::Index
 *
 *  == Index Entries
 *
 *  Index entries are represented as Hash instances with the following key/value pairs:
 *
 *  path: ::
 *    The entry's path in the index.
 *
 *  oid: ::
 *    The oid of the entry's git object (blob / tree).
 *
 *  dev: ::
 *    The device for the index entry.
 *
 *  ino: ::
 *    The inode for the index entry.
 *
 *  mode: ::
 *    The current permissions of the index entry.
 *
 *  gid: ::
 *    Group ID of the index entry's owner.
 *
 *  uid: ::
 *    User ID of the index entry's owner.
 *
 *  file_size: ::
 *    The index entry's size, in bytes.
 *
 *  valid: ::
 *    +true+ if the index entry is valid, +false+ otherwise.
 *
 *  stage: ::
 *    The current stage of the index entry.
 *
 *  mtime: ::
 *    A Time instance representing the index entry's time of last modification.
 *
 *  mtime: ::
 *    A Time instance representing the index entry's time of last status change
 *    (ie. change of owner, group, mode, etc.).
 */
void Init_rugged_index(void)
{
	/*
	 * Index
	 */
	rb_cRuggedIndex = rb_define_class_under(rb_mRugged, "Index", rb_cObject);
	rb_define_singleton_method(rb_cRuggedIndex, "new", rb_git_index_new, -1);

	rb_define_method(rb_cRuggedIndex, "count", rb_git_index_count, 0);
	rb_define_method(rb_cRuggedIndex, "reload", rb_git_index_read, 0);
	rb_define_method(rb_cRuggedIndex, "clear", rb_git_index_clear, 0);
	rb_define_method(rb_cRuggedIndex, "write", rb_git_index_write, 0);
	rb_define_method(rb_cRuggedIndex, "get", rb_git_index_get, -1);
	rb_define_method(rb_cRuggedIndex, "[]", rb_git_index_get, -1);
	rb_define_method(rb_cRuggedIndex, "each", rb_git_index_each, 0);
	rb_define_private_method(rb_cRuggedIndex, "diff_tree_to_index", rb_git_diff_tree_to_index, 2);
	rb_define_private_method(rb_cRuggedIndex, "diff_index_to_workdir", rb_git_diff_index_to_workdir, 1);

	rb_define_method(rb_cRuggedIndex, "conflicts?", rb_git_index_conflicts_p, 0);
	rb_define_method(rb_cRuggedIndex, "conflicts", rb_git_index_conflicts, 0);
	rb_define_method(rb_cRuggedIndex, "conflict_get", rb_git_conflict_get, 1);
	rb_define_method(rb_cRuggedIndex, "conflict_add", rb_git_conflict_add, 1);
	rb_define_method(rb_cRuggedIndex, "conflict_remove", rb_git_conflict_remove, 1);
	rb_define_method(rb_cRuggedIndex, "conflict_cleanup", rb_git_conflict_cleanup, 0);

	rb_define_method(rb_cRuggedIndex, "merge_file", rb_git_merge_file, -1);

	rb_define_method(rb_cRuggedIndex, "add", rb_git_index_add, 1);
	rb_define_method(rb_cRuggedIndex, "update", rb_git_index_add, 1);
	rb_define_method(rb_cRuggedIndex, "<<", rb_git_index_add, 1);

	rb_define_method(rb_cRuggedIndex, "remove", rb_git_index_remove, -1);
	rb_define_method(rb_cRuggedIndex, "remove_dir", rb_git_index_remove_directory, -1);

	rb_define_method(rb_cRuggedIndex, "add_all", rb_git_index_add_all, -1);
	rb_define_method(rb_cRuggedIndex, "update_all", rb_git_index_update_all, -1);
	rb_define_method(rb_cRuggedIndex, "remove_all", rb_git_index_remove_all, -1);

	rb_define_method(rb_cRuggedIndex, "write_tree", rb_git_index_writetree, -1);
	rb_define_method(rb_cRuggedIndex, "read_tree", rb_git_index_readtree, 1);

	rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_STAGE"), INT2FIX(GIT_IDXENTRY_STAGEMASK));
	rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_STAGE_SHIFT"), INT2FIX(GIT_IDXENTRY_STAGESHIFT));
	rb_const_set(rb_cRuggedIndex, rb_intern("ENTRY_FLAGS_VALID"), INT2FIX(GIT_IDXENTRY_VALID));
}
开发者ID:Angeldude,项目名称:sonic-pi,代码行数:89,代码来源:rugged_index.c

示例15: boot_defclass

static VALUE
boot_defclass(const char *name, VALUE super)
{
    VALUE obj = rb_class_boot(super);
    ID id = rb_intern(name);

    rb_name_class(obj, id);
    rb_const_set((rb_cObject ? rb_cObject : obj), id, obj);
    return obj;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:10,代码来源:class.c


注:本文中的rb_const_set函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。