本文整理汇总了C++中rb_yield函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_yield函数的具体用法?C++ rb_yield怎么用?C++ rb_yield使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_yield函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rbclt_container_each_callback
static void
rbclt_container_each_callback (ClutterActor *actor, gpointer data)
{
rb_yield (GOBJ2RVAL (actor));
}
示例2: each_i
static VALUE
each_i(VALUE v, void *arg)
{
rb_yield(v);
return Qnil;
}
示例3: cCommand_execute_reader
static VALUE cCommand_execute_reader(int argc, VALUE *argv, VALUE self) {
VALUE query, reader;
VALUE field_names, field_types;
unsigned int field_count;
unsigned int i;
char guess_default_field_types = 0;
VALUE connection = rb_iv_get(self, "@connection");
VALUE mysql_connection = rb_iv_get(connection, "@connection");
if (Qnil == mysql_connection) {
rb_raise(eConnectionError, "This connection has already been closed.");
}
MYSQL *db = DATA_PTR(mysql_connection);
MYSQL_RES *response = 0;
MYSQL_FIELD *field;
query = build_query_from_args(self, argc, argv);
response = cCommand_execute(self, connection, db, query);
if (!response) {
return Qnil;
}
field_count = mysql_field_count(db);
reader = rb_funcall(cReader, ID_NEW, 0);
rb_iv_set(reader, "@connection", connection);
rb_iv_set(reader, "@reader", Data_Wrap_Struct(rb_cObject, 0, 0, response));
rb_iv_set(reader, "@opened", Qfalse);
rb_iv_set(reader, "@field_count", INT2NUM(field_count));
field_names = rb_ary_new();
field_types = rb_iv_get(self, "@field_types");
if ( field_types == Qnil || 0 == RARRAY_LEN(field_types) ) {
field_types = rb_ary_new();
guess_default_field_types = 1;
} else if (RARRAY_LEN(field_types) != field_count) {
// Whoops... wrong number of types passed to set_types. Close the reader and raise
// and error
rb_funcall(reader, rb_intern("close"), 0);
rb_raise(rb_eArgError, "Field-count mismatch. Expected %ld fields, but the query yielded %d", RARRAY_LEN(field_types), field_count);
}
for(i = 0; i < field_count; i++) {
field = mysql_fetch_field_direct(response, i);
rb_ary_push(field_names, rb_str_new2(field->name));
if (1 == guess_default_field_types) {
rb_ary_push(field_types, infer_ruby_type(field));
}
}
rb_iv_set(reader, "@fields", field_names);
rb_iv_set(reader, "@field_types", field_types);
if (rb_block_given_p()) {
rb_yield(reader);
rb_funcall(reader, rb_intern("close"), 0);
}
return reader;
}
示例4: foreach
//.........这里部分代码省略.........
len+=len2-1;
nobackslash=start;
free(line);
free(line2);
continue;
}
}
break;
}
/* chomp! */
if(line[len]==EOL){
if(line[len-1]==CR)
len-=1;
line[len]='\0';
}
/* skip empty line */
if(len<2)
continue;
ary = rb_ary_new();
start=line;
nobackslash=line;
idx = 0;
flag=1;
while (nobackslash != NULL) {
/* get full field */
while(token=strstr(nobackslash, DELIM)){
count=0;
t2=token-1;
while((t2>=line) && (*t2=='\\'))
{++count;--t2;}
if(count%2 ==1){ /* backslashed! skip */
nobackslash=token;
continue;
}
break;
}
if(token)
*token='\0';
else
token=start+strlen(start);
if(searchfield==idx){
flag=0;
/* do check! */
sscanf(start,"%ld",&check);
for(i=0;i<pairs_count;++i){
/*rb_warn("check %ld: [%ld .. %ld]",check,pairs[i].low,pairs[i].high);*/
if(pairs[i].low<check && pairs[i].high>check){
/*rb_warn("check passed");*/
flag=1; /* yahooo! */
break;
}
}
}
/* not in ranges! */
if(flag==0)
break;
rb_ary_store(ary, idx, rb_str_new(start, token-start));
idx++;
nobackslash=start=token+strlen(DELIM);
while(token=strstr(nobackslash, DELIM)){
count=0;
t2=token-1;
while((t2>=line) && (*t2=='\\'))
{++count;--t2;}
if(count%2 ==1){ /* backslashed! skip */
nobackslash=token+strlen(DELIM);
continue;
}
break;
}
nobackslash=token;
}
if(flag==0)
continue;
/* last item */
rb_ary_store(ary, idx, rb_str_new(start, strlen(start)));
/* OBJ_FREEZE(ary); */
rb_yield(ary);
/* FL_UNSET((ary), FL_FREEZE); */
/* for(idx = 0; idx < RARRAY_LEN(ary); idx ++) {
rb_ary_store(ary, idx, Qnil);
} */
}
fclose(file);
free(line);
return Qnil;
}
示例5: pt_ps
//.........这里部分代码省略.........
// Get the state of the process
switch(procs[i].kp_proc.p_stat)
{
case SIDL:
strcpy(state, "idle");
break;
case SRUN:
strcpy(state, "run");
break;
case SSLEEP:
strcpy(state, "sleep");
break;
case SSTOP:
strcpy(state, "stop");
break;
case SZOMB:
strcpy(state, "zombie");
break;
default:
strcpy(state, "unknown");
break;
}
// Get ttynum and ttydev. If ttynum is -1, there is no tty.
if(procs[i].kp_eproc.e_tdev != -1){
v_tty_num = INT2FIX(procs[i].kp_eproc.e_tdev),
v_tty_dev = rb_str_new2(devname(procs[i].kp_eproc.e_tdev, S_IFCHR));
}
v_groups = rb_ary_new();
for (g = 0; g < procs[i].kp_eproc.e_ucred.cr_ngroups; ++g)
rb_ary_push(v_groups, INT2FIX(procs[i].kp_eproc.e_ucred.cr_groups[g]));
v_pstruct = rb_struct_new(
sProcStruct,
INT2FIX(procs[i].kp_proc.p_pid),
INT2FIX(procs[i].kp_eproc.e_ppid),
INT2FIX(procs[i].kp_eproc.e_pgid),
INT2FIX(procs[i].kp_eproc.e_pcred.p_ruid),
INT2FIX(procs[i].kp_eproc.e_pcred.p_rgid),
INT2FIX(procs[i].kp_eproc.e_ucred.cr_uid),
rb_ary_entry(v_groups, 0),
v_groups,
INT2FIX(procs[i].kp_eproc.e_pcred.p_svuid),
INT2FIX(procs[i].kp_eproc.e_pcred.p_svgid),
rb_str_new2(procs[i].kp_proc.p_comm),
rb_str_new2(state),
rb_float_new(procs[i].kp_proc.p_pctcpu),
Qnil,
v_tty_num,
v_tty_dev,
rb_str_new2(procs[i].kp_eproc.e_wmesg),
INT2FIX(procs[i].kp_proc.p_rtime.tv_sec),
INT2FIX(procs[i].kp_proc.p_priority),
INT2FIX(procs[i].kp_proc.p_usrpri),
INT2FIX(procs[i].kp_proc.p_nice),
v_cmdline,
v_exe,
v_environ,
v_start_time,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_maxrss) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_ixrss) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_idrss) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_isrss) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_minflt) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_majflt) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nswap) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_inblock) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_oublock) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_msgsnd) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_msgrcv) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nsignals) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nvcsw) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_nivcsw) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_utime.tv_sec) : Qnil,
(procs[i].kp_proc.p_ru && procs[i].kp_proc.p_stat != 5) ? LONG2NUM(procs[i].kp_proc.p_ru->ru_stime.tv_sec) : Qnil
);
OBJ_FREEZE(v_pstruct); // This is read-only data
if(rb_block_given_p())
rb_yield(v_pstruct);
else
rb_ary_push(v_array, v_pstruct);
}
if(procs)
free(procs);
if(!rb_block_given_p()){
if(NIL_P(v_pid))
return v_array;
else
return v_pstruct;
}
return Qnil;
}
示例6: dict_each_key
static void
dict_each_key (const char *key, xmmsv_t *value, void *udata)
{
rb_yield (ID2SYM (rb_intern (key)));
}
示例7: each
//.........这里部分代码省略.........
column = UINT2NUM(*((unsigned char*)result_buffers[i].buffer));
} else {
column = INT2NUM(*((signed char*)result_buffers[i].buffer));
}
break;
case MYSQL_TYPE_SHORT: // short int
if (result_buffers[i].is_unsigned) {
column = UINT2NUM(*((unsigned short int*)result_buffers[i].buffer));
} else {
column = INT2NUM(*((short int*)result_buffers[i].buffer));
}
break;
case MYSQL_TYPE_INT24: // int
case MYSQL_TYPE_LONG: // int
case MYSQL_TYPE_YEAR: // int
if (result_buffers[i].is_unsigned) {
column = UINT2NUM(*((unsigned int*)result_buffers[i].buffer));
} else {
column = INT2NUM(*((int*)result_buffers[i].buffer));
}
break;
case MYSQL_TYPE_LONGLONG: // long long int
if (result_buffers[i].is_unsigned) {
column = ULL2NUM(*((unsigned long long int*)result_buffers[i].buffer));
} else {
column = LL2NUM(*((long long int*)result_buffers[i].buffer));
}
break;
case MYSQL_TYPE_FLOAT: // float
column = rb_float_new((double)(*((float*)result_buffers[i].buffer)));
break;
case MYSQL_TYPE_DOUBLE: // double
column = rb_float_new((double)(*((double*)result_buffers[i].buffer)));
break;
case MYSQL_TYPE_DATE: // MYSQL_TIME
ts = (MYSQL_TIME*)result_buffers[i].buffer;
column = rb_funcall(cDate, rb_intern("new"), 3, INT2NUM(ts->year), INT2NUM(ts->month), INT2NUM(ts->day));
break;
case MYSQL_TYPE_TIME: // MYSQL_TIME
ts = (MYSQL_TIME*)result_buffers[i].buffer;
column = rb_funcall(rb_cTime,
rb_intern("mktime"), 6,
UINT2NUM(Qnil),
UINT2NUM(Qnil),
UINT2NUM(Qnil),
UINT2NUM(ts->hour),
UINT2NUM(ts->minute),
UINT2NUM(ts->second));
break;
case MYSQL_TYPE_NEWDATE: // MYSQL_TIME
case MYSQL_TYPE_DATETIME: // MYSQL_TIME
case MYSQL_TYPE_TIMESTAMP: // MYSQL_TIME
ts = (MYSQL_TIME*)result_buffers[i].buffer;
column = rb_funcall(rb_cTime,
rb_intern("mktime"), 6,
UINT2NUM(ts->year),
UINT2NUM(ts->month),
UINT2NUM(ts->day),
UINT2NUM(ts->hour),
UINT2NUM(ts->minute),
UINT2NUM(ts->second));
break;
case MYSQL_TYPE_DECIMAL: // char[]
case MYSQL_TYPE_NEWDECIMAL: // char[]
column = rb_funcall(cBigDecimal, rb_intern("new"), 1, rb_str_new(result_buffers[i].buffer, *(result_buffers[i].length)));
break;
case MYSQL_TYPE_STRING: // char[]
case MYSQL_TYPE_VAR_STRING: // char[]
case MYSQL_TYPE_VARCHAR: // char[]
case MYSQL_TYPE_TINY_BLOB: // char[]
case MYSQL_TYPE_BLOB: // char[]
case MYSQL_TYPE_MEDIUM_BLOB: // char[]
case MYSQL_TYPE_LONG_BLOB: // char[]
case MYSQL_TYPE_BIT: // char[]
case MYSQL_TYPE_SET: // char[]
case MYSQL_TYPE_ENUM: // char[]
case MYSQL_TYPE_GEOMETRY: // char[]
column = rb_str_new(result_buffers[i].buffer, *(result_buffers[i].length));
break;
default:
rb_raise(cMysql2Error, "unhandled buffer type: %d",
result_buffers[i].buffer_type);
break;
}
}
rb_ary_store(row, (long)i, column);
}
rb_yield(row);
}
free(result_buffers);
free(is_null);
free(error);
free(length);
}
return self;
}
示例8: draw
/*
call-seq: draw(hash = nil) { ... }
Three keys are checked in the given hash : ":buffer" which is the buffer
on which manipulation are done (by default, the actual buffer is taken),
":painter", which tell us to yield a +Joyau::Painter+ instead of a
+Joyau::Buffer+ when true (false by default), and ":auto_update" which
tell us whether we should update the buffer (true by default).
It is mandatory to give a block to this function.
Examples:
Joyau.draw(:buffer => a_buffer, :painter => true)
Joyau.draw(:auto_update => false)
Joyau.draw(:painter => true)
Joyau.draw(:buffer => a_buffer)
*/
VALUE Joyau_draw(int argc, VALUE *argv, VALUE self) {
static bool can_draw = false;
VALUE hash, block;
rb_scan_args(argc, argv, "01&", &hash, &block);
OSL_IMAGE *oldBuffer = oslGetDrawBuffer();
Buffer *buffer = NULL;
VALUE rbPainter = Qnil;
bool painter = false;
bool auto_update = true;
bool ruby_buf = false;
bool could_draw = can_draw;
if (!NIL_P(hash)) {
if (TYPE(hash) != T_HASH)
rb_raise(rb_eTypeError, "Hash expected for Joyau::draw.");
VALUE rbBuffer = rb_hash_aref(hash, ID2SYM(rb_intern("buffer")));
if (rb_obj_is_kind_of(rbBuffer, getClass("Buffer")) == Qfalse) {
if (rbBuffer != Qnil)
rb_raise(rb_eTypeError, ":buffer should be a Buffer (or nil).");
}
else {
buffer = getPtr<Buffer>(rbBuffer);
ruby_buf = true;
}
if (!buffer)
buffer = new Buffer(oldBuffer);
if (rb_hash_aref(hash, ID2SYM(rb_intern("painter"))) == Qtrue) {
painter = true;
Painter painter(buffer);
rbPainter = createObject(getClass("Painter"), painter);
}
if (rb_hash_aref(hash, ID2SYM(rb_intern("auto_update"))) == Qfalse)
auto_update = false;
}
else {
if (!buffer)
buffer = new Buffer(oldBuffer);
}
if (buffer->isScreen() && !can_draw) {
can_draw = true;
Graphics_startDraw(Qnil);
}
if (!NIL_P(block)) {
buffer->setActual();
if (painter)
rb_yield(rbPainter);
else {
VALUE rbBuffer = createObject(getClass("Buffer"), *buffer, true);
rb_yield(rbBuffer);
}
if (buffer->isScreen() && !could_draw) {
can_draw = false;
Graphics_endDraw(Qnil);
}
if (auto_update && buffer->isScreen())
Graphics_sync(Qnil);
}
else
rb_raise(rb_eArgError, "Block expected.");
if (!ruby_buf) // We do not delete the buffer if it comes from Ruby.
delete buffer;
oslSetDrawBuffer(oldBuffer);
return Qnil;
}
示例9: enumerator_iter_i
static VALUE
enumerator_iter_i(VALUE i, VALUE enum_obj, int argc, VALUE *argv)
{
struct enumerator *e = (struct enumerator *)enum_obj;
return rb_yield(proc_call(e->proc, i));
}
示例10: obj_new_with_block_body
static VALUE
obj_new_with_block_body(VALUE arg)
{
return rb_yield(arg);
}
示例11: sync_body
static VALUE
sync_body(VALUE a)
{
return rb_yield(Qundef);
}
示例12: iter_yield
static VALUE iter_yield(VALUE el, VALUE ary) {
rb_yield(el);
return Qnil;
}
示例13: rb_tinytds_result_each
static VALUE rb_tinytds_result_each(int argc, VALUE * argv, VALUE self) {
/* Local Vars */
VALUE qopts, opts, block;
ID timezone;
int symbolize_keys = 0, as_array = 0, cache_rows = 0, first = 0, empty_sets = 0;
tinytds_client_userdata *userdata;
GET_RESULT_WRAPPER(self);
userdata = (tinytds_client_userdata *)dbgetuserdata(rwrap->client);
/* Merge Options Hash To Query Options. Populate Opts & Block Var. */
qopts = rb_iv_get(self, "@query_options");
if (rb_scan_args(argc, argv, "01&", &opts, &block) == 1)
qopts = rb_funcall(qopts, intern_merge, 1, opts);
rb_iv_set(self, "@query_options", qopts);
/* Locals From Options */
if (rb_hash_aref(qopts, sym_first) == Qtrue)
first = 1;
if (rb_hash_aref(qopts, sym_symbolize_keys) == Qtrue)
symbolize_keys = 1;
if (rb_hash_aref(qopts, sym_as) == sym_array)
as_array = 1;
if (rb_hash_aref(qopts, sym_cache_rows) == Qtrue)
cache_rows = 1;
if (rb_hash_aref(qopts, sym_timezone) == sym_local) {
timezone = intern_local;
} else if (rb_hash_aref(qopts, sym_timezone) == sym_utc) {
timezone = intern_utc;
} else {
rb_warn(":timezone option must be :utc or :local - defaulting to :local");
timezone = intern_local;
}
if (rb_hash_aref(qopts, sym_empty_sets) == Qtrue)
empty_sets = 1;
/* Make The Results Or Yield Existing */
if (NIL_P(rwrap->results)) {
RETCODE dbsqlok_rc, dbresults_rc;
rwrap->results = rb_ary_new();
dbsqlok_rc = rb_tinytds_result_ok_helper(rwrap->client);
dbresults_rc = rb_tinytds_result_dbresults_retcode(self);
while ((dbsqlok_rc == SUCCEED) && (dbresults_rc == SUCCEED)) {
int has_rows = (DBROWS(rwrap->client) == SUCCEED) ? 1 : 0;
if (has_rows || empty_sets || (rwrap->number_of_results == 0))
rb_tinytds_result_fields(self);
if ((has_rows || empty_sets) && rwrap->number_of_fields > 0) {
/* Create rows for this result set. */
unsigned long rowi = 0;
VALUE result = rb_ary_new();
while (nogvl_dbnextrow(rwrap->client) != NO_MORE_ROWS) {
VALUE row = rb_tinytds_result_fetch_row(self, timezone, symbolize_keys, as_array);
if (cache_rows)
rb_ary_store(result, rowi, row);
if (!NIL_P(block))
rb_yield(row);
if (first) {
dbcanquery(rwrap->client);
userdata->dbcancel_sent = 1;
}
rowi++;
}
rwrap->number_of_rows = rowi;
/* Store the result. */
if (cache_rows) {
if (rwrap->number_of_results == 0) {
rwrap->results = result;
} else if (rwrap->number_of_results == 1) {
VALUE multi_resultsets = rb_ary_new();
rb_ary_store(multi_resultsets, 0, rwrap->results);
rb_ary_store(multi_resultsets, 1, result);
rwrap->results = multi_resultsets;
} else {
rb_ary_store(rwrap->results, rwrap->number_of_results, result);
}
}
// If we find results increment the counter that helpers use and setup the next loop.
rwrap->number_of_results = rwrap->number_of_results + 1;
dbresults_rc = rb_tinytds_result_dbresults_retcode(self);
rb_ary_store(rwrap->fields_processed, rwrap->number_of_results, Qnil);
} else {
// If we do not find results, side step the rb_tinytds_result_dbresults_retcode helper and
// manually populate its memoized array while nullifing any memoized fields too before loop.
dbresults_rc = nogvl_dbresults(rwrap->client);
rb_ary_store(rwrap->dbresults_retcodes, rwrap->number_of_results, INT2FIX(dbresults_rc));
rb_ary_store(rwrap->fields_processed, rwrap->number_of_results, Qnil);
}
}
if (dbresults_rc == FAIL)
rb_warn("TinyTDS: Something in the dbresults() while loop set the return code to FAIL.\n");
userdata->dbsql_sent = 0;
} else if (!NIL_P(block)) {
unsigned long i;
for (i = 0; i < rwrap->number_of_rows; i++) {
rb_yield(rb_ary_entry(rwrap->results, i));
}
}
return rwrap->results;
}
示例14: sb_yield
static VALUE sb_yield(VALUE self) {
return rb_yield(INT2FIX(5));
}
示例15: initialize
/* call-seq: SQLite3::Database.new(file, options = {})
*
* Create a new Database object that opens the given file. If utf16
* is +true+, the filename is interpreted as a UTF-16 encoded string.
*
* By default, the new database will return result rows as arrays
* (#results_as_hash) and has type translation disabled (#type_translation=).
*/
static VALUE initialize(int argc, VALUE *argv, VALUE self)
{
sqlite3RubyPtr ctx;
VALUE file;
VALUE opts;
VALUE zvfs;
#ifdef HAVE_SQLITE3_OPEN_V2
int mode = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
#endif
int status;
Data_Get_Struct(self, sqlite3Ruby, ctx);
rb_scan_args(argc, argv, "12", &file, &opts, &zvfs);
#if defined StringValueCStr
StringValuePtr(file);
rb_check_safe_obj(file);
#else
Check_SafeStr(file);
#endif
if(NIL_P(opts)) opts = rb_hash_new();
else Check_Type(opts, T_HASH);
#ifdef HAVE_RUBY_ENCODING_H
if(UTF16_LE_P(file) || UTF16_BE_P(file)) {
status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);
} else {
#endif
if(Qtrue == rb_hash_aref(opts, sym_utf16)) {
status = sqlite3_open16(utf16_string_value_ptr(file), &ctx->db);
} else {
#ifdef HAVE_RUBY_ENCODING_H
if(!UTF8_P(file)) {
file = rb_str_export_to_enc(file, rb_utf8_encoding());
}
#endif
if (Qtrue == rb_hash_aref(opts, ID2SYM(rb_intern("readonly")))) {
#ifdef HAVE_SQLITE3_OPEN_V2
mode = SQLITE_OPEN_READONLY;
#else
rb_raise(rb_eNotImpError, "sqlite3-ruby was compiled against a version of sqlite that does not support readonly databases");
#endif
}
#ifdef HAVE_SQLITE3_OPEN_V2
status = sqlite3_open_v2(
StringValuePtr(file),
&ctx->db,
mode,
NIL_P(zvfs) ? NULL : StringValuePtr(zvfs)
);
#else
status = sqlite3_open(
StringValuePtr(file),
&ctx->db
);
#endif
}
#ifdef HAVE_RUBY_ENCODING_H
}
#endif
CHECK(ctx->db, status)
rb_iv_set(self, "@tracefunc", Qnil);
rb_iv_set(self, "@authorizer", Qnil);
rb_iv_set(self, "@encoding", Qnil);
rb_iv_set(self, "@busy_handler", Qnil);
rb_iv_set(self, "@collations", rb_hash_new());
rb_iv_set(self, "@functions", rb_hash_new());
rb_iv_set(self, "@results_as_hash", rb_hash_aref(opts, sym_results_as_hash));
rb_iv_set(self, "@type_translation", rb_hash_aref(opts, sym_type_translation));
#ifdef HAVE_SQLITE3_OPEN_V2
rb_iv_set(self, "@readonly", mode == SQLITE_OPEN_READONLY ? Qtrue : Qfalse);
#else
rb_iv_set(self, "@readonly", Qfalse);
#endif
if(rb_block_given_p()) {
rb_yield(self);
rb_funcall(self, rb_intern("close"), 0);
}
return self;
}