示例#1
0
/**
 * TJSオブジェクト用のプロパティセッター
 * @param args 引数
 * @return 結果
 */
void
TJSInstance::tjsSetter(Local<String> property, Local<Value> value, const PropertyCallbackInfo<void>& info)
{
	Isolate *isolate = info.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant instance;
	tTJSVariant method;
	if (getVariant(isolate, instance, info.This()) && getVariant(isolate, method, info.Data()->ToObject())) {
		PropSetter set(instance, method, value, info);
		set.exec();
	}
}
示例#2
0
/**
 * TJSオブジェクト用のメソッド
 * @param args 引数
 * @return 結果
 */
void
TJSInstance::tjsInvoker(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant instance;
	tTJSVariant method;
	if (getVariant(isolate, instance, args.This()) && getVariant(isolate, method, args.Data()->ToObject())) {
		FuncInfo info(instance, method, args);
		args.GetReturnValue().Set(info.exec());
		return;
	}
	args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#3
0
/**
 * TJSオブジェクト用のプロパティゲッター
 * @param args 引数
 */
void
TJSInstance::tjsGetter(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
	Isolate *isolate = info.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant instance;
	tTJSVariant method;
	if (getVariant(isolate, instance, info.This()) && getVariant(isolate, method, info.Data()->ToObject())) {
		PropGetter get(instance, method, info);
		info.GetReturnValue().Set(get.exec());
		return;
	}
	info.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#4
0
QVariant Text::getProperty(P_ID propertyId) const
      {
      Property<Text>* p = property(propertyId);
      if (p)
            return getVariant(propertyId, ((*(Text*)this).*(p->data))());
      return Element::getProperty(propertyId);
      }
示例#5
0
/**
 * TJSオブジェクトのオーバライド処理
 * @param args 引数
 * @return 結果
 */
void
TJSInstance::tjsOverride(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant instance;
	if (getVariant(isolate, instance, args.This())) {
		if (args.Length() > 0) {
			Local<Value> func = args.Length() > 1 ? args[1] : args.This()->Get(args[0]);
			if (func->IsFunction()) {
				tTJSVariant value = toVariant(isolate, func->ToObject(), args.This());
				String::Value methodName(args[0]);
				tjs_error error;
				if (TJS_FAILED(error = instance.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, *methodName, NULL, &value, NULL))) {
					args.GetReturnValue().Set(ERROR_KRKR(isolate, error));
					return;
				}
				args.GetReturnValue().Set(Undefined(isolate));
				return;
			}
		}
		args.GetReturnValue().Set(isolate->ThrowException(String::NewFromUtf8(isolate, "not function")));
		return;
	}
	args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
//------------------------------------------------------------------------------
void SN_API getArray(HSQUIRRELVM vm, Variant & out_v, SQInteger index)
{
	out_v.setArray();
	Variant::Array & a = out_v.getArray();

	SQInteger len = sq_getsize(vm, index);
	SN_ASSERT(len >= 0, "Invalid array size");
	
	if (len > 0)
	{
		a.resize(len);
		s32 i = 0;

		sq_push(vm, index);
		sq_pushnull(vm);

		while (SQ_SUCCEEDED(sq_next(vm, -2)))
		{
			// -1 is the value and -2 is the key

			sq_getinteger(vm, -2, &i);
			Variant & val = a[i];
			getVariant(vm, val, -1);

			sq_pop(vm, 2); //pops key and val before the next iteration
		}

		sq_pop(vm, 2); // Pop the null iterator and array
	}
}
示例#7
0
QVariant Box::getProperty(P_ID propertyId) const
{
    Property<Box>* p = property(propertyId);
    if (p)
        return getVariant(propertyId, ((*(Box*)this).*(p->data))());
    return Element::getProperty(propertyId);
}
//------------------------------------------------------------------------------
void SN_API getTable(HSQUIRRELVM vm, Variant & out_v, SQInteger index)
{
	out_v.setDictionary();
	Variant::Dictionary & d = out_v.getDictionary();

	sq_push(vm, index);
	sq_pushnull(vm);

	while (SQ_SUCCEEDED(sq_next(vm, -2)))
	{
		if (sq_gettype(vm, -2) == OT_STRING)
		{
			const SQChar * key = nullptr;
			sq_getstring(vm, -2, &key);
			Variant & val = d[key];
			getVariant(vm, val, -1);
		}
		else
		{
			SN_WARNING("non-string keys in tables are not supported by getVariant");
		}

		sq_pop(vm, 2);
	}

	sq_pop(vm, 2); // Pop iterator and table
}
示例#9
0
Variant * VariantCollection::getVariant
(
    int const index
)
    const
{
    return getVariant( clusters.value( index ) );
}
示例#10
0
void VariantCollection::toggleReference
(
    int const index
)
{
    if ( getVariant( index )->isReference() )
    {
        getVariant( index )->setReference( false );
    }
    else
    {
        foreach ( FileCluster * cluster, clusters )
        {
            getVariant( cluster )->setReference( false );
        }

        getVariant( index )->setReference( true );
    }
示例#11
0
/**
 * TJSオブジェクト用のプロパティセッター
 * 引数1 オブジェクト
 * 引数2 設定値
 * 自由変数1 プロパティ
 */
SQRESULT
TJSObject::tjsSetter(HSQUIRRELVM v)
{
    tTJSVariant instance;
    if (getVariant(v,1,&instance) && instance.Type() == tvtObject) {
        FuncInfo info(v, instance);
        return info.setter();
    }
    return ERROR_BADINSTANCE(v);
}
示例#12
0
void Box::write(Xml& xml) const
{
    xml.stag(name());

    for (int i = 0;; ++i) {
        const Property<Box>& p = propertyList[i];
        P_ID id = p.id;
        if (id == P_END)
            break;
        QVariant val        = getVariant(id, ((*(Box*)this).*(p.data))());
        QVariant defaultVal = getVariant(id, p.defaultVal);
        if (val != defaultVal)
            xml.tag(propertyName(id), val);
    }

    Element::writeProperties(xml);
    foreach (const Element* el, _el)
        el->write(xml);
    xml.etag();
}
示例#13
0
/**
 * TJSオブジェクトの有効確認
 * @param args 引数
 * @return 結果
 */
void
TJSInstance::tjsIsValid(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant instance;
	if (getVariant(isolate, instance, args.This())) {
		args.GetReturnValue().Set(Boolean::New(isolate, instance.AsObjectClosureNoAddRef().IsValid(0, NULL, NULL, NULL) == TJS_S_TRUE));
		return;
	}
	args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#14
0
/**
 * TJSオブジェクトの有効確認
 * 引数1 オブジェクト
 */
SQRESULT
TJSObject::tjsIsValid(HSQUIRRELVM v)
{
    tTJSVariant instance;
    if (getVariant(v,1,&instance) && instance.Type() == tvtObject) {
        SQBool ret = instance.AsObjectClosureNoAddRef().IsValid(0, NULL, NULL, NULL) == TJS_S_TRUE ? SQTrue : SQFalse;
        sq_pushbool(v, ret);
        return 1;
    }
    sq_pushbool(v, SQFalse);
    return 1;
}
示例#15
0
/**
 * TJSオブジェクトのコンストラクタ
 */
void
TJSInstance::tjsConstructor(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant classObj;
	if (getVariant(isolate, classObj, args.Data()->ToObject())) {
		CreateInfo info(classObj, args);
		args.GetReturnValue().Set(info.create());
		return;
	}
	args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#16
0
// メソッドの呼び出し
void
TJSObject::caller(const FunctionCallbackInfo<Value>& args)
{
	Isolate *isolate = args.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant self;
	if (getVariant(isolate, self, args.This())) {
		Local<Value> ret;
		
		// 引数変換
		tjs_int argc = args.Length();
		tTJSVariant **argv = new tTJSVariant*[argc];
		for (tjs_int i=0;i<argc;i++) {
			argv[i] = new tTJSVariant();
			*argv[i] = toVariant(isolate, args[i]);
		}

		if (self.AsObjectClosureNoAddRef().IsInstanceOf(0, NULL, NULL, L"Class", NULL) == TJS_S_TRUE) {
			// クラスオブジェクトならコンストラクタ呼び出し
			iTJSDispatch2 *instance = NULL;
			tjs_error error;
			if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().CreateNew(0, NULL, NULL, &instance, argc, argv, NULL))) {
				ret = toJSValue(isolate, tTJSVariant(instance, instance));
				instance->Release();
			} else {
				ret = ERROR_KRKR(isolate, error);
			}
		} else {
			// メソッド呼び出し
			tTJSVariant result;
			tjs_error error;
			if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().FuncCall(0, NULL, NULL, &result, argc, argv, NULL))) {
				ret = toJSValue(isolate, result);
			} else {
				ret = ERROR_KRKR(isolate, error);
			}
		}

		// 引数解放
		if (argv) {
			for (int i=0;i<argc;i++) {
				delete argv[i];
			}
			delete[] argv;
		}
		
		args.GetReturnValue().Set(ret);
		return;
	}
	args.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#17
0
/**
 * TJSオブジェクトのオーバライド処理
 * 引数1 オブジェクト
 * 引数2 名前
 * 引数3 値。省略時は squirrel インスタンスから名前で参照
 */
SQRESULT
TJSObject::tjsOverride(HSQUIRRELVM v)
{
    SQRESULT result;
    tTJSVariant instance;
    if (getVariant(v,1,&instance) && instance.Type() == tvtObject) {
        tTJSVariant value;
        const SQChar *methodName = sqobject::getString(v,2);
        int n = sq_gettop(v);
        if (n >= 3) {
            // 引数で明示指定されている
            if (SQ_FAILED(result = sq_getvariant(v, 3, &value))) {
                return result;
            }
        } else {
            // 自己オブジェクトから名前で検索して登録
            sq_push(v, 1);
            sq_pushstring(v, methodName, -1);
            if (SQ_FAILED(result = sq_get(v, -2))) {
                sq_pop(v, 1); //self
                return result;
            } else {
                SQObjectType type = sq_gettype(v, -1);
                if (type == OT_CLOSURE || type == OT_NATIVECLOSURE) {
                    // クロージャの場合は bindenv しておく
                    sq_push(v, 1);
                    if (SQ_FAILED(result = sq_bindenv(v, -2))) {
                        sq_pop(v, 2); // func, self
                        return result;
                    } else {
                        sq_remove(v, -2); // original func
                    }
                }
                if (SQ_FAILED(result = sq_getvariant(v, -1, &value))) { // value
                    sq_pop(v, 1); //self
                    return result;
                }
                sq_pop(v, 1); // self
            }
        }
        tjs_error error;
        if (TJS_SUCCEEDED(error = instance.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, methodName, NULL, &value, NULL))) {
            return SQ_OK;
        } else {
            return  ERROR_KRKR(v, error);
        }
    }
    return ERROR_BADINSTANCE(v);
}
示例#18
0
// メソッドの呼び出し
Handle<Value>
TJSObject::caller(const Arguments& args)
{
	tTJSVariant self;
	if (getVariant(self, args.This())) {
		Handle<Value> ret;
		
		// 引数変換
		tjs_int argc = args.Length();
		tTJSVariant **argv = new tTJSVariant*[argc];
		for (tjs_int i=0;i<argc;i++) {
			argv[i] = new tTJSVariant();
			*argv[i] = toVariant(args[i]);
		}

		if (self.AsObjectClosureNoAddRef().IsInstanceOf(0, NULL, NULL, L"Class", NULL) == TJS_S_TRUE) {
			// クラスオブジェクトならコンストラクタ呼び出し
			iTJSDispatch2 *instance = NULL;
			tjs_error error;
			if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().CreateNew(0, NULL, NULL, &instance, argc, argv, NULL))) {
				ret = toJSValue(tTJSVariant(instance, instance));
				instance->Release();
			} else {
				ret = ERROR_KRKR(error);
			}
		} else {
			// メソッド呼び出し
			tTJSVariant result;
			tjs_error error;
			if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().FuncCall(0, NULL, NULL, &result, argc, argv, NULL))) {
				ret = toJSValue(result);
			} else {
				ret = ERROR_KRKR(error);
			}
		}

		// 引数解放
		if (argv) {
			for (int i=0;i<argc;i++) {
				delete argv[i];
			}
			delete[] argv;
		}
		
		return ret;
	}
	return ERROR_BADINSTANCE();
}
示例#19
0
// プロパティの設定
Handle<Value>
TJSObject::setter(Local<String> property, Local<Value> value, const AccessorInfo& info)
{
	tTJSVariant self;
	if (getVariant(self, info.This())) {
		String::Value propName(property);
		tTJSVariant param = toVariant(value);
		tjs_error error;
		if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, *propName, NULL, &param, NULL))) {
			return Undefined();
		} else {
			return ERROR_KRKR(error);
		}
	}
	return ERROR_BADINSTANCE();
}
示例#20
0
// プロパティの設定
void
TJSObject::setter(Local<String> property, Local<Value> value, const PropertyCallbackInfo<Value>& info)
{
	Isolate *isolate = info.GetIsolate();
	HandleScope handle_scope(isolate);
	tTJSVariant self;
	if (getVariant(isolate, self, info.This())) {
		String::Value propName(property);
		tTJSVariant param = toVariant(isolate, value);
		tjs_error error;
		if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropSet(TJS_MEMBERENSURE, *propName, NULL, &param, NULL))) {
		} else {
			info.GetReturnValue().Set(ERROR_KRKR(isolate, error));
		}
		return;
	}
	info.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
