本文整理汇总了C++中rb_obj_freeze函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_obj_freeze函数的具体用法?C++ rb_obj_freeze怎么用?C++ rb_obj_freeze使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_obj_freeze函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: rb_grn_init_version
static void
rb_grn_init_version (VALUE mGrn)
{
VALUE build_version, bindings_version;
rb_grn_init_runtime_version(mGrn);
build_version = rb_ary_new3(3,
INT2NUM(GRN_MAJOR_VERSION),
INT2NUM(GRN_MINOR_VERSION),
INT2NUM(GRN_MICRO_VERSION));
rb_obj_freeze(build_version);
/*
* ビルドしたgroongaのバージョン。 @[メジャーバージョン,
* マイナーバージョン, マイクロバージョン]@ の配列。
*/
rb_define_const(mGrn, "BUILD_VERSION", build_version);
bindings_version = rb_ary_new3(3,
INT2NUM(RB_GRN_MAJOR_VERSION),
INT2NUM(RB_GRN_MINOR_VERSION),
INT2NUM(RB_GRN_MICRO_VERSION));
rb_obj_freeze(bindings_version);
/*
* rroongaのバージョン。 @[メジャーバージョン, マ
* イナーバージョン, マイクロバージョン]@ の配列。
*/
rb_define_const(mGrn, "BINDINGS_VERSION", bindings_version);
}
开发者ID:cosmo0920,项目名称:rroonga,代码行数:29,代码来源:rb-groonga.c
示例2: pg_define_coder
void
pg_define_coder( const char *name, void *func, VALUE klass, VALUE nsp )
{
VALUE type_obj = Data_Wrap_Struct( klass, NULL, NULL, func );
VALUE objname = rb_str_dup(rb_mod_name(nsp));
rb_str_cat2( objname, "::");
rb_str_cat2( objname, name);
rb_iv_set( type_obj, "@name", rb_obj_freeze(objname) );
rb_define_const( nsp, name, rb_obj_freeze(type_obj) );
RB_GC_GUARD(type_obj);
}
开发者ID:willbryant,项目名称:ruby-pg,代码行数:13,代码来源:pg_coder.c
示例3: lookup_sig
static int lookup_sig(VALUE sig)
{
static VALUE list;
const char *ptr;
long len;
sig = rb_obj_as_string(sig);
len = RSTRING_LEN(sig);
ptr = RSTRING_PTR(sig);
if (len > 3 && !memcmp("SIG", ptr, 3))
sig = rb_str_new(ptr + 3, len - 3);
if (!list) {
VALUE mSignal = rb_const_get(rb_cObject, rb_intern("Signal"));
list = rb_funcall(mSignal, rb_intern("list"), 0);
rb_obj_freeze(list);
rb_global_variable(&list);
}
sig = rb_hash_aref(list, sig);
if (NIL_P(sig))
rb_raise(rb_eArgError, "invalid signal: %s\n", ptr);
return NUM2INT(sig);
}
开发者ID:tmm1,项目名称:ruby_posix_mq,代码行数:27,代码来源:posix_mq.c
示例4: env_str_new
static VALUE
env_str_new(const char *ptr, long len)
{
VALUE str = rb_tainted_str_new(ptr, len);
rb_obj_freeze(str);
return str;
}
开发者ID:Hunter-Dolan,项目名称:MacRuby,代码行数:7,代码来源:env.c
示例5: _class_get
DLL_LOCAL VALUE _class_get(int argc,VALUE *argv,VALUE self)
{
VALUE size,family,style,weight,underlined;
rb_scan_args(argc, argv, "41",&size,&family,&style,&weight,&underlined);
//TODO add refcounting
wxFont *font = wxTheFontList->FindOrCreateFont(
RB_NUM2INT(size),
unwrapenum<wxFontFamily>(family),
unwrapenum<wxFontStyle>(style),
unwrapenum<wxFontWeight>(weight),
RTEST(underlined)
);
if(!font || !font->IsOk())
return Qnil;
//look in the FontList holder is font was already wrapped
fontlisttype::iterator it = fontlistholder.find(font);
if(it != fontlistholder.end()) {
return it->second;
} else {
//wrap wxFont pointer to ruby object
VALUE result = wrap(font);
//FontList objects should not be changed
rb_obj_freeze(result);
//Prevent FontList objects from been deleted
rwx_refobject(result);
//add wrapped font to the FontList holder to find it again
fontlistholder[font] = result;
return result;
}
}
开发者ID:Hanmac,项目名称:rwx,代码行数:34,代码来源:wxFont.cpp
示例6: layout_get_default
VALUE layout_get_default(const upb_fielddef *field) {
switch (upb_fielddef_type(field)) {
case UPB_TYPE_FLOAT: return DBL2NUM(upb_fielddef_defaultfloat(field));
case UPB_TYPE_DOUBLE: return DBL2NUM(upb_fielddef_defaultdouble(field));
case UPB_TYPE_BOOL:
return upb_fielddef_defaultbool(field) ? Qtrue : Qfalse;
case UPB_TYPE_MESSAGE: return Qnil;
case UPB_TYPE_ENUM: {
const upb_enumdef *enumdef = upb_fielddef_enumsubdef(field);
int32_t num = upb_fielddef_defaultint32(field);
const char *label = upb_enumdef_iton(enumdef, num);
if (label) {
return ID2SYM(rb_intern(label));
} else {
return INT2NUM(num);
}
}
case UPB_TYPE_INT32: return INT2NUM(upb_fielddef_defaultint32(field));
case UPB_TYPE_INT64: return LL2NUM(upb_fielddef_defaultint64(field));;
case UPB_TYPE_UINT32: return UINT2NUM(upb_fielddef_defaultuint32(field));
case UPB_TYPE_UINT64: return ULL2NUM(upb_fielddef_defaultuint64(field));
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES: {
size_t size;
const char *str = upb_fielddef_defaultstr(field, &size);
VALUE str_rb = rb_str_new(str, size);
rb_enc_associate(str_rb, (upb_fielddef_type(field) == UPB_TYPE_BYTES) ?
kRubyString8bitEncoding : kRubyStringUtf8Encoding);
rb_obj_freeze(str_rb);
return str_rb;
}
default: return Qnil;
}
}
开发者ID:acozzette,项目名称:protobuf,代码行数:35,代码来源:storage.c
示例7: rb_iv_set
// View#getInverseTransform()
// View#get_inverse_transform()
// View#inverse_transform()
VALUE rbView::GetInverseTransform( VALUE aSelf )
{
const sf::Transform& transform = rbMacros::ToSFML< sf::View >( aSelf, rbView::Class )->getInverseTransform();
VALUE obj = rbMacros::ToRuby( const_cast< sf::Transform* >( &transform ), rbTransform::Class );
rb_iv_set( obj, "@__ref__owner", aSelf );
rb_obj_freeze( obj );
return obj;
}
开发者ID:silverhammermba,项目名称:rbSFML,代码行数:11,代码来源:View.cpp
示例8: Init_version
void
Init_version()
{
VALUE v = rb_obj_freeze(rb_str_new2(ruby_version));
VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date));
VALUE p = rb_obj_freeze(rb_str_new2(ruby_platform));
rb_define_global_const("RUBY_VERSION", v);
rb_define_global_const("RUBY_RELEASE_DATE", d);
rb_define_global_const("RUBY_PLATFORM", p);
rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
/* obsolete constants */
rb_define_global_const("VERSION", v);
rb_define_global_const("RELEASE_DATE", d);
rb_define_global_const("PLATFORM", p);
}
开发者ID:cygwin-fork,项目名称:ruby186,代码行数:17,代码来源:version.c
示例9: rb_iv_set
// RenderTexture#texture
// RenderTexture#get_texture
// RenderTexture#getTexture
VALUE rbRenderTexture::GetTexture( VALUE aSelf )
{
const sf::Texture& texture = rbMacros::ToSFML< sf::RenderTexture >( aSelf, rbRenderTexture::Class )->getTexture();
VALUE object = rbMacros::ToRubyNoGC( const_cast< sf::Texture* >( &texture ), rbTexture::Class );
rb_iv_set( object, "@__ref__owner", aSelf );
rb_obj_freeze( object );
return object;
}
开发者ID:paulas,项目名称:rbSFML,代码行数:11,代码来源:RenderTexture.cpp
示例10: rb_array_buffer_to_s
/*
* call-seq:
* buf.to_s => String
*
* Returns a String (binary) representation of the buffer.
*
* === Examples
* buf = ArrayBuffer.new("buffer") => ArrayBuffer
* buf.byte_length => 6
* buf.to_s => "buffer"
*
*/
VALUE rb_array_buffer_to_s(VALUE obj)
{
VALUE str;
GetArrayBuffer(obj);
str = rb_str_new((const char*)buf->buf, buf->length);
ArrayBufferEncode(str);
return rb_obj_freeze(str);
}
开发者ID:methodmissing,项目名称:type_array,代码行数:20,代码来源:array_buffer.c
示例11: set_rack_input
static void
set_rack_input(VALUE env, struct evbuffer* evbuffer)
{
VALUE str = rb_str_new((const char*)EVBUFFER_DATA(evbuffer),
EVBUFFER_LENGTH(evbuffer));
rb_obj_freeze(str);
volatile VALUE ret = rb_funcall(rb_cStringIO, rb_intern("new"), 1, str);
rb_hash_aset(env, global_envs[GE_RACK_INPUT], ret);
}
开发者ID:miyucy,项目名称:aspirin,代码行数:9,代码来源:response.c
示例12: Init_oci8
VALUE Init_oci8(void)
{
#if 0
oci8_cOCIHandle = rb_define_class("OCIHandle", rb_cObject);
cOCI8 = rb_define_class("OCI8", oci8_cOCIHandle);
#endif
cOCI8 = oci8_define_class("OCI8", &oci8_svcctx_class);
cSession = oci8_define_class_under(cOCI8, "Session", &oci8_svcctx_associate_class);
cServer = oci8_define_class_under(cOCI8, "Server", &oci8_svcctx_associate_class);
id_at_session_handle = rb_intern("@session_handle");
id_at_server_handle = rb_intern("@server_handle");
oracle_client_vernum = INT2FIX(oracle_client_version);
if (have_OCIClientVersion) {
sword major, minor, update, patch, port_update;
OCIClientVersion(&major, &minor, &update, &patch, &port_update);
oracle_client_vernum = INT2FIX(ORAVERNUM(major, minor, update, patch, port_update));
}
sym_SYSDBA = ID2SYM(rb_intern("SYSDBA"));
sym_SYSOPER = ID2SYM(rb_intern("SYSOPER"));
id_at_prefetch_rows = rb_intern("@prefetch_rows");
id_set_prefetch_rows = rb_intern("prefetch_rows=");
rb_define_const(cOCI8, "VERSION", rb_obj_freeze(rb_usascii_str_new_cstr(OCI8LIB_VERSION)));
rb_define_singleton_method_nodoc(cOCI8, "oracle_client_vernum", oci8_s_oracle_client_vernum, 0);
rb_define_singleton_method_nodoc(cOCI8, "__set_property", oci8_s_set_property, 2);
if (have_OCIMessageOpen && have_OCIMessageGet) {
rb_define_singleton_method(cOCI8, "error_message", oci8_s_error_message, 1);
}
rb_define_private_method(cOCI8, "parse_connect_string", oci8_parse_connect_string, 1);
rb_define_private_method(cOCI8, "logon", oci8_logon, 3);
rb_define_private_method(cOCI8, "allocate_handles", oci8_allocate_handles, 0);
rb_define_private_method(cOCI8, "session_handle", oci8_get_session_handle, 0);
rb_define_private_method(cOCI8, "server_handle", oci8_get_server_handle, 0);
rb_define_private_method(cOCI8, "server_attach", oci8_server_attach, 2);
rb_define_private_method(cOCI8, "session_begin", oci8_session_begin, 2);
rb_define_method(cOCI8, "logoff", oci8_svcctx_logoff, 0);
rb_define_method(cOCI8, "parse", oci8_svcctx_parse, 1);
rb_define_method(cOCI8, "commit", oci8_commit, 0);
rb_define_method(cOCI8, "rollback", oci8_rollback, 0);
rb_define_method(cOCI8, "non_blocking?", oci8_non_blocking_p, 0);
rb_define_method(cOCI8, "non_blocking=", oci8_set_non_blocking, 1);
rb_define_method(cOCI8, "autocommit?", oci8_autocommit_p, 0);
rb_define_method(cOCI8, "autocommit=", oci8_set_autocommit, 1);
rb_define_method(cOCI8, "long_read_len", oci8_long_read_len, 0);
rb_define_method(cOCI8, "long_read_len=", oci8_set_long_read_len, 1);
rb_define_method(cOCI8, "break", oci8_break, 0);
rb_define_method(cOCI8, "prefetch_rows=", oci8_set_prefetch_rows, 1);
rb_define_private_method(cOCI8, "oracle_server_vernum", oci8_oracle_server_vernum, 0);
rb_define_method(cOCI8, "ping", oci8_ping, 0);
rb_define_method(cOCI8, "client_identifier=", oci8_set_client_identifier, 1);
rb_define_method(cOCI8, "module=", oci8_set_module, 1);
rb_define_method(cOCI8, "action=", oci8_set_action, 1);
rb_define_method(cOCI8, "client_info=", oci8_set_client_info, 1);
return cOCI8;
}
开发者ID:jcasts,项目名称:ruby-oci8,代码行数:57,代码来源:oci8.c
示例13: Init_wkhtml_native
void Init_wkhtml_native() {
//Global initialization of library and when Ruby shuts down
wkhtmltopdf_init(USE_GRAPHICS_INT);
wkhtmltoimage_init(USE_GRAPHICS_INT);
rb_set_end_proc(Deinit_wkhtml_native, Qnil);
idReady = rb_intern("ready");
mWkHtml = rb_define_module("WkHtml");
rb_define_const(mWkHtml, "LIBRARY_VERSION", rb_obj_freeze(rb_str_new_cstr(wkhtmltopdf_version())));
rb_define_const(mWkHtml, "USE_GRAPHICS", INT2BOOL(USE_GRAPHICS_INT));
mWkHtmlToPdf = rb_define_module_under(mWkHtml, "ToPdf");
cWkHtmlToPdfGlobalSettings = rb_define_class_under(mWkHtmlToPdf, "GlobalSettings", rb_cObject);
rb_define_alloc_func(cWkHtmlToPdfGlobalSettings, wkhtml_topdf_globalsettings_alloc);
rb_define_method(cWkHtmlToPdfGlobalSettings, "[]=", wkhtml_topdf_globalsettings_aset, 2);
rb_define_method(cWkHtmlToPdfGlobalSettings, "[]", wkhtml_topdf_globalsettings_aref, 1);
cWkHtmlToPdfObjectSettings = rb_define_class_under(mWkHtmlToPdf, "ObjectSettings", rb_cObject);
rb_define_alloc_func(cWkHtmlToPdfObjectSettings, wkhtml_topdf_objectsettings_alloc);
rb_define_method(cWkHtmlToPdfObjectSettings, "[]=", wkhtml_topdf_objectsettings_aset, 2);
rb_define_method(cWkHtmlToPdfObjectSettings, "[]", wkhtml_topdf_objectsettings_aref, 1);
cWkHtmlToPdfConverter = rb_define_class_under(mWkHtmlToPdf, "Converter", rb_cObject);
/*
TODO
rb_define_singleton_method(klass, "new", constructor, 1); //Uses Data_Wrap_Struct -> rb_obj_call_init(t_data, 1, argv);
rb_define_method(klass, "initialize", initialize, 1);
*/
rb_define_singleton_method(cWkHtmlToPdfConverter, "create", wkhtml_topdf_converter_create, 1);
rb_define_method(cWkHtmlToPdfConverter, "add_object", wkhtml_topdf_converter_add_object, 2);
rb_define_method(cWkHtmlToPdfConverter, "convert", wkhtml_topdf_converter_convert, 0);
rb_define_method(cWkHtmlToPdfConverter, "http_error_code", wkhtml_topdf_converter_http_error_code, 0);
rb_define_method(cWkHtmlToPdfConverter, "get_output", wkhtml_topdf_converter_get_output, 0);
//Force use of factory method
rb_undef_alloc_func(cWkHtmlToPdfConverter);
rb_undef_method(rb_singleton_class(cWkHtmlToPdfConverter), "new");
mWkHtmlToImage = rb_define_module_under(mWkHtml, "ToImage");
cWkHtmlToImageGlobalSettings = rb_define_class_under(mWkHtmlToImage, "GlobalSettings", rb_cObject);
rb_define_alloc_func(cWkHtmlToImageGlobalSettings, wkhtml_toimage_globalsettings_alloc);
rb_define_method(cWkHtmlToImageGlobalSettings, "[]=", wkhtml_toimage_globalsettings_aset, 2);
rb_define_method(cWkHtmlToImageGlobalSettings, "[]", wkhtml_toimage_globalsettings_aref, 1);
cWkHtmlToImageConverter = rb_define_class_under(mWkHtmlToImage, "Converter", rb_cObject);
rb_define_singleton_method(cWkHtmlToImageConverter, "create", wkhtml_toimage_converter_create, 2);
rb_define_method(cWkHtmlToImageConverter, "convert", wkhtml_toimage_converter_convert, 0);
rb_define_method(cWkHtmlToImageConverter, "http_error_code", wkhtml_toimage_converter_http_error_code, 0);
rb_define_method(cWkHtmlToImageConverter, "get_output", wkhtml_toimage_converter_get_output, 0);
//Force use of factory method
rb_undef_alloc_func(cWkHtmlToImageConverter);
rb_undef_method(rb_singleton_class(cWkHtmlToImageConverter), "new");
}
开发者ID:carsonreinke,项目名称:wkhtml,代码行数:55,代码来源:wkhtml.c
示例14: add_modules
static void
add_modules(struct cmdline_options *opt, const char *mod)
{
VALUE list = opt->req_list;
if (!list) {
opt->req_list = list = rb_ary_new();
RBASIC(list)->klass = 0;
}
rb_ary_push(list, rb_obj_freeze(rb_str_new2(mod)));
}
开发者ID:Netfart,项目名称:rhodes,代码行数:11,代码来源:ruby.c
示例15: rb_ary_new2
// Transform#matrix
// Transform#get_matrix
// Transform#getMatrix
VALUE rbTransform::GetMatrix( VALUE aSelf )
{
const float* values = rbMacros::ToSFML< sf::Transform >( aSelf, rbTransform::Class )->getMatrix();
VALUE array = rb_ary_new2( 16 );
for( unsigned int index = 0; index < 16; index++ )
{
rb_ary_store( array, index, rb_float_new( values[ index ] ) );
}
rb_obj_freeze( array );
return array;
}
开发者ID:CaptainJet,项目名称:rbSFML,代码行数:14,代码来源:Transform.cpp
示例16: sandbox
static inline VALUE sandbox(const char * name, uint64_t flags) {
VALUE obj = rb_sandbox_s_alloc(rb_cSandbox);
rb_sandbox_t * box;
Data_Get_Struct(obj, rb_sandbox_t, box);
box->profile = strcpy(malloc(strlen(name)), name);
box->flags = flags;
return rb_obj_freeze(obj);
}
开发者ID:jensnockert,项目名称:artemis-sandbox,代码行数:12,代码来源:artemis_sandbox.c
示例17: rb_iv_set
// RenderStates#initialize_copy(state)
VALUE rbRenderStates::InitializeCopy( VALUE aSelf, VALUE aState )
{
sf::RenderStates* states = rbRenderStates::ToSFML( aSelf );
*states = *rbRenderStates::ToSFML( aState );
VALUE transform = rbMacros::ToRubyNoGC( &states->transform, rbTransform::Class );
rb_iv_set( aSelf, "@__ref__transform", transform );
rb_iv_set( transform, "@__ref__state_owner", aSelf );
rb_obj_freeze( transform );
VALUE texture = rbMacros::ToRubyNoGC( const_cast< sf::Texture* >( states->texture ), rbTexture::Class );
rb_iv_set( aSelf, "@__ref__texture", texture );
rb_iv_set( texture, "@__ref__state_owner", aSelf );
rb_obj_freeze( texture );
VALUE shader = rbMacros::ToRubyNoGC( const_cast< sf::Shader* >( states->shader ), rbShader::Class );
rb_iv_set( aSelf, "@__ref__shader", shader );
rb_iv_set( shader, "@__ref__state_owner", aSelf );
rb_obj_freeze( shader );
return aSelf;
}
开发者ID:CaptainJet,项目名称:rbSFML,代码行数:22,代码来源:RenderStates.cpp
示例18: Init_thin_backend
void Init_thin_backend()
{
/* Intern some Ruby strings and symbols */
cStringIO = rb_define_class("StringIO", rb_cData);
sInternedCall = rb_intern("call");
sInternedKeys = rb_intern("keys");
sRackInput = rb_obj_freeze(rb_str_new2("rack.input"));
rb_gc_register_address(&sRackInput);
/* Initialize internal stuff */
backend_define();
parser_callbacks_define();
}
开发者ID:designtestcode,项目名称:thin-turbo,代码行数:13,代码来源:init.c
示例19: Init_pkcs11_protect_server_ext
void
Init_pkcs11_protect_server_ext()
{
VALUE eError;
mPKCS11 = rb_const_get(rb_cObject, rb_intern("PKCS11"));
mProtectServer = rb_define_module_under(mPKCS11, "ProtectServer");
/* Library version */
rb_define_const( mProtectServer, "VERSION", rb_str_new2(VERSION) );
eError = rb_const_get(mPKCS11, rb_intern("Error"));
/* Document-class: PKCS11::ProtectServer::Error
*
* Base class for all ProtectServer specific exceptions (CKR_*) */
eProtectServerError = rb_define_class_under(mProtectServer, "Error", eError);
cPkcs11CStruct = rb_const_get(mPKCS11, rb_intern("CStruct")); \
cProtectServerCStruct = rb_define_class_under(mProtectServer, "CStruct", cPkcs11CStruct);
#include "pk11s_struct_def.inc"
vOBJECT_CLASSES = rb_hash_new();
vATTRIBUTES = rb_hash_new();
vMECHANISMS = rb_hash_new();
vRETURN_VALUES = rb_hash_new();
rb_define_const(mProtectServer, "OBJECT_CLASSES", vOBJECT_CLASSES);
rb_define_const(mProtectServer, "ATTRIBUTES", vATTRIBUTES);
rb_define_const(mProtectServer, "MECHANISMS", vMECHANISMS);
rb_define_const(mProtectServer, "RETURN_VALUES", vRETURN_VALUES);
#include "pk11s_const_def.inc"
rb_obj_freeze(vOBJECT_CLASSES);
rb_obj_freeze(vATTRIBUTES);
rb_obj_freeze(vMECHANISMS);
rb_obj_freeze(vRETURN_VALUES);
}
开发者ID:aalness,项目名称:pkcs11,代码行数:39,代码来源:pk11s.c
示例20: Init_grpc_error_codes
static void Init_grpc_error_codes() {
/* Constants representing the error codes of grpc_call_error in grpc.h */
VALUE grpc_rb_mRpcErrors =
rb_define_module_under(grpc_rb_mGrpcCore, "RpcErrors");
rb_define_const(grpc_rb_mRpcErrors, "OK", UINT2NUM(GRPC_CALL_OK));
rb_define_const(grpc_rb_mRpcErrors, "ERROR", UINT2NUM(GRPC_CALL_ERROR));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_SERVER",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER));
rb_define_const(grpc_rb_mRpcErrors, "NOT_ON_CLIENT",
UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_ACCEPTED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "NOT_INVOKED",
UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED));
rb_define_const(grpc_rb_mRpcErrors, "ALREADY_FINISHED",
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED));
rb_define_const(grpc_rb_mRpcErrors, "TOO_MANY_OPERATIONS",
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS));
rb_define_const(grpc_rb_mRpcErrors, "INVALID_FLAGS",
UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS));
/* Add the detail strings to a Hash */
rb_error_code_details = rb_hash_new();
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_OK),
rb_str_new2("ok"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR),
rb_str_new2("unknown error"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_SERVER),
rb_str_new2("not available on a server"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_ON_CLIENT),
rb_str_new2("not available on a client"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_ACCEPTED),
rb_str_new2("call is already accepted"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_ALREADY_INVOKED),
rb_str_new2("call is already invoked"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_NOT_INVOKED),
rb_str_new2("call is not yet invoked"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_ALREADY_FINISHED),
rb_str_new2("call is already finished"));
rb_hash_aset(rb_error_code_details,
UINT2NUM(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS),
rb_str_new2("outstanding read or write present"));
rb_hash_aset(rb_error_code_details, UINT2NUM(GRPC_CALL_ERROR_INVALID_FLAGS),
rb_str_new2("a bad flag was given"));
rb_define_const(grpc_rb_mRpcErrors, "ErrorMessages", rb_error_code_details);
rb_obj_freeze(rb_error_code_details);
}
开发者ID:rootusr,项目名称:grpc,代码行数:51,代码来源:rb_call.c
注:本文中的rb_obj_freeze函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论