本文整理汇总了C++中rb_iv_set函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_iv_set函数的具体用法?C++ rb_iv_set怎么用?C++ rb_iv_set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_iv_set函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RDATA
VALUE Field::init_copy(VALUE copy, VALUE orig) {
//Copy this object to a new one. Open the cap file again
Field* FieldCopy = NULL;
Field* FieldOrig = NULL;
if (copy == orig) {
return copy;
}
if(TYPE(orig)!=T_DATA ||
RDATA(orig)->dfree!=(RUBY_DATA_FUNC)Field::free) {
rb_raise(rb_eTypeError, "Wrong argument type");
}
Data_Get_Struct(copy, Field, FieldCopy);
Data_Get_Struct(orig, Field, FieldOrig);
//Copy the Ruby property @packet, then copy the native Field objects too
rb_iv_set(copy, "@packet", rb_iv_get(orig, "@packet"));
*FieldCopy = *FieldOrig;
return copy;
}
开发者ID:anelson,项目名称:rcapdissector,代码行数:24,代码来源:Field.cpp
示例2: cSedna_initialize
/* :nodoc:
*
* Initialize a new instance of Sedna. Undocumented, because Sedna.connect should
* be used instead.
*/
static VALUE cSedna_initialize(VALUE self, VALUE options)
{
VALUE host_k, db_k, user_k, pw_k,
host_v, db_v, user_v, pw_v;
char *host, *db, *user, *pw;
// Ensure the argument is a Hash.
Check_Type(options, T_HASH);
// Store the symbols of the valid hash keys.
host_k = ID2SYM(rb_intern("host"));
db_k = ID2SYM(rb_intern("database"));
user_k = ID2SYM(rb_intern("username"));
pw_k = ID2SYM(rb_intern("password"));
// Get the connection details or set them to the default values if not given.
if(NIL_P(host_v = rb_hash_aref(options, host_k))) host = strdup(DEFAULT_HOST); else host = StringValuePtr(host_v);
if(NIL_P(db_v = rb_hash_aref(options, db_k ))) db = strdup(DEFAULT_DB); else db = StringValuePtr(db_v);
if(NIL_P(user_v = rb_hash_aref(options, user_k))) user = strdup(DEFAULT_USER); else user = StringValuePtr(user_v);
if(NIL_P(pw_v = rb_hash_aref(options, pw_k ))) pw = strdup(DEFAULT_PW); else pw = StringValuePtr(pw_v);
// Save all connection details to instance variables.
rb_iv_set(self, IV_HOST, rb_str_new2(host));
rb_iv_set(self, IV_DB, rb_str_new2(db));
rb_iv_set(self, IV_USER, rb_str_new2(user));
rb_iv_set(self, IV_PW, rb_str_new2(pw));
#ifdef NON_BLOCKING
// Create a mutex if this build supports non-blocking queries.
rb_iv_set(self, IV_MUTEX, rb_mutex_new());
#endif
// Connect to the database.
SCA c = { sedna_struct(self), host, db, user, pw };
sedna_connect(self, &c);
// Initialize @autocommit to true.
rb_iv_set(self, IV_AUTOCOMMIT, Qtrue);
return self;
}
开发者ID:rolftimmermans,项目名称:sedna-ruby,代码行数:46,代码来源:sedna.c
示例3: ossl_x509store_initialize
/*
* call-seq:
* X509::Store.new => store
*
*/
static VALUE
ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
{
X509_STORE *store;
/* BUG: This method takes any number of arguments but appears to ignore them. */
GetX509Store(self, store);
X509_STORE_set_verify_cb_func(store, ossl_verify_cb);
ossl_x509store_set_vfy_cb(self, Qnil);
#if (OPENSSL_VERSION_NUMBER < 0x00907000L)
rb_iv_set(self, "@flags", INT2NUM(0));
rb_iv_set(self, "@purpose", INT2NUM(0));
rb_iv_set(self, "@trust", INT2NUM(0));
#endif
/* last verification status */
rb_iv_set(self, "@error", Qnil);
rb_iv_set(self, "@error_string", Qnil);
rb_iv_set(self, "@chain", Qnil);
rb_iv_set(self, "@time", Qnil);
return self;
}
开发者ID:DCarper,项目名称:rubinius,代码行数:29,代码来源:ossl_x509store.c
示例4: birch_initialize
/*
* Initialize the node with its value and id.
* Setup containers for the children, features
* and dependencies of this node.
*/
static VALUE birch_initialize(VALUE self, VALUE value, VALUE id)
{
VALUE parent;
VALUE children;
VALUE children_hash;
VALUE features;
VALUE edges;
parent = Qnil;
children = rb_ary_new();
children_hash = rb_hash_new();
features = rb_hash_new();
edges = rb_ary_new();
rb_iv_set(self, "@value", value);
rb_iv_set(self, "@id", id);
rb_iv_set(self, "@parent", parent);
rb_iv_set(self, "@children", children);
rb_iv_set(self, "@children_hash", children_hash);
rb_iv_set(self, "@features", features);
rb_iv_set(self, "@edges", edges);
return self;
}
开发者ID:louismullie,项目名称:birch,代码行数:29,代码来源:native.c
示例5: 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
示例6: nstruct_add_type
static VALUE
nstruct_add_type(VALUE type, int argc, VALUE *argv, VALUE nst)
{
VALUE ofs, size;
ID id;
int i;
VALUE name=Qnil;
size_t *shape=NULL;
int ndim=0;
ssize_t stride;
narray_view_t *nt;
int j;
for (i=0; i<argc; i++) {
switch(TYPE(argv[i])) {
case T_STRING:
case T_SYMBOL:
if (NIL_P(name)) {
name = argv[i];
break;
}
rb_raise(rb_eArgError,"multiple name in struct definition");
case T_ARRAY:
if (shape) {
rb_raise(rb_eArgError,"multiple shape in struct definition");
}
ndim = RARRAY_LEN(argv[i]);
if (ndim > NA_MAX_DIMENSION) {
rb_raise(rb_eArgError,"too large number of dimensions");
}
if (ndim == 0) {
rb_raise(rb_eArgError,"array is empty");
}
shape = ALLOCA_N(size_t, ndim);
na_array_to_internal_shape(Qnil, argv[i], shape);
break;
}
}
id = rb_to_id(name);
name = ID2SYM(id);
if (rb_obj_is_kind_of(type,cNArray)) {
narray_t *na;
GetNArray(type,na);
type = CLASS_OF(type);
ndim = na->ndim;
shape = na->shape;
}
type = rb_narray_view_new(type,ndim,shape);
GetNArrayView(type,nt);
nt->stridx = ALLOC_N(stridx_t,ndim);
stride = na_dtype_elmsz(CLASS_OF(type));
for (j=ndim; j--; ) {
SDX_SET_STRIDE(nt->stridx[j], stride);
stride *= shape[j];
}
ofs = rb_iv_get(nst, "__offset__");
nt->offset = NUM2SIZET(ofs);
size = rb_funcall(type, rb_intern("byte_size"), 0);
rb_iv_set(nst, "__offset__", rb_funcall(ofs,'+',1,size));
rb_ary_push(rb_iv_get(nst,"__members__"),
rb_ary_new3(4,name,type,ofs,size)); // <- field definition
return Qnil;
}
开发者ID:metanest,项目名称:narray-devel,代码行数:67,代码来源:struct.c
示例7: ossl_asn1_decode0
static VALUE
ossl_asn1_decode0(unsigned char **pp, long length, long *offset, long depth,
int once, int yield)
{
unsigned char *start, *p;
const unsigned char *p0;
long len, off = *offset;
int hlen, tag, tc, j;
VALUE ary, asn1data, value, tag_class;
ary = rb_ary_new();
p = *pp;
while(length > 0){
start = p;
p0 = p;
j = ASN1_get_object(&p0, &len, &tag, &tc, length);
p = (unsigned char *)p0;
if(j & 0x80) ossl_raise(eASN1Error, NULL);
hlen = p - start;
if(yield){
VALUE arg = rb_ary_new();
rb_ary_push(arg, LONG2NUM(depth));
rb_ary_push(arg, LONG2NUM(off));
rb_ary_push(arg, LONG2NUM(hlen));
rb_ary_push(arg, LONG2NUM(len));
rb_ary_push(arg, (j & V_ASN1_CONSTRUCTED) ? Qtrue : Qfalse);
rb_ary_push(arg, ossl_asn1_class2sym(tc));
rb_ary_push(arg, INT2NUM(tag));
rb_yield(arg);
}
length -= hlen;
off += hlen;
if(len > length) ossl_raise(eASN1Error, "value is too short");
if((tc & V_ASN1_PRIVATE) == V_ASN1_PRIVATE)
tag_class = sPRIVATE;
else if((tc & V_ASN1_CONTEXT_SPECIFIC) == V_ASN1_CONTEXT_SPECIFIC)
tag_class = sCONTEXT_SPECIFIC;
else if((tc & V_ASN1_APPLICATION) == V_ASN1_APPLICATION)
tag_class = sAPPLICATION;
else
tag_class = sUNIVERSAL;
if(j & V_ASN1_CONSTRUCTED){
/* TODO: if j == 0x21 it is indefinite length object. */
if((j == 0x21) && (len == 0)){
long lastoff = off;
value = ossl_asn1_decode0(&p, length, &off, depth+1, 0, yield);
len = off - lastoff;
}
else value = ossl_asn1_decode0(&p, len, &off, depth+1, 0, yield);
}
else{
value = rb_str_new((const char *)p, len);
p += len;
off += len;
}
if(tag_class == sUNIVERSAL &&
tag < ossl_asn1_info_size && ossl_asn1_info[tag].klass){
VALUE klass = *ossl_asn1_info[tag].klass;
long flag = 0;
if(!rb_obj_is_kind_of(value, rb_cArray)){
switch(tag){
case V_ASN1_BOOLEAN:
value = decode_bool(start, hlen+len);
break;
case V_ASN1_INTEGER:
value = decode_int(start, hlen+len);
break;
case V_ASN1_BIT_STRING:
value = decode_bstr(start, hlen+len, &flag);
break;
case V_ASN1_NULL:
value = decode_null(start, hlen+len);
break;
case V_ASN1_ENUMERATED:
value = decode_enum(start, hlen+len);
break;
case V_ASN1_OBJECT:
value = decode_obj(start, hlen+len);
break;
case V_ASN1_UTCTIME: /* FALLTHROUGH */
case V_ASN1_GENERALIZEDTIME:
value = decode_time(start, hlen+len);
break;
default:
/* use original value */
break;
}
}
asn1data = rb_funcall(klass, rb_intern("new"), 1, value);
if(tag == V_ASN1_BIT_STRING){
rb_iv_set(asn1data, "@unused_bits", LONG2NUM(flag));
}
}
else{
asn1data = rb_funcall(cASN1Data, rb_intern("new"), 3,
value, INT2NUM(tag), ID2SYM(tag_class));
}
rb_ary_push(ary, asn1data);
length -= len;
if(once) break;
//.........这里部分代码省略.........
开发者ID:DocPsy,项目名称:MacRuby,代码行数:101,代码来源:ossl_asn1.c
示例8: query_initialize
//
// def initialize(query_id, query, client)
//
static VALUE query_initialize(VALUE self, VALUE query_id, VALUE query, VALUE client) {
rb_iv_set(self, "@query_id", query_id);
rb_iv_set(self, "@query", query);
rb_iv_set(self, "@client", client);
rb_iv_set(self, "@done", Qfalse);
}
开发者ID:itelab,项目名称:AerospikeCRuby,代码行数:9,代码来源:query_task.c
示例9: display_initialize
static VALUE display_initialize(int argc, VALUE* argv, VALUE self)
{
caca_display_t *display;
caca_canvas_t *canvas = NULL;
const char *driver = NULL;
VALUE cv = Qnil;
VALUE arg1, arg2;
rb_scan_args(argc, argv, "02", &arg1, &arg2);
if(CLASS_OF(arg1) == cCanvas)
{
cv = arg1;
if(CLASS_OF(arg2) == cCanvas)
{
rb_raise(rb_eArgError, "Only one argument can be a Caca::Canvas");
}
}
else if(CLASS_OF(arg2) == cCanvas)
{
cv = arg2;
}
if(TYPE(arg1) == T_STRING)
{
driver = StringValuePtr(arg1);
if(TYPE(arg2) == T_STRING)
{
rb_raise(rb_eArgError, "Only one argument can be a string");
}
}
else if(TYPE(arg2) == T_STRING)
{
driver = StringValuePtr(arg2);
}
if(cv != Qnil)
canvas = DATA_PTR(cv);
if(driver == NULL)
{
display = caca_create_display(canvas);
if(display && NIL_P(cv))
{
cv = canvas_create(caca_get_canvas(display));
}
}
else
{
display = caca_create_display_with_driver(canvas, driver);
}
if(display == NULL)
{
rb_raise(rb_eRuntimeError, "%s", strerror(errno));
}
_SELF = display;
rb_iv_set(self, "@canvas", cv);
return self;
}
开发者ID:Kirkman,项目名称:libcaca,代码行数:63,代码来源:caca-display.c
示例10: rb_grn_column_select
//.........这里部分代码省略.........
* [+:allow_pragma+]
* query構文時にプラグマを利用するかどうか。省略した場合は
* 利用する。
*
* 参考: Groonga::Expression#parse.
*
* [+:allow_column+]
* query構文時にカラム指定を利用するかどうか。省略した場合
* は利用する。
*
* 参考: Groonga::Expression#parse.
*
* [+:allow_update+]
* script構文時に更新操作を利用するかどうか。省略した場合
* は利用する。
*
* 参考: Groonga::Expression#parse.
*/
static VALUE
rb_grn_column_select (int argc, VALUE *argv, VALUE self)
{
grn_ctx *context;
grn_obj *table, *column, *result, *expression;
grn_operator operator = GRN_OP_OR;
VALUE options;
VALUE rb_query, condition_or_options;
VALUE rb_name, rb_operator, rb_result, rb_syntax;
VALUE rb_allow_pragma, rb_allow_column, rb_allow_update;
VALUE builder;
VALUE rb_expression = Qnil;
rb_query = Qnil;
rb_scan_args(argc, argv, "02", &condition_or_options, &options);
rb_grn_column_deconstruct(SELF(self), &column, &context,
NULL, NULL,
NULL, NULL, NULL);
table = grn_column_table(context, column);
if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options, rb_cString))) {
rb_query = condition_or_options;
} else if (RVAL2CBOOL(rb_obj_is_kind_of(condition_or_options,
rb_cGrnExpression))) {
rb_expression = condition_or_options;
} else {
if (!NIL_P(options))
rb_raise(rb_eArgError,
"should be [query_string, option_hash], "
"[expression, option_hash] "
"or [option_hash]: %s",
rb_grn_inspect(rb_ary_new4(argc, argv)));
options = condition_or_options;
}
rb_grn_scan_options(options,
"operator", &rb_operator,
"result", &rb_result,
"name", &rb_name,
"syntax", &rb_syntax,
"allow_pragma", &rb_allow_pragma,
"allow_column", &rb_allow_column,
"allow_update", &rb_allow_update,
NULL);
if (!NIL_P(rb_operator))
operator = NUM2INT(rb_operator);
if (NIL_P(rb_result)) {
result = grn_table_create(context, NULL, 0, NULL,
GRN_TABLE_HASH_KEY | GRN_OBJ_WITH_SUBREC,
table,
0);
rb_result = GRNTABLE2RVAL(context, result, RB_GRN_TRUE);
} else {
result = RVAL2GRNTABLE(rb_result, &context);
}
if (NIL_P(rb_expression)) {
builder = rb_grn_column_expression_builder_new(self, rb_name, rb_query);
rb_funcall(builder, rb_intern("syntax="), 1, rb_syntax);
rb_funcall(builder, rb_intern("allow_pragma="), 1, rb_allow_pragma);
rb_funcall(builder, rb_intern("allow_column="), 1, rb_allow_column);
rb_funcall(builder, rb_intern("allow_update="), 1, rb_allow_update);
rb_expression = rb_grn_column_expression_builder_build(builder);
}
rb_grn_object_deconstruct(RB_GRN_OBJECT(DATA_PTR(rb_expression)),
&expression, NULL,
NULL, NULL, NULL, NULL);
grn_table_select(context, table, expression, result, operator);
rb_grn_context_check(context, self);
rb_attr(rb_singleton_class(rb_result),
rb_intern("expression"),
RB_GRN_TRUE, RB_GRN_FALSE, RB_GRN_FALSE);
rb_iv_set(rb_result, "@expression", rb_expression);
return rb_result;
}
开发者ID:nobu,项目名称:rroonga,代码行数:101,代码来源:rb-grn-column.c
示例11: rbhtp_file_initialize
// ---- File ----
VALUE rbhtp_file_initialize( VALUE self, VALUE raw_file )
{
rb_iv_set( self, "@file", raw_file );
return Qnil;
}
开发者ID:aburan28,项目名称:ironbee,代码行数:6,代码来源:HTP.c
示例12: counter_start
/*
:nodoc:
*/
static VALUE counter_start(VALUE self)
{
rb_iv_set(self, "@st", rb_funcall(mSDL, rb_intern("getTicks"), 0));
rb_iv_set(self, "@counting", Qtrue);
return self;
}
开发者ID:cyross,项目名称:miyako2_with_ruby_sdl_win32_binary,代码行数:9,代码来源:miyako_basicdata.c
示例13: statement_Execute
static VALUE statement_Execute(VALUE self) {
int i;
CS_DATAFMT col;
CS_DATAFMT *cols;
EX_COLUMN_DATA *col_data;
CS_INT rc;
CS_INT resulttype;
CS_INT num_cols;
CS_INT col_len;
CS_INT row_count = 0;
CS_INT rows_read;
CS_INT num_errors = 0;
CS_SERVERMSG servermsg;
VALUE err;
char *error_msg;
struct timeval start, stop;
int print_rows = 1;
char message[128];
char* buf;
CS_DATEREC date_rec;
char output[200];
CS_INT output_len;
int tempInt;
CS_BIGINT tempBigInt;
double tempDouble;
CS_NUMERIC tempNumeric;
char* tempText;
char* newTempText;
int tempTextLen;
CS_INT data_rc;
int isNull = 0;
CS_DATE tempDate;
CS_DATETIME tempDateTime;
TDS_Connection* conn;
CS_COMMAND * cmd;
VALUE connection;
VALUE query;
VALUE columns;
VALUE rows;
VALUE status;
VALUE errors;
VALUE date_parts[8];
VALUE column;
VALUE row;
VALUE column_name = rb_str_new2("name");
VALUE column_type = rb_str_new2("type");
VALUE column_size = rb_str_new2("size");
VALUE column_scale = rb_str_new2("scale");
VALUE column_precision = rb_str_new2("precision");
VALUE column_value;
connection = rb_iv_get(self, "@connection");
query = rb_iv_get(self, "@query");
columns = rb_ary_new();
rb_iv_set(self, "@columns", columns);
rows = rb_ary_new();
rb_iv_set(self, "@rows", rows);
Data_Get_Struct(connection, TDS_Connection, conn);
buf = value_to_cstr(query);
rb_iv_set(self, "@status", Qnil);
rb_iv_set(self, "@messages", rb_ary_new());
errors = rb_ary_new();
rb_iv_set(self, "@errors", errors);
ct_diag(conn->connection, CS_INIT, CS_UNUSED, CS_UNUSED, NULL);
// if ( ct_callback(conn->context, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *)clientmsg_cb) != CS_SUCCEED ) {
// error_message("ct_callback CS_CLIENTMSG_CB failed\n");
// }
// if ( ct_callback(conn->context, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *)servermsg_cb) != CS_SUCCEED ) {
// error_message("ct_callback CS_SERVERMSG_CB failed\n");
// }
ct_cmd_alloc(conn->connection, &cmd);
ct_command(cmd, CS_LANG_CMD, buf, CS_NULLTERM, CS_UNUSED);
ct_send(cmd);
if ( ct_diag(conn->connection, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_errors) != CS_SUCCEED ) {
error_message("ct_diag CS_STATUS CS_SERVERMSG_TYPE failed");
}
if (num_errors > 0) {
// fprintf(stderr, "%d errors found\n", num_errors);
for (i = 0; i < num_errors; i++) {
if ( ct_diag(conn->connection, CS_GET, CS_SERVERMSG_TYPE, i+1, &servermsg) != CS_SUCCEED ) {
error_message("ct_diag CS_GET CS_SERVERMSG_TYPE failed");
}
if (servermsg.severity > 0) {
// error_message(servermsg.text);
rb_ary_push(errors, rb_str_new2(servermsg.text));
//.........这里部分代码省略.........
开发者ID:ebryn,项目名称:freetds4ruby,代码行数:101,代码来源:freetds.c
示例14: connection_Initialize
static VALUE connection_Initialize(VALUE self, VALUE connection_hash) {
TDS_Connection* conn;
char *servername = NULL;
char *username = NULL;
char *password = NULL;
char *confile = NULL;
char *charset = NULL;
VALUE temp;
VALUE errors;
CS_RETCODE ret;
Data_Get_Struct(self, TDS_Connection, conn);
cs_ctx_alloc(CS_VERSION_100, &conn->context);
ct_init(conn->context, CS_VERSION_100);
ct_con_alloc(conn->context, &conn->connection);
// conn->context->msg_handler = connection_handle_message;
// conn->context->err_handler = connection_handle_message;
/* now let's get the connection parameters */
temp = rb_hash_aref(connection_hash, ID2SYM(rb_intern("username")));
username = value_to_cstr(temp);
temp = rb_hash_aref(connection_hash, ID2SYM(rb_intern("password")));
password = value_to_cstr(temp);
temp = rb_hash_aref(connection_hash, ID2SYM(rb_intern("servername")));
servername = value_to_cstr(temp);
temp = rb_hash_aref(connection_hash, ID2SYM(rb_intern("charset")));
charset = value_to_cstr(temp);
if(charset==NULL) {
charset = strdup("ISO-8859-1");
}
/* validate parameters */
if (!servername) {
rb_raise(rb_eArgError, "You must specify a servername");
return Qnil;
}
if (!username) {
rb_raise(rb_eArgError, "No username specified");
return Qnil;
}
if (!password) {
password = strdup("");
}
// printf("*** servername='%s', username='%s' password='%s'\n", servername, username, password);
ct_con_props(conn->connection, CS_SET, CS_USERNAME, username, CS_NULLTERM, NULL);
ct_con_props(conn->connection, CS_SET, CS_PASSWORD, password, CS_NULLTERM, NULL);
/* Try to open a connection */
ret = ct_connect(conn->connection, servername, CS_NULLTERM);
/* free up all the memory */
if (username) {
free(username);
username = NULL;
}
if (password) {
free(password);
password = NULL;
}
if (servername) {
free(servername);
}
if(ret!=CS_SUCCEED) {
rb_raise(rb_eIOError, "Connection failed");
return Qnil;
}
rb_iv_set(self, "@messages", rb_ary_new());
errors = rb_ary_new();
rb_iv_set(self, "@errors", errors);
return Qnil;
}
开发者ID:ebryn,项目名称:freetds4ruby,代码行数:83,代码来源:freetds.c
示例15: Extension1_initialize
VALUE Extension1_initialize(VALUE self)
{
rb_iv_set(self,"@test",1);
rb_iv_set(self,"@test2",2);
return self;
}
开发者ID:NuriYuri,项目名称:RubyInterface,代码行数:6,代码来源:RubyExtension+1.cpp
示例16: ImageList_quantize
/**
* Call QuantizeImages.
*
* Ruby usage:
* - @verbatim ImageList#quantize @endverbatim
* - @verbatim ImageList#quantize(number_colors) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither, tree_depth) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither, tree_depth, measure_error) @endverbatim
*
* Notes:
* - Default number_colors is 256
* - Default coorspace is Magick::RGBColorsapce
* - Default dither is true
* - Default tree_depth is 0
* - Default measure_error is false
* - Sets \@scene to the same value as self.scene
*
* @param argc number of input arguments
* @param argv array of input arguments
* @param self this object
* @return a new ImageList with quantized images
*/
VALUE
ImageList_quantize(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_images;
Image *new_image;
QuantizeInfo quantize_info;
ExceptionInfo *exception;
VALUE new_imagelist, scene;
GetQuantizeInfo(&quantize_info);
switch (argc)
{
case 5:
quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
case 4:
quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]);
case 3:
#if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
{
VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
}
#else
quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
#endif
case 2:
VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
case 1:
quantize_info.number_colors = NUM2ULONG(argv[0]);
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc);
break;
}
// Convert image array to image sequence, clone image sequence.
exception = AcquireExceptionInfo();
images = images_from_imagelist(self);
new_images = CloneImageList(images, exception);
rm_split(images);
rm_check_exception(exception, new_images, DestroyOnError);
rm_ensure_result(new_images);
(void) QuantizeImages(&quantize_info, new_images);
rm_check_exception(exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(exception);
// Create new ImageList object, convert mapped image sequence to images,
// append to images array.
new_imagelist = ImageList_new();
while ((new_image = RemoveFirstImageFromList(&new_images)))
{
imagelist_push(new_imagelist, rm_image_new(new_image));
}
// Set @scene in new ImageList object to same value as in self.
scene = rb_iv_get(self, "@scene");
(void) rb_iv_set(new_imagelist, "@scene", scene);
RB_GC_GUARD(new_imagelist);
RB_GC_GUARD(scene);
return new_imagelist;
}
开发者ID:ABaumgaertner,项目名称:rmagick,代码行数:94,代码来源:rmilist.c
示例17: ruv_buffer_write
VALUE ruv_buffer_write(int argc, VALUE* argv, VALUE rb_buffer) {
VALUE rb_str, rb_offset, rb_length, rb_extern_enc, rb_cBuffer;
size_t offset, length, max_length, char_count;
ruv_buffer_t *buffer;
rb_encoding *rb_extern_encoding;
Data_Get_Struct(rb_buffer, ruv_buffer_t, buffer);
rb_scan_args(argc, argv, "13", &rb_str, &rb_offset, &rb_length, &rb_extern_enc);
StringValue(rb_str);
// encoding: use specified external encoding if provided
// otherwise use Encoding.default_external as default
if(!NIL_P(rb_extern_enc)) {
rb_extern_encoding = rb_enc_get(rb_extern_enc);
} else {
rb_extern_encoding = rb_default_external_encoding();
}
// convert to external encoding
rb_str = rb_str_export_to_enc(rb_str, rb_extern_encoding);
// offset: either specified in params or 0
if(!NIL_P(rb_offset)) {
Check_Type(rb_offset, T_FIXNUM);
offset = NUM2SIZET(rb_offset);
if(offset >= buffer->length) {
rb_raise(rb_eArgError, "Overflow! offset is larger than buffer size.");
}
} else {
offset = 0;
}
// max length: the smaller of the max available space or the whole ruby string
max_length = MIN(buffer->length - offset, (size_t)RSTRING_LEN(rb_str));
// length: number of bytes to write. (include half chars)
if(!NIL_P(rb_length)) {
Check_Type(rb_length, T_FIXNUM);
length = NUM2SIZET(rb_length);
} else {
length = max_length;
}
// If we are not writing the whole string into the buffer,
// re-adjust length so we don't write half a character (uft8, etc)
// 1). get char count from calculated byte length
// 2). get byte length back from char count
// This way only whole char is written to buffer
if(length != (size_t)RSTRING_LEN(rb_str)) {
char_count = rb_str_sublen(rb_str, length);
length = rb_str_offset(rb_str, char_count);
}
memcpy(buffer->data + offset, RSTRING_PTR(rb_str), length);
// set instance variable so we know how much characters are written
rb_cBuffer = rb_obj_class(rb_buffer);
rb_iv_set(rb_cBuffer, RUV_BUFFER_CHAR_WRITTEN_SYM, SIZET2NUM(char_count));
return SIZET2NUM(length);
}
开发者ID:aq1018,项目名称:ruv,代码行数:62,代码来源:ruv_buffer.c
示例18: rbhtp_header_line_initialize
// ---- Header Line ----
VALUE rbhtp_header_line_initialize( VALUE self, VALUE raw_header_line )
{
rb_iv_set( self, "@header_line", raw_header_line );
return Qnil;
}
开发者ID:aburan28,项目名称:ironbee,代码行数:6,代码来源:HTP.c
示例19: rbhtp_uri_initialize
// ---- URI ----
VALUE rbhtp_uri_initialize( VALUE self, VALUE raw_uri )
{
rb_iv_set( self, "@uri", raw_uri );
return Qnil;
}
开发者ID:aburan28,项目名称:ironbee,代码行数:6,代码来源:HTP.c
示例20: counter_stop
/*
:nodoc:
*/
static VALUE counter_stop(VALUE self)
{
rb_iv_set(self, "@st", INT2NUM(0));
rb_iv_set(self, "@counting", Qfalse);
return self;
}
开发者ID:cyross,项目名称:miyako2_with_ruby_sdl_win32_binary,代码行数:9,代码来源:miyako_basicdata.c
注:本文中的rb_iv_set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论