示例#21
0
// プロパティの取得
Handle<Value>
TJSObject::getter(Local<String> property, const AccessorInfo& info)
{
	String::Value propName(property);
	if (wcscmp(*propName, TJSINSTANCENAME) == 0) {
		return Handle<Value>();
	}
	tTJSVariant self;
	if (getVariant(self, info.This())) {
		tjs_error error;
		tTJSVariant result;
		if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropGet(0, *propName, NULL, &result, NULL))) {
			return toJSValue(result);
		} else {
			return ERROR_KRKR(error);
		}
	}
	return ERROR_BADINSTANCE();
}
void CDStarRepeaterConfigDVMegaSet::onVariant(wxCommandEvent &event)
{
	DVMEGA_VARIANT variant = getVariant();

	switch (variant) {
		case DVMV_RADIO_2M:
		case DVMV_RADIO_70CM:
		case DVMV_RADIO_2M_70CM:
			m_txInvert->Disable();
			m_rxInvert->Disable();
			m_frequency->Enable();
			m_power->Enable();
			break;
		default:	// DVMV_MODEM
			m_txInvert->Enable();
			m_rxInvert->Enable();
			m_frequency->Disable();
			m_power->Disable();
			break;
	}
}
示例#23
0
		void setUp (void) {
			m = new Memory(120000);
			r = new RegisterSet;
			r->addDefaultRegisters();
			v = getVariant("msp430x16x");
			intManager = new InterruptManager(r, m, v);
			factory = new DummyTimerFactory();
			pinManager = new PinManager(m, intManager, v);

			PinMultiplexer *mpx = pinManager->addPin(P1, 0);

			{
				PinMultiplexer::Condition c;
				c["sel"] = 1;
				mpx->addMultiplexing(c, "SOMI0");
			}

			mpx = pinManager->addPin(P1, 4);

			{
				PinMultiplexer::Condition c;
				c["sel"] = 1;
				mpx->addMultiplexing(c, "SIMO0");
			}

			mpx = pinManager->addPin(P1, 5);

			{
				PinMultiplexer::Condition c;
				c["sel"] = 1;
				mpx->addMultiplexing(c, "UCLK0");
			}
			
			bc = new BasicClock(m, v, intManager, pinManager, factory);
			watcher = new DummyPinWatcher2();
			pinManager->setWatcher(watcher);

			usart = new USART(pinManager, intManager, m, v, 0, bc->getACLK(), bc->getSMCLK());
		}
