本文整理汇总了C++中rb_ivar_set函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_ivar_set函数的具体用法?C++ rb_ivar_set怎么用?C++ rb_ivar_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_ivar_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: lazy_take_func
static VALUE
lazy_take_func(VALUE val, VALUE args, int argc, VALUE *argv)
{
long remain;
VALUE memo = rb_attr_get(argv[0], id_memo);
if (NIL_P(memo)) {
memo = args;
}
rb_funcall2(argv[0], id_yield, argc - 1, argv + 1);
if ((remain = NUM2LONG(memo)-1) == 0) {
return Qundef;
}
else {
rb_ivar_set(argv[0], id_memo, LONG2NUM(remain));
return Qnil;
}
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:18,代码来源:enumerator.c
示例2: Init_sha1
/*
* A class for calculating message digests using the SHA-1 Secure Hash
* Algorithm by NIST (the US' National Institute of Standards and
* Technology), described in FIPS PUB 180-1.
*/
void
Init_sha1()
{
VALUE mDigest, cDigest_Base, cDigest_SHA1;
rb_require("digest");
#if 0
mDigest = rb_define_module("Digest"); /* let rdoc know */
#endif
mDigest = rb_path2class("Digest");
cDigest_Base = rb_path2class("Digest::Base");
cDigest_SHA1 = rb_define_class_under(mDigest, "SHA1", cDigest_Base);
rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
Data_Wrap_Struct(rb_cObject, 0, 0, (void *)&sha1));
}
开发者ID:brightbox,项目名称:deb-ruby2.1,代码行数:23,代码来源:sha1init.c
示例3: cr_s_wrap
static VALUE
cr_s_wrap (VALUE self, VALUE pointer)
{
VALUE result;
VALUE rb_cr;
cairo_t *cr;
if (NIL_P (rb_cairo__cFFIPointer))
{
rb_raise (rb_eNotImpError,
"%s: FFI::Pointer is required",
rb_id2name (rb_frame_this_func ()));
}
if (!RTEST (rb_obj_is_kind_of (pointer, rb_cairo__cFFIPointer)))
{
rb_raise (rb_eArgError,
"must be FFI::Pointer: %s",
rb_cairo__inspect (pointer));
}
{
VALUE rb_cr_address;
rb_cr_address = rb_funcall (pointer, rb_intern ("address"), 0);
cr = NUM2PTR (rb_cr_address);
cr_check_status (cr);
}
rb_cr = rb_obj_alloc (self);
cairo_reference (cr);
DATA_PTR (rb_cr) = cr;
rb_ivar_set (rb_cr, cr_id_surface, Qnil);
if (rb_block_given_p ())
{
result = rb_ensure (rb_yield, rb_cr, cr_destroy_with_destroy_check, rb_cr);
}
else
{
result = rb_cr;
}
return result;
}
开发者ID:cosmo0920,项目名称:rcairo,代码行数:44,代码来源:rb_cairo_context.c
示例4: rxml_reader_io
/* call-seq:
* XML::Reader.io(io) -> XML::Reader
* XML::Reader.io(io, :encoding => XML::Encoding::UTF_8,
* :options => XML::Parser::Options::NOENT) -> XML::Parser
*
* Creates a new reader by parsing the specified io object.
*
* You may provide an optional hash table to control how the
* parsing is performed. Valid options are:
*
* base_uri - The base url for the parsed document.
* encoding - The document encoding, defaults to nil. Valid values
* are the encoding constants defined on XML::Encoding.
* options - Controls the execution of the parser, defaults to 0.
* Valid values are the constants defined on
* XML::Parser::Options. Mutliple options can be combined
* by using Bitwise OR (|).
*/
static VALUE rxml_reader_io(int argc, VALUE *argv, VALUE klass)
{
xmlTextReaderPtr xreader;
VALUE result;
VALUE io;
VALUE options;
char *xbaseurl = NULL;
const char *xencoding = NULL;
int xoptions = 0;
rb_scan_args(argc, argv, "11", &io, &options);
if (!NIL_P(options))
{
VALUE baseurl = Qnil;
VALUE encoding = Qnil;
VALUE parserOptions = Qnil;
Check_Type(options, T_HASH);
baseurl = rb_hash_aref(options, BASE_URI_SYMBOL);
xbaseurl = NIL_P(baseurl) ? NULL : StringValueCStr(baseurl);
encoding = rb_hash_aref(options, ENCODING_SYMBOL);
xencoding = NIL_P(encoding) ? NULL : xmlGetCharEncodingName(NUM2INT(encoding));
parserOptions = rb_hash_aref(options, OPTIONS_SYMBOL);
xoptions = NIL_P(parserOptions) ? 0 : NUM2INT(parserOptions);
}
xreader = xmlReaderForIO((xmlInputReadCallback) rxml_read_callback, NULL,
(void *) io,
xbaseurl, xencoding, xoptions);
if (xreader == NULL)
rxml_raise(&xmlLastError);
result = rxml_reader_wrap(xreader);
/* Attach io object to parser so it won't get freed.*/
rb_ivar_set(result, IO_ATTR, io);
return result;
}
开发者ID:GREENMASK,项目名称:mgr,代码行数:62,代码来源:ruby_xml_reader.c
示例5: rbosa_element_make
static VALUE
rbosa_element_make (VALUE klass, AEDesc *desc, VALUE app)
{
AEDesc * newDesc;
VALUE new_klass, obj;
newDesc = (AEDesc *)malloc (sizeof (AEDesc));
if (newDesc == NULL)
rb_fatal ("cannot allocate memory");
memcpy (newDesc, desc, sizeof (AEDesc));
new_klass = Qnil;
/* Let's replace the klass here according to the type of the descriptor,
* if the basic class OSA::Element was given.
*/
if (klass == cOSAElement) {
if (newDesc->descriptorType == 'list') {
klass = cOSAElementList;
}
else if (newDesc->descriptorType == 'reco') {
klass = cOSAElementRecord;
}
else if (newDesc->descriptorType == 'type') {
new_klass = __rbosa_class_from_desc_data (app, *newDesc);
}
else if (newDesc->descriptorType == 'obj ' && !NIL_P (app)) {
AEDesc res;
OSErr err;
if ((err = AEGetParamDesc ((AppleEvent *)newDesc, 'want', '****', &res)) == noErr)
new_klass = __rbosa_class_from_desc_data (app, res);
}
}
if (!NIL_P (new_klass))
klass = new_klass;
obj = Data_Wrap_Struct (klass, NULL, rbosa_element_free, newDesc);
rb_ivar_set (obj, sApp, NIL_P (app) ? obj : app);
return obj;
}
开发者ID:bmorton,项目名称:rubyosa,代码行数:43,代码来源:rbosa.c
示例6: rg_initialize
/*
* Create an empty media list.
*
* @param [VLC::Core] core the core instance
* @raise [ArgumentError] Invalid or unsupported arguments
* @todo fixme
*/
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
VALUE core;
libvlc_media_list_t *instance;
rb_scan_args(argc, argv, "01", &core);
if (NIL_P(core))
core = rb_funcall(GTYPE2CLASS(VLC_TYPE_CORE), rb_intern("new"), 0);
instance = libvlc_media_list_new(RVAL2VLCCORE(core));
if (!instance)
rb_raise(rb_eArgError, "Invalid arguments.");
rb_ivar_set(self, id_core, core);
G_INITIALIZE(self, instance);
vlc_media_list_free(instance);
return Qnil;
}
开发者ID:Vasfed,项目名称:ruby-gnome2,代码行数:26,代码来源:rbvlcmedialist.c
示例7: Message_alloc
VALUE Message_alloc(VALUE klass) {
VALUE descriptor = rb_ivar_get(klass, descriptor_instancevar_interned);
Descriptor* desc = ruby_to_Descriptor(descriptor);
MessageHeader* msg = (MessageHeader*)ALLOC_N(
uint8_t, sizeof(MessageHeader) + desc->layout->size);
VALUE ret;
memset(Message_data(msg), 0, desc->layout->size);
// We wrap first so that everything in the message object is GC-rooted in case
// a collection happens during object creation in layout_init().
ret = TypedData_Wrap_Struct(klass, &Message_type, msg);
msg->descriptor = desc;
rb_ivar_set(ret, descriptor_instancevar_interned, descriptor);
layout_init(desc->layout, Message_data(msg));
return ret;
}
开发者ID:1nf1corp,项目名称:protobuf,代码行数:19,代码来源:message.c
示例8: cr_get_target
static VALUE
cr_get_target (VALUE self)
{
cairo_surface_t *surface;
VALUE rb_surface = Qnil;
surface = cairo_get_target (_SELF);
rb_cairo_check_status (cairo_surface_status (surface));
if (RTEST (rb_ivar_defined (self, cr_id_surface)))
rb_surface = rb_ivar_get (self, cr_id_surface);
if (NIL_P (rb_surface) || RVAL2CRSURFACE (rb_surface) != surface)
{
rb_surface = CRSURFACE2RVAL (surface);
rb_ivar_set (self, cr_id_surface, rb_surface);
}
return rb_surface;
}
开发者ID:joshuawatson,项目名称:rcairo,代码行数:19,代码来源:rb_cairo_context.c
示例9: rbgtk_initialize_gtkobject
void
rbgtk_initialize_gtkobject(VALUE obj, GtkObject *gtkobj)
{
gtkobj = g_object_ref(gtkobj);
gtk_object_sink(gtkobj);
G_INITIALIZE(obj, gtkobj);
if (GTK_IS_WINDOW(gtkobj) || GTK_IS_MENU_SHELL(gtkobj)) {
VALUE klass;
klass = rb_obj_class(obj);
if (rb_ivar_defined(klass, id__windows__) == Qfalse) {
rb_ivar_set(klass, id__windows__, rb_hash_new());
}
rb_hash_aset(rb_ivar_get(klass, id__windows__), obj, Qnil);
g_signal_connect_after(gtkobj, "destroy",
G_CALLBACK(remove_from_windows),
(gpointer)obj);
}
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:19,代码来源:rbgtk.c
示例10: NIO_Selector_synchronize
/* Synchronize around a reentrant selector lock */
static VALUE NIO_Selector_synchronize(VALUE self, VALUE (*func)(VALUE *args), VALUE *args)
{
VALUE current_thread, lock_holder, lock;
current_thread = rb_thread_current();
lock_holder = rb_ivar_get(self, rb_intern("lock_holder"));
if(lock_holder != current_thread) {
lock = rb_ivar_get(self, rb_intern("lock"));
rb_funcall(lock, rb_intern("lock"), 0, 0);
rb_ivar_set(self, rb_intern("lock_holder"), current_thread);
/* We've acquired the lock, so ensure we unlock it */
return rb_ensure(func, (VALUE)args, NIO_Selector_unlock, self);
} else {
/* We already hold the selector lock, so no need to unlock it */
return func(args);
}
}
开发者ID:emosei,项目名称:chef,代码行数:20,代码来源:selector.c
示例11: cr_initialize
static VALUE
cr_initialize (VALUE self, VALUE target)
{
cairo_t *cr;
VALUE result = Qnil;
cr = cairo_create (RVAL2CRSURFACE (target));
cr_check_status (cr);
rb_ivar_set (self, cr_id_surface, target);
if (rb_ivar_defined (target, rb_cairo__io_id_output))
cr_set_user_data (cr,
&cr_object_holder_key,
cr_object_holder_new (self),
cr_object_holder_free);
DATA_PTR (self) = cr;
if (rb_block_given_p ())
result = rb_ensure (rb_yield, self, cr_destroy_with_destroy_check, self);
return result;
}
开发者ID:joshuawatson,项目名称:rcairo,代码行数:19,代码来源:rb_cairo_context.c
示例12: lazy_zip_arrays_func
static VALUE
lazy_zip_arrays_func(VALUE val, VALUE arrays, int argc, VALUE *argv)
{
VALUE yielder, ary, memo;
long i, count;
yielder = argv[0];
memo = rb_attr_get(yielder, id_memo);
count = NIL_P(memo) ? 0 : NUM2LONG(memo);
ary = rb_ary_new2(RARRAY_LEN(arrays) + 1);
rb_ary_push(ary, argv[1]);
for (i = 0; i < RARRAY_LEN(arrays); i++) {
rb_ary_push(ary, rb_ary_entry(RARRAY_AREF(arrays, i), count));
}
rb_funcall(yielder, id_yield, 1, ary);
rb_ivar_set(yielder, id_memo, LONG2NUM(++count));
return Qnil;
}
开发者ID:takuto-h,项目名称:ruby,代码行数:19,代码来源:enumerator.c
示例13: cr_text_to_glyphs_data_initialize
static VALUE
cr_text_to_glyphs_data_initialize (VALUE self,
VALUE need_glyphs, VALUE need_clusters,
VALUE need_cluster_flags)
{
rb_ivar_set (self, cr_id_at_glyphs, Qnil);
rb_ivar_set (self, cr_id_at_clusters, Qnil);
rb_ivar_set (self, cr_id_at_cluster_flags, INT2NUM (0));
rb_ivar_set (self, cr_id_at_need_glyphs, need_glyphs);
rb_ivar_set (self, cr_id_at_need_clusters, need_clusters);
rb_ivar_set (self, cr_id_at_need_cluster_flags, need_cluster_flags);
return Qnil;
}
开发者ID:rcairo,项目名称:rcairo,代码行数:14,代码来源:rb_cairo_font_face.c
示例14: rpm_spec_get_packages
/*
* @return [Array<RPM::Package>] Packages defined in the spec file
*/
VALUE
rpm_spec_get_packages(VALUE spec)
{
VALUE pkg = rb_ivar_get(spec, id_pkg);
if (NIL_P(pkg)) {
Package p = RPM_SPEC(spec)->packages;
pkg = rb_ary_new();
while (p != NULL) {
if (p->fileList)
rb_ary_push(pkg, rpm_package_new_from_header(p->header));
p = p->next;
}
rb_ivar_set(spec, id_pkg, pkg);
}
return pkg;
}
开发者ID:daviddavis,项目名称:rpm.rb,代码行数:23,代码来源:spec.c
示例15: rg_initialize
static VALUE
rg_initialize(VALUE self, VALUE type)
{
GType gtype;
if (RVAL2CBOOL(rb_obj_is_kind_of(type, rb_cInteger))) {
gtype = NUM2ULONG(type);
if (!g_type_name(gtype))
gtype = G_TYPE_INVALID;
} else {
gtype = g_type_from_name(StringValuePtr(type));
}
if (G_TYPE_INVALID == gtype)
rb_raise(rb_eArgError, "invalid GType");
rb_ivar_set(self, id_gtype, ULONG2NUM(gtype));
return Qnil;
}
开发者ID:aurelj,项目名称:ruby-gnome2,代码行数:20,代码来源:rbgobj_type.c
示例16: rbffi_Function_ForProc
VALUE
rbffi_Function_ForProc(VALUE rbFunctionInfo, VALUE proc)
{
VALUE callback;
VALUE cbTable = RTEST(rb_ivar_defined(proc, id_cbtable)) ? rb_ivar_get(proc, id_cbtable) : Qnil;
if (cbTable == Qnil) {
cbTable = rb_hash_new();
rb_ivar_set(proc, id_cbtable, cbTable);
}
callback = rb_hash_aref(cbTable, rbFunctionInfo);
if (callback != Qnil) {
return callback;
}
callback = rbffi_Function_NewInstance(rbFunctionInfo, proc);
rb_hash_aset(cbTable, rbFunctionInfo, callback);
return callback;
}
开发者ID:shafferj,项目名称:ffi,代码行数:20,代码来源:Function.c
示例17: rb_rsvg_handle_close
static VALUE
rb_rsvg_handle_close(VALUE self)
{
gboolean result;
GError *error = NULL;
if (RVAL2CBOOL(rb_ivar_get(self, id_closed))) {
return Qnil;
}
result = rsvg_handle_close(_SELF(self), &error);
if (result) {
rb_ivar_set(self, id_closed, Qtrue);
} else {
RAISE_GERROR(error);
}
return CBOOL2RVAL(result);
}
开发者ID:benolee,项目名称:ruby-gnome2,代码行数:20,代码来源:rbrsvg.c
示例18: raise_argument_error
static void
raise_argument_error(rb_thread_t *th, const rb_iseq_t *iseq, const VALUE exc)
{
VALUE at;
if (iseq) {
vm_push_frame(th, iseq, VM_FRAME_MAGIC_DUMMY, Qnil /* self */,
VM_ENVVAL_BLOCK_PTR(0) /* specval*/, Qfalse /* me or cref */,
iseq->body->iseq_encoded, th->cfp->sp, 1 /* local_size (cref/me) */, 0 /* stack_max */);
at = rb_vm_backtrace_object();
vm_pop_frame(th);
}
else {
at = rb_vm_backtrace_object();
}
rb_ivar_set(exc, idBt_locations, at);
rb_exc_set_backtrace(exc, at);
rb_exc_raise(exc);
}
开发者ID:hayaken8112,项目名称:.emacs.d,代码行数:20,代码来源:vm_args.c
示例19: Sprite_initialize
static VALUE Sprite_initialize(int argc, VALUE *argv, VALUE self) {
VALUE sprites = rb_ivar_get(mGraphics, rb_intern("@sprites"));
VALUE src_rect = rb_class_new_instance(0, NULL, cRect);
Sprite *sprite = EXT_SPRITE(self);
rb_ary_push(sprites, self);
old_call(self, rb_intern("initialize"), argc, argv);
src_rect = old_call(self, rb_intern("src_rect"), 0, NULL); /* TODO */
rb_ivar_set(self, rb_intern("@src_rect"), src_rect);
Rect__add_ref(src_rect, self);
sprite->src_rect = src_rect;
sprite->x = sprite->y = 0;
sprite->ox = sprite->oy = 0;
sprite->disposed = 0;
sprite->visible = 1;
return self;
}
开发者ID:wanabe,项目名称:ExtRgss,代码行数:20,代码来源:sprite.c
示例20: rb_eu_escape_html_as_html_safe
static VALUE rb_eu_escape_html_as_html_safe(VALUE self, VALUE str)
{
VALUE result;
int secure = g_html_secure;
gh_buf buf = GH_BUF_INIT;
Check_Type(str, T_STRING);
check_utf8_encoding(str);
if (houdini_escape_html0(&buf, (const uint8_t *)RSTRING_PTR(str), RSTRING_LEN(str), secure)) {
result = new_html_safe_string(buf.ptr, buf.size);
gh_buf_free(&buf);
} else {
result = new_html_safe_string(RSTRING_PTR(str), RSTRING_LEN(str));
}
rb_ivar_set(result, ID_at_html_safe, Qtrue);
return result;
}
开发者ID:gjtorikian,项目名称:escape_utils,代码行数:20,代码来源:escape_utils.c
注:本文中的rb_ivar_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论