本文整理汇总了C++中Array_obj类的典型用法代码示例。如果您正苦于以下问题:C++ Array_obj类的具体用法?C++ Array_obj怎么用?C++ Array_obj使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Array_obj类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: val_array_double
double * val_array_double(hx::Object * arg1)
{
Array_obj<double> *a = dynamic_cast< Array_obj<double> * >(arg1);
if (a==0)
return 0;
return (double *)a->GetBase();
}
示例2: val_array_float
float * val_array_float(hx::Object * arg1)
{
Array_obj<float> *a = dynamic_cast< Array_obj<float> * >(arg1);
if (a==0)
return 0;
return (float *)a->GetBase();
}
示例3: file_contents
/**
file_contents : f:string -> string
<doc>Read the content of the file [f] and return it.</doc>
**/
static value file_contents( value name ) {
using namespace Kore;
buffer s=0;
int len;
val_check(name,string);
fio f(val_filename(name));
const char* fname = val_string(name);
gc_enter_blocking();
{
FileReader file;
if (file.open(fname)) {
len = static_cast<int>(file.size());
#ifdef SYS_WIIU
void* data = file.readAll();
Array_obj<unsigned char>* b = new Array_obj<unsigned char>(len, len);
memcpy(b->GetBase(), data, len);
s = (buffer)b;
#else
s = alloc_buffer_len(len);
file.read(buffer_data(s), static_cast<uint>(len));
#endif
}
else {
file_error("file_contents", &f);
}
}
gc_exit_blocking();
return buffer_val(s);
}
示例4: val_array_bool
// Array access - fast if possible - may return null
// Resizing the array may invalidate the pointer
bool * val_array_bool(hx::Object * arg1)
{
Array_obj<bool> *a = dynamic_cast< Array_obj<bool> * >(arg1);
if (a==0)
return 0;
return (bool *)a->GetBase();
}
示例5: Dynamic
hx::Object *runObject(CppiaCtx *ctx)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int i = args[0]->runInt(ctx);
BCR_CHECK;
ELEM &elem = thisVal->Item(i);
FUNC::run(elem, ctx, args[1]);
return Dynamic(elem).mPtr;
}
示例6: runString
String runString(CppiaCtx *ctx)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int i = args[0]->runInt(ctx);
BCR_CHECK;
ELEM &elem = thisVal->Item(i);
FUNC::run(elem, ctx, args[1]);
return ValToString(elem);
}
示例7: runFloat
Float runFloat(CppiaCtx *ctx)
{
if (FUNC==afPop)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return ValToFloat(thisVal->pop());
}
if (FUNC==afShift)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return ValToFloat(thisVal->shift());
}
if (FUNC==af__get)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return ValToFloat(thisVal->__get(args[0]->runInt(ctx)));
}
if (FUNC==af__set)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int i = args[0]->runInt(ctx);
ELEM elem;
runValue(elem,ctx,args[1]);
BCR_CHECK;
thisVal->Item(i) = elem;
return ValToFloat(elem);
}
if (FUNC==af__crement)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
ELEM &elem = thisVal->Item(args[0]->runInt(ctx));
return ValToFloat(CREMENT::run(elem));
}
if (FUNC==afPush)
return runInt(ctx);
return 0.0;
}
示例8: runVoid
void runVoid(CppiaCtx *ctx)
{
if (FUNC==afPop)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
thisVal->pop();
}
if (FUNC==afShift)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
thisVal->shift();
}
if (FUNC==af__set)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
int i = args[0]->runInt(ctx);
BCR_VCHECK;
ELEM elem;
thisVal->Item(i) = runValue(elem,ctx,args[1]);
}
if (FUNC==af__crement)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
int idx = args[0]->runInt(ctx);
BCR_VCHECK;
ELEM &elem = thisVal->Item(idx);
CREMENT::run(elem);
}
if (FUNC==afPush || FUNC==afRemove)
runInt(ctx);
if (FUNC==afConcat || FUNC==afCopy || FUNC==afReverse || FUNC==afSplice || FUNC==afSlice ||
FUNC==afMap || FUNC==afFilter)
runObject(ctx);
if (FUNC==afReverse)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
thisVal->reverse();
}
if (FUNC==afSort)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
hx::Object * func = args[0]->runObject(ctx);
BCR_VCHECK;
thisVal->sort(func);
}
if (FUNC==afInsert)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
int pos = args[0]->runInt(ctx);
BCR_VCHECK;
ELEM elem;
runValue(elem,ctx,args[1]);
BCR_VCHECK;
thisVal->insert(pos,elem);
}
if (FUNC==afUnshift)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_VCHECK;
ELEM elem;
runValue(elem,ctx,args[0]);
BCR_VCHECK;
thisVal->unshift(elem);
}
}
示例9: runValue
hx::Object *runObject(CppiaCtx *ctx)
{
if (FUNC==af__get)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int idx = args[0]->runInt(ctx);
BCR_CHECK;
return thisVal->__GetItem(idx).mPtr;
}
if (FUNC==af__set)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int i = args[0]->runInt(ctx);
BCR_CHECK;
ELEM elem;
thisVal->Item(i) = runValue(elem,ctx,args[1]);
return Dynamic(elem).mPtr;
}
if (FUNC==af__crement)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int idx = args[0]->runInt(ctx);
BCR_CHECK;
ELEM &elem = thisVal->Item(idx);
return Dynamic(CREMENT::run(elem)).mPtr;
}
if (FUNC==afPop)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return Dynamic(thisVal->pop()).mPtr;
}
if (FUNC==afShift)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return Dynamic(thisVal->shift()).mPtr;
}
if (FUNC==afConcat)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
Array_obj<ELEM> *inVal = (Array_obj<ELEM>*)args[0]->runObject(ctx);
BCR_CHECK;
return thisVal->concat(inVal).mPtr;
}
if (FUNC==afCopy)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return thisVal->copy().mPtr;
}
if (FUNC==afSplice)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int pos = args[0]->runInt(ctx);
BCR_CHECK;
int end = args[1]->runInt(ctx);
BCR_CHECK;
return thisVal->splice(pos,end).mPtr;
}
if (FUNC==afSlice)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int pos = args[0]->runInt(ctx);
BCR_CHECK;
hx::Object *end = args[1]->runObject(ctx);
BCR_CHECK;
return thisVal->slice(pos,end).mPtr;
}
if (FUNC==afMap)
{
// TODO - maybe make this more efficient
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
hx::Object *func = args[0]->runObject(ctx);
BCR_CHECK;
Array<ELEM> result = thisVal->map(func);
return result.mPtr;
}
if (FUNC==afFilter)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
hx::Object *func = args[0]->runObject(ctx);
BCR_CHECK;
return thisVal->filter(func).mPtr;
}
if (FUNC==afIterator)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
//.........这里部分代码省略.........
示例10: runInt
int runInt(CppiaCtx *ctx)
{
if (FUNC==afPush)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
ELEM elem;
runValue(elem,ctx,args[0]);
BCR_CHECK;
int result = thisVal->push(elem);
return result;
}
if (FUNC==afPop)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return ValToInt(thisVal->pop());
}
if (FUNC==afShift)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
return ValToInt(thisVal->shift());
}
if (FUNC==afRemove)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
ELEM elem;
runValue(elem,ctx,args[0]);
BCR_CHECK;
return thisVal->remove(elem);
}
if (FUNC==afIndexOf)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
ELEM elem;
runValue(elem,ctx,args[0]);
BCR_CHECK;
hx::Object *start = args[1]->runObject(ctx);
BCR_CHECK;
return thisVal->indexOf(elem,start);
}
if (FUNC==afLastIndexOf)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
ELEM elem;
runValue(elem,ctx,args[0]);
BCR_CHECK;
hx::Object *start = args[1]->runObject(ctx);
BCR_CHECK;
return thisVal->lastIndexOf(elem, start);
}
if (FUNC==af__get)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int idx = args[0]->runInt(ctx);
BCR_CHECK;
return ValToInt(thisVal->__get(idx));
}
if (FUNC==af__set)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int i = args[0]->runInt(ctx);
BCR_CHECK;
ELEM elem;
runValue(elem,ctx,args[1]);
BCR_CHECK;
thisVal->Item(i) = elem;
return ValToInt(elem);
}
if (FUNC==af__crement)
{
Array_obj<ELEM> *thisVal = (Array_obj<ELEM>*)thisExpr->runObject(ctx);
BCR_CHECK;
int idx = args[0]->runInt(ctx);
BCR_CHECK;
ELEM &elem = thisVal->Item(idx);
return ValToInt(CREMENT::run(elem));
}
return 0;
}