示例#24
0
// プロパティの取得
void
TJSObject::getter(Local<String> property, const PropertyCallbackInfo<Value>& info)
{
	Isolate *isolate = info.GetIsolate();
	HandleScope handle_scope(isolate);
	String::Value propName(property);
	if (wcscmp(*propName, TJSINSTANCENAME) == 0) {
		return;
	}
	tTJSVariant self;
	if (getVariant(isolate, self, info.This())) {
		tjs_error error;
		tTJSVariant result;
		if (TJS_SUCCEEDED(error = self.AsObjectClosureNoAddRef().PropGet(0, *propName, NULL, &result, NULL))) {
			info.GetReturnValue().Set(toJSValue(isolate, result));
		} else {
			info.GetReturnValue().Set(ERROR_KRKR(isolate, error));
		}
		return;
	}
	info.GetReturnValue().Set(ERROR_BADINSTANCE(isolate));
}
unsigned int CDStarRepeaterConfigDVMegaSet::getTXFrequency() const
{
        DVMEGA_VARIANT variant = getVariant();
	wxString hz = m_frequency->GetValue();

	int pos = hz.Find(wxT('/'));
	if (pos != wxNOT_FOUND && variant == DVMV_RADIO_2M_70CM) {
            unsigned long frequency;
            hz.Mid(pos + 1).ToULong(&frequency);
            return frequency;
        } else {
            if (pos != wxNOT_FOUND) {
                unsigned long frequency;
                hz.Left(pos).ToULong(&frequency);
                return frequency;
            } else {
	        unsigned long frequency;
	        hz.ToULong(&frequency);
	        return frequency;
            }
        }
}
示例#26
0
 QStringList StringListSettingsItem::get() const {
   return getVariant().toStringList();
 }
