本文整理汇总了C++中RDATA函数的典型用法代码示例。如果您正苦于以下问题:C++ RDATA函数的具体用法?C++ RDATA怎么用?C++ RDATA使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RDATA函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dh_equal
static VALUE dh_equal(VALUE self, VALUE other)
{
// TODO: for == and ===, allow 'other' to be a subclass of Usb::Device
// but keep the behavior of eql? the same
return ( CLASS_OF(other) == cDeviceHandle &&
RDATA(self)->data == RDATA(other)->data ) ? Qtrue : Qfalse;
}
示例2: rdata_finalize
static void
rdata_finalize(void *rcv, SEL sel)
{
if (RDATA(rcv)->dfree != NULL && RDATA(rcv)->data != NULL) {
RDATA(rcv)->dfree(RDATA(rcv)->data);
RDATA(rcv)->data = NULL;
}
}
示例3: sws_change_struct
VALUE sws_change_struct(VALUE self, VALUE obj, VALUE new_val) {
struct sample_wrapped_struct *old_struct, *new_struct;
new_struct = (struct sample_wrapped_struct *)malloc(sizeof(struct sample_wrapped_struct));
new_struct->foo = FIX2INT(new_val);
old_struct = RDATA(obj)->data;
free(old_struct);
RDATA(obj)->data = new_struct;
return Qnil;
}
示例4: Init_hijack
void
Init_hijack(void)
{
VALUE proc;
rb_define_global_function("hijack", f_hijack, 0);
proc = rb_eval_string("lambda {}");
blk_mark = (void (*)(struct BLOCK*)) RDATA(proc)->dmark;
blk_free = (void (*)(struct BLOCK*)) RDATA(proc)->dfree;
}
示例5: rb_trie_node_initialize_copy
/* nodoc */
static VALUE rb_trie_node_initialize_copy(VALUE self, VALUE from) {
RDATA(self)->data = trie_state_clone(RDATA(from)->data);
VALUE state = rb_iv_get(from, "@state");
rb_iv_set(self, "@state", state == Qnil ? Qnil : rb_str_dup(state));
VALUE full_state = rb_iv_get(from, "@full_state");
rb_iv_set(self, "@full_state", full_state == Qnil ? Qnil : rb_str_dup(full_state));
return self;
}
示例6: wrap_Node_free
void
wrap_Node_free (struct fs_node* ptr)
{
if(ptr){
VALUE vid = fs_node_get_script_id(ptr);
if (vid != Qnil && RDATA(vid)->data) {
RDATA(vid)->data = NULL;
fs_node_set_script_id(ptr, Qnil);
fs_free(ptr);
}
}
}
示例7: rxml_attr_remove_ex
/*
* call-seq:
* attr.remove! -> nil
*
* Removes this attribute from it's parent. Note
* the attribute and its content is freed and can
* no longer be used. If you try to use it you
* will get a segmentation fault.
*/
static VALUE rxml_attr_remove_ex(VALUE self)
{
xmlAttrPtr xattr;
Data_Get_Struct(self, xmlAttr, xattr);
xmlRemoveProp(xattr);
RDATA(self)->data = NULL;
RDATA(self)->dfree = NULL;
RDATA(self)->dmark = NULL;
return Qnil;
}
示例8: prof_call_info_ruby_gc_free
static void
prof_call_info_ruby_gc_free(prof_call_info_t *call_info)
{
/* Has this thread object been accessed by Ruby? If
yes clean it up so to avoid a segmentation fault. */
if (call_info->object != Qnil)
{
RDATA(call_info->object)->data = NULL;
RDATA(call_info->object)->dfree = NULL;
RDATA(call_info->object)->dmark = NULL;
}
call_info->object = Qnil;
}
示例9: rxml_node_deregisterNode
static void rxml_node_deregisterNode(xmlNodePtr xnode)
{
/* Has the node been wrapped and exposed to Ruby? */
if (xnode->_private)
{
/* Node was wrapped. Set the _private member to free and
then dislabe the dfree function so that Ruby will not
try to free the node a second time. */
VALUE node = (VALUE) xnode->_private;
RDATA(node)->data = NULL;
RDATA(node)->dfree = NULL;
RDATA(node)->dmark = NULL;
}
}
示例10: pcre_regexp_match
static mrb_value
pcre_regexp_match(mrb_state *mrb, mrb_value self) {
const char *str;
char global_match[3];
mrb_value regexp;
struct mrb_pcre_regexp *reg;
int i;
mrb_value mrb_i, mrb_match;
size_t nmatch = 999;
int match[999];
int regno;
int ai;
struct RClass* clazz;
mrb_value c;
mrb_value args[2];
mrb_get_args(mrb, "z", &str);
regexp = mrb_iv_get(mrb, self, mrb_intern_lit(mrb, "@regexp"));
Data_Get_Struct(mrb, regexp, &mrb_pcre_regexp_type, reg);
regno = pcre_exec(reg->re, NULL, str, strlen(str), 0, 0, match, nmatch);
if (regno < 0)
return mrb_nil_value();
mrb_obj_iv_set(mrb, (struct RObject *)mrb_class_real(RDATA(self)->c), mrb_intern_lit(mrb, "@last_match"), mrb_nil_value());
ai = mrb_gc_arena_save(mrb);
clazz = mrb_class_get(mrb, "PcreMatchData");
c = mrb_obj_new(mrb, clazz, 0, NULL);
mrb_iv_set(mrb, c,mrb_intern_lit(mrb, "@string"), mrb_str_new_cstr(mrb, str));
for (i = 0; i < regno; i++) {
args[0] = mrb_fixnum_value(match[i * 2]);
args[1] = mrb_fixnum_value(match[i * 2 + 1] - match[i * 2]);
mrb_funcall_argv(mrb, c, mrb_intern_lit(mrb, "push"), sizeof(args)/sizeof(args[0]), &args[0]);
if (i > 0 && i < 10) {
sprintf(global_match, "$%i", i);
mrb_i = mrb_fixnum_value(i);
mrb_match = mrb_funcall_argv(mrb, c, mrb_intern_lit(mrb, "[]"), 1, &mrb_i);
mrb_gv_set(mrb, mrb_intern_cstr(mrb, global_match), mrb_match);
}
mrb_gc_arena_restore(mrb, ai);
}
mrb_obj_iv_set(mrb, (struct RObject *)mrb_class_real(RDATA(self)->c), mrb_intern_lit(mrb, "@last_match"), c);
return c;
}
示例11: rxml_xpath_object_wrap
VALUE rxml_xpath_object_wrap(xmlDocPtr xdoc, xmlXPathObjectPtr xpop)
{
int i;
rxml_xpath_object *rxpop = ALLOC(rxml_xpath_object);
rxpop->xdoc =xdoc;
rxpop->xpop = xpop;
rxpop->nsnodes = rb_ary_new();
/* Find all the extra namespace nodes and wrap them. */
if (xpop->nodesetval && xpop->nodesetval->nodeNr)
{
for (i = 0;i < xpop->nodesetval->nodeNr; i++)
{
xmlNodePtr xnode = xpop->nodesetval->nodeTab[i];
if (xnode != NULL && xnode->type == XML_NAMESPACE_DECL)
{
VALUE ns = Qnil;
xmlNsPtr xns = (xmlNsPtr)xnode;
/* Get rid of libxml's -> next hack. The issue here is
the rxml_namespace code assumes that ns->next refers
to another namespace. */
xns->next = NULL;
/* Specify a custom free function here since by default
namespace nodes will not be freed */
ns = rxml_namespace_wrap((xmlNsPtr)xnode);
RDATA(ns)->dfree = (RUBY_DATA_FUNC)rxml_xpath_namespace_free;
rb_ary_push(rxpop->nsnodes, ns);
}
}
}
return Data_Wrap_Struct(cXMLXPathObject, rxml_xpath_object_mark, rxml_xpath_object_free, rxpop);
}
示例12: transactionInitialize
/**
* This function provides the initialize method for the Transaction class.
*
* @param self A reference to the new Transaction class instance.
* @param connections Either a reference to a single Connection object or to
* an array of Connection objects that the transaction
* will apply to.
*
*/
static VALUE transactionInitialize(VALUE self, VALUE connections) {
TransactionHandle *transaction = NULL;
VALUE array = Qnil;
/* Determine if an array has been passed as a parameter. */
if(TYPE(connections) == T_ARRAY) {
array = connections;
} else if(TYPE(connections) == T_DATA &&
RDATA(connections)->dfree == (RUBY_DATA_FUNC)connectionFree) {
array = rb_ary_new();
rb_ary_push(array, connections);
} else {
rb_fireruby_raise(NULL,
"Invalid connection parameter(s) for transaction.");
}
/* Store the database details. */
rb_iv_set(self, "@connections", array);
/* Fetch the data structure and start the transaction. */
Data_Get_Struct(self, TransactionHandle, transaction);
startTransaction(transaction, array, 0, NULL);
rb_tx_started(self, array);
return(self);
}
示例13: grpc_rb_call_credentials_init_copy
/* Clones CallCredentials instances.
Gives CallCredentials a consistent implementation of Ruby's object copy/dup
protocol. */
static VALUE grpc_rb_call_credentials_init_copy(VALUE copy, VALUE orig) {
grpc_rb_call_credentials *orig_cred = NULL;
grpc_rb_call_credentials *copy_cred = NULL;
if (copy == orig) {
return copy;
}
/* Raise an error if orig is not a credentials object or a subclass. */
if (TYPE(orig) != T_DATA ||
RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_call_credentials_free) {
rb_raise(rb_eTypeError, "not a %s",
rb_obj_classname(grpc_rb_cCallCredentials));
}
TypedData_Get_Struct(orig, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, orig_cred);
TypedData_Get_Struct(copy, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, copy_cred);
/* use ruby's MEMCPY to make a byte-for-byte copy of the credentials
* wrapper object. */
MEMCPY(copy_cred, orig_cred, grpc_rb_call_credentials, 1);
return copy;
}
示例14: executeOnConnectionImmediate
/**
* This function provides the execute_immediate method for the Connection class.
*
* @param self A reference to the connection object to perform the execution
* through.
* @param sql A reference to the SQL statement to be executed.
*
* @return Always returns nil.
*
*/
static VALUE executeOnConnectionImmediate(VALUE self, VALUE sql) {
VALUE transaction = rb_transaction_new(self),
set = Qnil,
results = Qnil,
array = rb_ary_new(),
dialect = INT2FIX(3),
statement = rb_statement_new(self, transaction, sql, dialect);
rb_ary_push(array, self);
rb_ary_push(array, transaction);
rb_ary_push(array, sql);
rb_ary_push(array, statement);
set = rb_rescue(executeBlock, array, executeRescue, array);
if(set != Qnil) {
if(TYPE(set) == T_DATA &&
RDATA(set)->dfree == (RUBY_DATA_FUNC)resultSetFree) {
rb_assign_transaction(set, transaction);
if(rb_block_given_p()) {
results = rb_rescue(executeImmediateBlock, set,
executeImmediateRescue, set);
} else {
results = set;
}
} else {
rb_funcall(transaction, rb_intern("commit"), 0);
results = set;
}
} else {
rb_funcall(transaction, rb_intern("commit"), 0);
}
return(results);
}
示例15: dnssd_service_stop
static VALUE
dnssd_service_stop(VALUE self) {
VALUE thread;
DNSServiceRef *client;
get(cDNSSDService, self, DNSServiceRef, client);
RDATA(self)->data = NULL;
if (client == NULL)
rb_raise(eDNSSDError, "service is already stopped");
thread = rb_ivar_get(self, dnssd_iv_thread);
rb_ivar_set(self, dnssd_iv_continue, Qfalse);
if (!NIL_P(thread) && thread != rb_thread_current()) {
rb_thread_run(thread);
rb_funcall(thread, dnssd_id_join, 0);
}
dnssd_service_free_client(client);
rb_ivar_set(self, dnssd_iv_type, Qnil);
return self;
}