本文整理汇总了C++中TYPE函数的典型用法代码示例。如果您正苦于以下问题:C++ TYPE函数的具体用法?C++ TYPE怎么用?C++ TYPE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TYPE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flashread
static long
flashread(Chan *c, void *buf, long n, vlong offset)
{
Flash *f;
Flashpart *fp;
Flashregion *r;
int i;
ulong start, end;
char *s, *o;
if(c->qid.type & QTDIR)
return devdirread(c, buf, n, nil, 0, flashgen);
f = flash.card[c->dev];
fp = &f->part[PART(c->qid.path)];
if(fp->name == nil)
error(Egreg);
switch(TYPE(c->qid.path)){
case Qdata:
offset += fp->start;
if(offset >= fp->end)
return 0;
if(offset+n > fp->end)
n = fp->end - offset;
n = readflash(f, buf, offset, n);
if(n < 0)
error(Eio);
return n;
case Qctl:
s = malloc(READSTR);
if(s == nil)
error(Enomem);
if(waserror()){
free(s);
nexterror();
}
o = seprint(s, s+READSTR, "%#2.2ux %#4.4ux %d %q\n",
f->id, f->devid, f->width, f->sort!=nil? f->sort: "nor");
for(i=0; i<f->nr; i++){
r = &f->regions[i];
if(r->start < fp->end && fp->start < r->end){
start = r->start;
if(fp->start > start)
start = fp->start;
end = r->end;
if(fp->end < end)
end = fp->end;
o = seprint(o, s+READSTR, "%#8.8lux %#8.8lux %#8.8lux",
start, end, r->erasesize);
if(r->pagesize)
o = seprint(o, s+READSTR, " %#8.8lux",
r->pagesize);
o = seprint(o, s+READSTR, "\n");
}
}
n = readstr(offset, buf, n, s);
poperror();
free(s);
return n;
}
error(Egreg);
return 0; /* not reached */
}
示例2: g_unichar_islower
/**
* g_unichar_islower:
* @c: a Unicode character
*
* Determines whether a character is a lowercase letter.
* Given some UTF-8 text, obtain a character value with
* g_utf8_get_char().
*
* Return value: %TRUE if @c is a lowercase letter
**/
gboolean
g_unichar_islower (gunichar c)
{
return TYPE (c) == G_UNICODE_LOWERCASE_LETTER;
}
示例3: g_unichar_isupper
/**
* g_unichar_isupper:
* @c: a Unicode character
*
* Determines if a character is uppercase.
*
* Return value: %TRUE if @c is an uppercase character
**/
gboolean
g_unichar_isupper (gunichar c)
{
return TYPE (c) == G_UNICODE_UPPERCASE_LETTER;
}
示例4: g_unichar_isalnum
/**
* g_unichar_isalnum:
* @c: a Unicode character
*
* Determines whether a character is alphanumeric.
* Given some UTF-8 text, obtain a character value
* with g_utf8_get_char().
*
* Return value: %TRUE if @c is an alphanumeric character
**/
gboolean
g_unichar_isalnum (gunichar c)
{
return ISALDIGIT (TYPE (c)) ? TRUE : FALSE;
}
示例5: g_unichar_iscntrl
/**
* g_unichar_iscntrl:
* @c: a Unicode character
*
* Determines whether a character is a control character.
* Given some UTF-8 text, obtain a character value with
* g_utf8_get_char().
*
* Return value: %TRUE if @c is a control character
**/
gboolean
g_unichar_iscntrl (gunichar c)
{
return TYPE (c) == G_UNICODE_CONTROL;
}
示例6: rb_c_impl_SQLite3_execute
unsigned long rb_c_impl_SQLite3_execute(int argc, VALUE *argv, void* pDB)
{
sqlite3 * db = NULL;
void **ppDB = &pDB;
sqlite3_stmt *statement = NULL;
const char* sql = NULL;
VALUE arRes = rb_ary_new();
VALUE* colNames = NULL;
int nRes = 0;
char * szErrMsg = 0;
int is_batch = 0;
if ((argc < 2) || (argc > 3))
rb_raise(rb_eArgError, "wrong # of arguments(%d for 3)",argc);
db = (sqlite3 *)rho_db_get_handle(*ppDB);
sql = RSTRING_PTR(argv[0]);
is_batch = argv[1] == Qtrue ? 1 : 0;
RAWTRACE1("db_execute: %s", sql);
PROF_START_CREATED("SQLITE");
if ( is_batch )
{
PROF_START_CREATED("SQLITE_EXEC");
rho_db_lock(*ppDB);
nRes = sqlite3_exec(db, sql, NULL, NULL, &szErrMsg);
rho_db_unlock(*ppDB);
PROF_STOP("SQLITE_EXEC");
}
else
{
rho_db_lock(*ppDB);
PROF_START_CREATED("SQLITE_PREPARE");
nRes = rho_db_prepare_statement(*ppDB, sql, -1, &statement);
PROF_STOP("SQLITE_PREPARE");
//nRes = sqlite3_prepare_v2(db, sql, -1, &statement, NULL);
if ( nRes != SQLITE_OK)
{
szErrMsg = (char *)sqlite3_errmsg(db);
rho_db_unlock(*ppDB);
rb_raise(rb_eArgError, "could not prepare statement: %d; Message: %s",nRes, (szErrMsg?szErrMsg:""));
}
if ( (argc > 2) && (TYPE(argv[2]) == T_ARRAY) )
{
int i = 0;
VALUE args = argv[2];
if ( RARRAY_LEN(args) > 0 && TYPE(RARRAY_PTR(args)[0]) == T_ARRAY )
args = RARRAY_PTR(args)[0];
for( ; i < RARRAY_LEN(args); i++ )
{
VALUE arg = RARRAY_PTR(args)[i];
if (NIL_P(arg))
{
sqlite3_bind_null(statement, i+1);
continue;
}
switch( TYPE(arg) )
{
case T_STRING:
sqlite3_bind_text(statement, i+1, RSTRING_PTR(arg), RSTRING_LEN(arg), SQLITE_TRANSIENT);
break;
case T_FLOAT:
sqlite3_bind_double(statement, i+1, NUM2DBL(arg));
break;
case T_FIXNUM:
case T_BIGNUM:
sqlite3_bind_int64(statement, i+1, NUM2LL(arg));
break;
case T_DATA:
if (CLASS_OF(arg) == rb_cTime)
{
VALUE intVal = rb_funcall(arg, rb_intern("to_i"), 0);
sqlite3_bind_int64(statement, i+1, NUM2LL(intVal));
break;
}
default:
{
VALUE strVal = rb_funcall(arg, rb_intern("to_s"), 0);
sqlite3_bind_text(statement, i+1, RSTRING_PTR(strVal), -1, SQLITE_TRANSIENT);
}
break;
}
}
}
PROF_START_CREATED("SQLITE_EXEC");
nRes = sqlite3_step(statement);
PROF_STOP("SQLITE_EXEC");
while( nRes== SQLITE_ROW ) {
int nCount = sqlite3_data_count(statement);
int nCol = 0;
//.........这里部分代码省略.........
示例7: TYPE
/*******************************************************************************
*** FUNCTION PROG()
*******************************************************************************
*** DESCRIPTION : Processes PROG grammar rule.
***
*** PROG -> TYPE idt REST PROG |
*** const idt = num ; PROG |
*** e
******************************************************************************/
void RecursiveParser::PROG()
{
EntryPtr ptr;
VarType type;
ParamPtr paramptr = NULL;
base = NULL;
bool func;
string code;
int local_vars = 0;
int param_num = 0;
if (global->Token == Global::intt || global->Token == Global::floatt || global->Token == Global::chart)
{
TYPE(type);
symtab->insert(global->Lexeme, global->Token, depth);
ptr = symtab->lookup(global->Lexeme);
funcname = global->Lexeme;
match(Global::idt);
if (global->Token == Global::lparent)
{
func = true;
code = "proc " + funcname;
emit(code);
//if function
ptr->TypeOfEntry = functionEntry;
ptr->function.ReturnType = type;
ptr->function.ParamList = new ParamNode();
paramptr = ptr->function.ParamList;
ptr->function.NumberOfParameters = 0;
base = paramptr;
}
else
{
funcname = "::EMPTY::";
//if variable declaration
ptr->TypeOfEntry = varEntry;
ptr->var.TypeOfVariable = type;
ptr->var.Offset = offset;
ptr->var.size = getsize(type, offset);
}
REST(type, offset, paramptr, local_vars, param_num);
if (func)
{
code = "endp " + funcname;
emit(code);
code = "START PROC " + funcname;
emit(code);
func = false;
}
PROG();
}
//rest is for constant
else if (global->Token == Global::constt)
{
match(Global::constt);
symtab->insert(global->Lexeme, global->Token, depth);
ptr = symtab->lookup(global->Lexeme);
ptr->TypeOfEntry = constEntry;
match(Global::idt);
match(Global::assignopt);
if (lex->isFloat)
{
ptr->constant.TypeOfConstant = floatType;
ptr->constant.ValueR = global->ValueR;
}
else
{
ptr->constant.TypeOfConstant = intType;
ptr->constant.Value = global->Value;
}
match(Global::numt);
match(Global::semicolont);
PROG();
}
else
//.........这里部分代码省略.........
示例8: rb_str_format
//.........这里部分代码省略.........
long v = 0;
int base, bignum = 0;
int len, pos;
switch (*p) {
case 'd':
case 'i':
case 'u':
sign = 1; break;
case 'o':
case 'x':
case 'X':
case 'b':
case 'B':
if (flags&(FPLUS|FSPACE)) sign = 1;
break;
}
if (flags & FSHARP) {
switch (*p) {
case 'o':
prefix = "0"; break;
case 'x':
prefix = "0x"; break;
case 'X':
prefix = "0X"; break;
case 'b':
prefix = "0b"; break;
case 'B':
prefix = "0B"; break;
}
}
bin_retry:
switch (TYPE(val)) {
case T_FLOAT:
if (FIXABLE(RFLOAT_VALUE(val))) {
val = LONG2FIX((long)RFLOAT_VALUE(val));
goto bin_retry;
}
val = rb_dbl2big(RFLOAT_VALUE(val));
if (FIXNUM_P(val)) goto bin_retry;
bignum = 1;
break;
case T_STRING:
val = rb_str_to_inum(val, 0, Qtrue);
goto bin_retry;
case T_BIGNUM:
bignum = 1;
break;
case T_FIXNUM:
v = FIX2LONG(val);
break;
default:
val = rb_Integer(val);
goto bin_retry;
}
switch (*p) {
case 'o':
base = 8; break;
case 'x':
case 'X':
base = 16; break;
case 'b':
case 'B':
base = 2; break;
示例9: ruby_cleanup
int
ruby_cleanup(int ex)
{
int state;
volatile VALUE errs[2];
rb_thread_t *th = GET_THREAD();
int nerr;
errs[1] = th->errinfo;
th->safe_level = 0;
Init_stack((void *)&state);
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, ruby_finalize_0());
}
POP_TAG();
errs[0] = th->errinfo;
PUSH_TAG();
if ((state = EXEC_TAG()) == 0) {
SAVE_ROOT_JMPBUF(th, rb_thread_terminate_all());
}
else if (ex == 0) {
ex = state;
}
th->errinfo = errs[1];
ex = error_handle(ex);
ruby_finalize_1();
POP_TAG();
rb_thread_stop_timer_thread();
for (nerr = 0; nerr < sizeof(errs) / sizeof(errs[0]); ++nerr) {
VALUE err = errs[nerr];
if (!RTEST(err)) continue;
/* th->errinfo contains a NODE while break'ing */
if (TYPE(err) == T_NODE) continue;
if (rb_obj_is_kind_of(err, rb_eSystemExit)) {
return sysexit_status(err);
}
else if (rb_obj_is_kind_of(err, rb_eSignal)) {
VALUE sig = rb_iv_get(err, "signo");
ruby_default_signal(NUM2INT(sig));
}
else if (ex == 0) {
ex = 1;
}
}
#if EXIT_SUCCESS != 0 || EXIT_FAILURE != 1
switch (ex) {
#if EXIT_SUCCESS != 0
case 0: return EXIT_SUCCESS;
#endif
#if EXIT_FAILURE != 1
case 1: return EXIT_FAILURE;
#endif
}
#endif
return ex;
}
示例10: TYPE
const Node::Type& HighpassFilter::getType() const
{
return TYPE();
}
示例11: write_container
static void write_container(int ttype, VALUE field_info, VALUE value, VALUE protocol) {
int sz, i;
if (ttype == TTYPE_MAP) {
VALUE keys;
VALUE key;
VALUE val;
Check_Type(value, T_HASH);
VALUE key_info = rb_hash_aref(field_info, key_sym);
VALUE keytype_value = rb_hash_aref(key_info, type_sym);
int keytype = FIX2INT(keytype_value);
VALUE value_info = rb_hash_aref(field_info, value_sym);
VALUE valuetype_value = rb_hash_aref(value_info, type_sym);
int valuetype = FIX2INT(valuetype_value);
keys = rb_funcall(value, keys_method_id, 0);
sz = RARRAY_LEN(keys);
mt->write_map_begin(protocol, keytype_value, valuetype_value, INT2FIX(sz));
for (i = 0; i < sz; i++) {
key = rb_ary_entry(keys, i);
val = rb_hash_aref(value, key);
if (IS_CONTAINER(keytype)) {
write_container(keytype, key_info, key, protocol);
} else {
write_anything(keytype, key, protocol, key_info);
}
if (IS_CONTAINER(valuetype)) {
write_container(valuetype, value_info, val, protocol);
} else {
write_anything(valuetype, val, protocol, value_info);
}
}
mt->write_map_end(protocol);
} else if (ttype == TTYPE_LIST) {
Check_Type(value, T_ARRAY);
sz = RARRAY_LEN(value);
VALUE element_type_info = rb_hash_aref(field_info, element_sym);
VALUE element_type_value = rb_hash_aref(element_type_info, type_sym);
int element_type = FIX2INT(element_type_value);
mt->write_list_begin(protocol, element_type_value, INT2FIX(sz));
for (i = 0; i < sz; ++i) {
VALUE val = rb_ary_entry(value, i);
if (IS_CONTAINER(element_type)) {
write_container(element_type, element_type_info, val, protocol);
} else {
write_anything(element_type, val, protocol, element_type_info);
}
}
mt->write_list_end(protocol);
} else if (ttype == TTYPE_SET) {
VALUE items;
if (TYPE(value) == T_ARRAY) {
items = value;
} else {
if (rb_cSet == CLASS_OF(value)) {
items = rb_funcall(value, entries_method_id, 0);
} else {
Check_Type(value, T_HASH);
items = rb_funcall(value, keys_method_id, 0);
}
}
sz = RARRAY_LEN(items);
VALUE element_type_info = rb_hash_aref(field_info, element_sym);
VALUE element_type_value = rb_hash_aref(element_type_info, type_sym);
int element_type = FIX2INT(element_type_value);
mt->write_set_begin(protocol, element_type_value, INT2FIX(sz));
for (i = 0; i < sz; i++) {
VALUE val = rb_ary_entry(items, i);
if (IS_CONTAINER(element_type)) {
write_container(element_type, element_type_info, val, protocol);
} else {
write_anything(element_type, val, protocol, element_type_info);
}
}
mt->write_set_end(protocol);
} else {
rb_raise(rb_eNotImpError, "can't write container of type: %d", ttype);
}
}
示例12: flashwrite
static long
flashwrite(Chan *c, void *buf, long n, vlong offset)
{
Cmdbuf *cb;
Cmdtab *ct;
ulong addr, start, end;
char *e;
Flashpart *fp;
Flashregion *r;
Flash *f;
f = flash.card[c->dev];
fp = &f->part[PART(c->qid.path)];
if(fp->name == nil)
error(Egreg);
switch(TYPE(c->qid.path)){
case Qdata:
if(f->write == nil)
error(Eperm);
offset += fp->start;
if(offset >= fp->end)
return 0;
if(offset+n > fp->end)
n = fp->end - offset;
n = writeflash(f, offset, buf, n);
if(n < 0)
error(Eio);
return n;
case Qctl:
cb = parsecmd(buf, n);
if(waserror()){
free(cb);
nexterror();
}
ct = lookupcmd(cb, flashcmds, nelem(flashcmds));
switch(ct->index){
case CMerase:
if(strcmp(cb->f[1], "all") != 0){
addr = flashaddr(f, fp, cb->f[1]);
r = flashregion(f, addr);
if(r == nil)
error("nonexistent flash region");
if(addr%r->erasesize != 0)
error("invalid erase block address");
eraseflash(f, r, addr);
}else if(fp->start == 0 && fp->end == f->size &&
f->eraseall != nil){
eraseflash(f, nil, 0);
}else{
for(addr = fp->start; addr < fp->end;
addr += r->erasesize){
r = flashregion(f, addr);
if(r == nil)
error("nonexistent flash region");
if(addr%r->erasesize != 0)
error("invalid erase block address");
eraseflash(f, r, addr);
}
}
break;
case CMadd:
if(cb->nf < 3)
error(Ebadarg);
start = flashaddr(f, fp, cb->f[2]);
if(cb->nf > 3 && strcmp(cb->f[3], "end") != 0)
end = flashaddr(f, fp, cb->f[3]);
else
end = fp->end;
if(start > end || start >= fp->end || end > fp->end)
error(Ebadarg);
e = flashnewpart(f, cb->f[1], start, end);
if(e != nil)
error(e);
break;
case CMremove:
/* TO DO */
break;
case CMprotectboot:
if(cb->nf > 1 && strcmp(cb->f[1], "off") == 0)
f->protect = 0;
else
f->protect = 1;
break;
case CMsync:
/* TO DO? */
break;
default:
error(Ebadarg);
}
poperror();
free(cb);
return n;
}
error(Egreg);
return 0; /* not reached */
}
示例13: GSL_REAL
/* generate random m_{ij} and add it */
int xr = (int) (gsl_rng_uniform(r) * (upper - lower) + lower);
int xi = (int) (gsl_rng_uniform(r) * (upper - lower) + lower);
BASE x;
GSL_REAL(x) = (ATOMIC) xr;
GSL_IMAG(x) = (ATOMIC) xi;
FUNCTION (gsl_spmatrix, set) (m, i, j, x);
}
return m;
}
static void
FUNCTION (test, random_dense)(TYPE (gsl_matrix) * m, const double lower,
const double upper, const gsl_rng *r)
{
const size_t M = m->size1;
const size_t N = m->size2;
size_t i, j;
for (i = 0; i < M; ++i)
{
for (j = 0; j < N; ++j)
{
double x;
BASE z;
x = gsl_rng_uniform(r) * (upper - lower) + lower;
GSL_REAL (z) = (ATOMIC) x;
示例14: nurat_s_convert
static VALUE
nurat_s_convert(VALUE klass, SEL sel, int argc, VALUE *argv)
{
VALUE a1, a2, backref;
rb_scan_args(argc, argv, "11", &a1, &a2);
if (NIL_P(a1) || (argc == 2 && NIL_P(a2)))
rb_raise(rb_eTypeError, "can't convert nil into Rational");
switch (TYPE(a1)) {
case T_COMPLEX:
if (k_exact_zero_p(RCOMPLEX(a1)->imag))
a1 = RCOMPLEX(a1)->real;
}
switch (TYPE(a2)) {
case T_COMPLEX:
if (k_exact_zero_p(RCOMPLEX(a2)->imag))
a2 = RCOMPLEX(a2)->real;
}
backref = rb_backref_get();
rb_match_busy(backref);
switch (TYPE(a1)) {
case T_FIXNUM:
case T_BIGNUM:
break;
case T_FLOAT:
a1 = f_to_r(a1);
break;
case T_STRING:
a1 = string_to_r_strict(a1);
break;
}
switch (TYPE(a2)) {
case T_FIXNUM:
case T_BIGNUM:
break;
case T_FLOAT:
a2 = f_to_r(a2);
break;
case T_STRING:
a2 = string_to_r_strict(a2);
break;
}
rb_backref_set(backref);
switch (TYPE(a1)) {
case T_RATIONAL:
if (argc == 1 || (k_exact_one_p(a2)))
return a1;
}
if (argc == 1) {
if (!(k_numeric_p(a1) && k_integer_p(a1)))
return rb_convert_type(a1, T_RATIONAL, "Rational", "to_r");
}
else {
if ((k_numeric_p(a1) && k_numeric_p(a2)) &&
(!f_integer_p(a1) || !f_integer_p(a2)))
return f_div(a1, a2);
}
{
VALUE argv2[2];
argv2[0] = a1;
argv2[1] = a2;
return nurat_s_new(argc, argv2, klass);
}
}
示例15: rbffi_SetupCallParams
void
rbffi_SetupCallParams(int argc, VALUE* argv, int paramCount, Type** paramTypes,
FFIStorage* paramStorage, void** ffiValues,
VALUE* callbackParameters, int callbackCount, VALUE enums)
{
VALUE callbackProc = Qnil;
FFIStorage* param = ¶mStorage[0];
int i, argidx, cbidx, argCount;
if (unlikely(paramCount != -1 && paramCount != argc)) {
if (argc == (paramCount - 1) && callbackCount == 1 && rb_block_given_p()) {
callbackProc = rb_block_proc();
} else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, paramCount);
}
}
argCount = paramCount != -1 ? paramCount : argc;
for (i = 0, argidx = 0, cbidx = 0; i < argCount; ++i) {
Type* paramType = paramTypes[i];
int type;
if (unlikely(paramType->nativeType == NATIVE_MAPPED)) {
VALUE values[] = { argv[argidx], Qnil };
argv[argidx] = rb_funcall2(((MappedType *) paramType)->rbConverter, id_to_native, 2, values);
paramType = ((MappedType *) paramType)->type;
}
type = argidx < argc ? TYPE(argv[argidx]) : T_NONE;
ffiValues[i] = param;
switch (paramType->nativeType) {
case NATIVE_INT8:
param->s8 = NUM2INT(argv[argidx]);
++argidx;
ADJ(param, INT8);
break;
case NATIVE_INT16:
param->s16 = NUM2INT(argv[argidx]);
++argidx;
ADJ(param, INT16);
break;
case NATIVE_INT32:
if (unlikely(type == T_SYMBOL && enums != Qnil)) {
VALUE value = rb_funcall(enums, id_map_symbol, 1, argv[argidx]);
param->s32 = NUM2INT(value);
} else {
param->s32 = NUM2INT(argv[argidx]);
}
++argidx;
ADJ(param, INT32);
break;
case NATIVE_BOOL:
if (type != T_TRUE && type != T_FALSE) {
rb_raise(rb_eTypeError, "wrong argument type (expected a boolean parameter)");
}
param->s8 = argv[argidx++] == Qtrue;
ADJ(param, INT8);
break;
case NATIVE_UINT8:
param->u8 = NUM2UINT(argv[argidx]);
ADJ(param, INT8);
++argidx;
break;
case NATIVE_UINT16:
param->u16 = NUM2UINT(argv[argidx]);
ADJ(param, INT16);
++argidx;
break;
case NATIVE_UINT32:
param->u32 = NUM2UINT(argv[argidx]);
ADJ(param, INT32);
++argidx;
break;
case NATIVE_INT64:
param->i64 = NUM2LL(argv[argidx]);
ADJ(param, INT64);
++argidx;
break;
//.........这里部分代码省略.........