示例#27
0
QVariant Box::propertyDefault(P_ID id) const
{
    return getVariant(id, property(id)->defaultVal);
}
示例#28
0
int Event::apply( eagle::model::Contig& contigOut,
                  const EventIterator& lastPosition,
                  const ReferenceBounds& reference,
                  const eagle::model::Direction direction)
{
    EAGLE_DEBUG(8,"... [processing] " << getStructuralVariant() );
    EAGLE_DEBUG(8,"from " << lastPosition->getStructuralVariant() );
    EAGLE_DEBUG(8,"in direction " << direction.str() );

    // cached contig
    static std::string lastContigId("");
    static ReferenceIterator contig;
    if (lastContigId != src())
    {
        lastContigId = src();
        contig = std::find( reference.first, reference.second, eagle::model::Contig(lastContigId) );
        if (contig == reference.second)
        {
            std::cerr << "ERROR: contig " << lastContigId << " not found!" << std::endl;
            std::cerr << "List of known contigs:" << std::endl;
            for (eagle::genome::ReferenceIterator contig=reference.first; contig != reference.second; ++contig)
            {
                std::cerr << "    " << contig->name() << " (id=" << contig->id() << ")" << std::endl;
            }
        }
    }

    if ( (lastPosition->outgoing().defined() && incoming().defined() && !lastPosition->outgoing().sameAs(incoming()))
    ||  lastPosition->dest() != src() )
    {
        std::stringstream message;
        message << std::endl;
        message << "*** Could not produce a valid DNA segment going from:" << std::endl;
        message << "***       " << lastPosition->getVariant() << std::endl;
        message << "*** To:" << std::endl;
        message << "***       " << getVariant() << std::endl;
        EAGLE_ERROR( message.str() );
    }
    long pos1 = lastPosition->from(direction) + direction.offset();
    long pos2 = to(direction.inv());
    if (0 == pos1) {assert(0 == pos2);}  // only fake event allowed at position 0, until we implement support for telomeres
    std::vector<char> segment = contig->read(pos1,pos2);
    EAGLE_DEBUG(8, "[assign] " << segment.size() << " bases" );
    EAGLE_DEBUG(8, "[assign] " << std::string(segment.begin(), segment.end()).substr(0,100) << (segment.size()>100?"...":"")  ); // Prints max 100 bases
    unsigned long basesCount = contigOut.append( segment, direction.isRev() );
    EAGLE_DEBUG(5,"Copied " << basesCount << " bases");
    if (segment.size() != basesCount)
    {
        EAGLE_WARNING( (boost::format("Only %lu bases copied (%lu expected) while processing:") % basesCount % segment.size()).str() );
        EAGLE_WARNING_CONT( "         " << this->getStructuralVariant() );
        EAGLE_WARNING_CONT( "   from: " );
        EAGLE_WARNING_CONT( "         " << lastPosition->getStructuralVariant() );
    }

    if (!getVariant().sequence.empty())
    {
        // we only need to rev-compl the BiDir events, as everything else has been rev-compl at loading time
        basesCount += contigOut.append( getVariant().sequence, direction.isRev() && getVariant().adjacency.first.dir.isBiDir() );
        EAGLE_DEBUG(10,"+ " << getVariant().sequence.size() << " bases from ALT field (" << std::string( getVariant().sequence.begin(), getVariant().sequence.end() ) << ")");
    }

    // Update metadata DEST field with the current position on the allele as it was before adding inserted bases
    long positionBeforeInsertion = contigOut.size() - getVariant().sequence.size() + (type==model::variant::SNP?1:0);
    metadata_.addInfoValue( "DEST", (boost::format("%s:%d") % contigOut.id() % positionBeforeInsertion).str() );

    return basesCount;
}