コード例 #1
0
ファイル: TowerScene.cpp プロジェクト: binarybird/OpenTower
void Tower::onMouseMove(cocos2d::Event* _event)
{

	if(_isClosing == true || _returnFromSave == true)
    {
        _returnFromSave = false;
        return;// if we are pressing the close button, we dont want to build things!
    }

	EventMouse* e = (EventMouse*)_event;

	if(_isMovingToolPanal == true)
	{
		Vec2 tPP = _toolPanalLayer->getPosition();
		float mPPY = e->getCursorY();
		float mPPX = e->getCursorX();
		mPPY=mPPY+_mouseYOffset;

		_toolPanalLayer->setPosition(Vec2(mPPX-_windowOffsetX,mPPY-_windowOffsetY));
	}

	if(_isBuildingFloor == true)
	{
		float mPPY = e->getCursorY()+_mouseYOffset;
		float mPPX = e->getCursorX();
		createStructure(Vec2(mPPX,mPPY));
	}

    _mouseLayer->setPosition(e->getCursorX()-_currentStructureSize.width/2, _mouseYOffset + e->getCursorY() - _currentStructureSize.height/2);
}
コード例 #2
0
void NeuronFactory::createFeedForwardNetStrucuture(NetworkParams& params)
{
	params.structure.resize(0);
	string s="";
	string& nS = Parameters::neuronsMatrix;
	bool b = true;
	unsigned int sPos=0;
	unsigned int ePos=0;
	int ind = 0;
	while(b)
	{
		ePos = nS.find_first_of(',',sPos);
		if(ePos < 0 || ePos > nS.length() - 1)
		{
			ePos = nS.length() ;
			b = false;
		}
		s = nS.substr(sPos,ePos-sPos);
		params.structure.push_back(atoi(s.data()));
		ind++;
		sPos = ePos+1;
	}

	createStructure(params);
}
コード例 #3
0
PVStructurePtr NTTableBuilder::createPVStructure()
{
    size_t len = labels.size();
    shared_vector<string> l(len);
    for(size_t i=0; i<len; ++i) l[i] = labels[i];
    PVStructurePtr s = getPVDataCreate()->createPVStructure(createStructure());
    s->getSubField<PVStringArray>("labels")->replace(freeze(l));
    return s;
}
コード例 #4
0
void NeuronFactory::createTreeLayerNetStrucuture(NetworkParams& params)
{
	params.structure.resize(3);//input, interm and output neurons 
	params.structure[0] = Parameters::ALL_SPACE_DIM;
	params.structure[1] = Parameters::START_INTERM_NEURON_NUM;//create only one intermediate neuron
	params.structure[2] = Parameters::OUTPUT_NUM;

	createStructure(params);
}
コード例 #5
0
Database::Database()
{
    m_Connection = QSqlDatabase::addDatabase("QSQLITE");
    m_Connection.setDatabaseName("database.db");
    if (!m_Connection.open()) {
        qDebug() << "Can't open database";
    }
    createStructure();
}
コード例 #6
0
void ChannelsFavoritesDatabaseManager::checkStructure()
{
    if (!db.isOpen())
        return;

    if (!db.tables().contains(_channelsFavoriteTableName)) {
        createStructure();
    }
}
コード例 #7
0
void ComicDatabaseResource::checkStructure()
{
    if (!db.isOpen())
        return;

    if (!db.tables().contains(_comicsTableName)) {
        createStructure();
    }
}
コード例 #8
0
JSNPObject::JSNPObject(JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
    : JSObjectWithGlobalObject(globalObject, createStructure(globalObject->objectPrototype()))
    , m_objectMap(objectMap)
    , m_npObject(npObject)
{
    // We should never have an NPJSObject inside a JSNPObject.
    ASSERT(!NPJSObject::isNPJSObject(m_npObject));

    retainNPObject(m_npObject);
}
コード例 #9
0
ファイル: Constructors.cpp プロジェクト: karelklic/canal
Domain *
Constructors::create(const llvm::Type &type) const
{
    CANAL_ASSERT_MSG(!type.isVoidTy(), "Cannot create value of type Void.");

    if (type.isIntegerTy())
    {
        llvm::IntegerType &integerType = checkedCast<llvm::IntegerType>(type);
        return createInteger(integerType.getBitWidth());
    }

    if (type.isFloatingPointTy())
    {
        const llvm::fltSemantics &semantics =
            Float::Utils::getSemantics(type);

        return createFloat(semantics);
    }

    if (type.isPointerTy())
    {
        const llvm::PointerType &pointerType =
            checkedCast<llvm::PointerType>(type);

        return createPointer(pointerType);
    }

    if (type.isArrayTy() || type.isVectorTy())
    {
        const llvm::SequentialType &stype =
            checkedCast<llvm::SequentialType>(type);

        return createArray(stype);
    }

    if (type.isStructTy())
    {
        const llvm::StructType &structType =
            checkedCast<llvm::StructType>(type);

        std::vector<Domain*> members;
        for (unsigned i = 0; i < structType.getNumElements(); i ++)
            members.push_back(create(*structType.getElementType(i)));

        return createStructure(structType, members);
    }

    CANAL_DIE_MSG("Unsupported llvm::Type::TypeID: " << type.getTypeID());
}
コード例 #10
0
void NeuronFactory::createJordanNetworkStrucuture(NetworkParams& params)
{
	params.structure.resize(3);
	params.structure[0] = Parameters::ALL_SPACE_DIM*(Parameters::INPUT_DELAY_NUM+1) + Parameters::JOINT_NUM*Parameters::BACK_FROM_OUTPUT_DELAY_NUM;
	params.structure[1] = Parameters::START_INTERM_NEURON_NUM;
	params.structure[2] = Parameters::JOINT_NUM;

	createStructure(params);

	int startOutId = params.structure[0] + params.structure[1] - 1;
	vector<int> ids(0);
	ids.push_back(startOutId);
	int id = Parameters::ALL_SPACE_DIM*(Parameters::INPUT_DELAY_NUM+1);

	for(int i=0; i < Parameters::JOINT_NUM; ++i)
	{
		for(int j=0; j < Parameters::BACK_FROM_OUTPUT_DELAY_NUM; ++j)
		{
			params.connections[id] = ids;
			++id;
		}
		++ids[0];
	}
}
コード例 #11
0
Structure* ClonedArguments::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
    // We use contiguous storage because optimizations in the FTL assume that cloned arguments creation always produces the same initial structure.
    return createStructure(vm, globalObject, prototype, NonArrayWithContiguous);
}
コード例 #12
0
PVStructurePtr NTScalarBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #13
0
PVStructurePtr NTMatrixBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #14
0
PVStructurePtr NTNameValueBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #15
0
BDK::Decoder::Decoder(ifstream *ptr_ifstream)
{
	unsigned short soc = 0;
	this->ptr_ifstream = ptr_ifstream;
	unsigned short MARK;
	int length = 200000, new_read_nr;
	streamsize read_nr;
	unsigned char *ptr_soc = new unsigned char[length];
	unsigned char *ptr_qcd_input;
	unsigned int tile;
	unsigned int codestream_length = 0;
	//unsigned long stream_pos;

	COD_read = false;
	QCD_need_to_create = false;

	decoder_state state = decoder_main;

	read_nr = 42;
	(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
	if((*this->ptr_ifstream).eof() == true){
		throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
	}
	

	soc |= ptr_soc[0];
	soc <<= 8;
	soc |= ptr_soc[1];

	if(soc != SOC){
		throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "No *.jpc file " );
	}

	ptr_SIZ_part_one = new SIZ_part_one(ptr_soc);
	read_nr = ptr_SIZ_part_one->Csiz * 3;
	if(read_nr > length){
		ptr_soc = (unsigned char*)realloc(ptr_soc, read_nr);
		length	= read_nr; 
	}
	(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
	if((*this->ptr_ifstream).eof() == true){
		throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
	}
	ptr_SIZ_part_one->set_SIZ_part_two(ptr_soc);

	createStructure();

	read_nr = 2;
	(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
	if((*this->ptr_ifstream).eof() == true){
		throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
	}
	MARK = ptr_soc[0];
	MARK <<= 8;
	MARK |= ptr_soc[1];	
	do{
		switch(MARK){
			case COD:
				read_nr = 2;
				(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
				}
				new_read_nr = ptr_soc[0];
				new_read_nr <<= 8;
				new_read_nr |= ptr_soc[1];	
				if(new_read_nr > length){
					ptr_soc = (unsigned char*)realloc(ptr_soc, new_read_nr);
					length	= new_read_nr;
				}
				read_nr = new_read_nr - 2;
				(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
				}
				if(state == decoder_main){
					set_COD(new Coding_style_default_COD(ptr_soc, read_nr + 2, main_header));
					
				}else if(state == decoder_tile){
					tiles[tile]->set_COD(new Coding_style_default_COD(ptr_soc, read_nr + 2, main_header));
					codestream_length -= (tiles[tile]->ptr_COD->Lcox + 2);
					tiles[tile]->COD_read	= true;		
				}
				break;
			case QCD:
				read_nr = 2;
				(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__,"Unexpected EOF");
				}
				new_read_nr = bytetoshort( ptr_soc, 0);
				read_nr = new_read_nr - 2;
				ptr_qcd_input = (unsigned char*) new unsigned char[read_nr];
				if(ptr_qcd_input == NULL){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "NO MEMORY");
				}
				(*this->ptr_ifstream).read((char*)ptr_qcd_input, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Unexpected EOF");
				}
				if(state == decoder_main){
					if(COD_read == true){
						set_QCD( new Quantization_default_QCD(ptr_qcd_input, read_nr + 2, ptr_COD));
					}else{
						throw new Default_Exceptionhandler(__FILE__, __LINE__, "Not yet implement");
					}
				}else if(state == decoder_tile){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Not yet implement");
				}

				break;
			case COM:
				read_nr = 2;
				(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__,"Unexpected EOF");
				}
				new_read_nr = bytetoshort( ptr_soc, 0);
				read_nr = new_read_nr - 2;
				if(read_nr > length){
					ptr_soc = (unsigned char*)realloc(ptr_soc, new_read_nr);
					length	= read_nr;
				}
				(*this->ptr_ifstream).read((char*)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Unexpected EOF");
				}
				ptr_COM = new Comment(new_read_nr, ptr_soc);
				break;
			case SOT:
				read_nr = 2;
				(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__,"Unexpected EOF");
				}
				new_read_nr = bytetoshort( ptr_soc, 0);
				read_nr = new_read_nr - 2;
				if(read_nr > length){
					ptr_soc = (unsigned char*)realloc(ptr_soc, new_read_nr);
					length	= read_nr;
				}
				(*this->ptr_ifstream).read((char*)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Unexpected EOF");
				}				
				tile = Start_of_tile_part_SOT::get_Isot(ptr_soc);
				if(tiles.size() <= tile){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Wrong Isot");
				}
				tiles[tile]->set_Tilepart(read_nr + 2 , ptr_soc);
				codestream_length = Start_of_tile_part_SOT::get_Psot(ptr_soc);
				codestream_length -= 12;
				state = decoder_tile;
				break;
			case SOD:
				read_nr = codestream_length - 2;
				if(read_nr > length){
					ptr_soc = (unsigned char*)realloc(ptr_soc, read_nr);
					length	= read_nr;
				}
				
				(*this->ptr_ifstream).read((char*)ptr_soc, read_nr);
				if((*this->ptr_ifstream).eof() == true){
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "Unexpected EOF");
				}				
				if(state == decoder_tile){
					ByteBuffer *bytebuffer = new ByteBuffer(ptr_soc, read_nr);
					tiles[tile]->set_Codestream(read_nr, ptr_soc, bytebuffer);
					codestream_length = 0;
					state = decoder_main;
				}else{
					throw new Default_Exceptionhandler(__FILE__, __LINE__, "SOD without SOT");
				}
				break;
		}


		read_nr = 2;
		(*this->ptr_ifstream).read((char *)ptr_soc, read_nr);
		if(((*this->ptr_ifstream).eof() == true) && (this->ptr_ifstream->gcount() != read_nr)){
			throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unexpected EOF" );
		}

		MARK = ptr_soc[0];
		MARK <<= 8;
		MARK |= ptr_soc[1];	


		if(!is_known_mark(MARK)){
			throw new Default_Exceptionhandler(__FILE__ , __LINE__ , "Unknown Mark", MARK );
		}
	}while((*this->ptr_ifstream).eof() != true && MARK != EOC);
	
	inverse_quantization_irreversible();
	start_Filter97_decoder();

	delete[] ptr_soc;
}
コード例 #16
0
PVStructurePtr NTMultiChannelBuilder::createPVStructure()
{
    return pvDataCreate->createPVStructure(createStructure());
}
コード例 #17
0
PVStructurePtr NTAttributeBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #18
0
PVStructurePtr NTNDArrayBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #19
0
Structure* ClonedArguments::createSlowPutStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
    return createStructure(vm, globalObject, prototype, NonArrayWithSlowPutArrayStorage);
}
コード例 #20
0
PVStructurePtr NTHistogramBuilder::createPVStructure()
{
    return getPVDataCreate()->createPVStructure(createStructure());
}
コード例 #21
0
ファイル: JSNPMethod.cpp プロジェクト: mcgrawp/webkit-webcl
JSNPMethod::JSNPMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, NPIdentifier npIdentifier)
    : InternalFunction(&exec->globalData(), globalObject, createStructure(globalObject->functionPrototype()), name)
    , m_npIdentifier(npIdentifier)
{
}
コード例 #22
0
ファイル: Constructors.cpp プロジェクト: karelklic/canal
Domain *
Constructors::create(const llvm::Constant &value,
                     const llvm::Value &place,
                     const State *state) const
{
    if (llvm::isa<llvm::UndefValue>(value))
        return create(*value.getType());

    if (llvm::isa<llvm::ConstantInt>(value))
    {
        const llvm::ConstantInt &intValue =
            checkedCast<llvm::ConstantInt>(value);

        const llvm::APInt &i = intValue.getValue();
        return createInteger(i);
    }

    if (llvm::isa<llvm::ConstantPointerNull>(value))
    {
        const llvm::ConstantPointerNull &nullValue =
            checkedCast<llvm::ConstantPointerNull>(value);

        const llvm::PointerType &pointerType = *nullValue.getType();
        Domain *constPointer = createPointer(pointerType);
        constPointer->setZero(&place);
        return constPointer;
    }

    if (llvm::isa<llvm::ConstantExpr>(value))
    {
        const llvm::ConstantExpr &exprValue =
            checkedCast<llvm::ConstantExpr>(value);

        return createConstantExpr(exprValue, place, state);
    }

    if (llvm::isa<llvm::ConstantFP>(value))
    {
        const llvm::ConstantFP &fp = checkedCast<llvm::ConstantFP>(value);
        const llvm::APFloat &number = fp.getValueAPF();
        return createFloat(number);
    }

    if (llvm::isa<llvm::ConstantStruct>(value))
    {
        const llvm::ConstantStruct &structValue =
            checkedCast<llvm::ConstantStruct>(value);

        uint64_t elementCount = structValue.getType()->getNumElements();
        std::vector<Domain*> members;
        for (uint64_t i = 0; i < elementCount; ++i)
        {
            members.push_back(create(*structValue.getOperand(i),
                                     *structValue.getOperand(i),
                                     state));
        }

        return createStructure(*structValue.getType(), members);
    }

    if (llvm::isa<llvm::ConstantVector>(value))
    {
        const llvm::ConstantVector &vectorValue =
            checkedCast<llvm::ConstantVector>(value);

        // VectorType::getNumElements returns unsigned int.
        unsigned elementCount = vectorValue.getType()->getNumElements();
        std::vector<Domain*> values;
        for (unsigned i = 0; i < elementCount; ++i)
        {
            values.push_back(create(*vectorValue.getOperand(i),
                                    *vectorValue.getOperand(i),
                                    state));
        }

        return createArray(*vectorValue.getType(), values);
    }

    if (llvm::isa<llvm::ConstantArray>(value))
    {
        const llvm::ConstantArray &arrayValue =
            checkedCast<llvm::ConstantArray>(value);

        // ArrayType::getNumElements returns uint64_t.
        uint64_t elementCount = arrayValue.getType()->getNumElements();
        std::vector<Domain*> values;
        for (uint64_t i = 0; i < elementCount; ++i)
        {
            values.push_back(create(*arrayValue.getOperand(i),
                                    *arrayValue.getOperand(i),
                                    state));
        }

        return createArray(*arrayValue.getType(), values);
    }

#if (LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 1) || LLVM_VERSION_MAJOR > 3
    // llvm::isa<llvm::ConstantDataSequential> returns false for an
    // llvm::ConstantDataArray/Vector instance at least on on LLVM
    // 3.1.
    if (llvm::isa<llvm::ConstantDataVector>(value) ||
        llvm::isa<llvm::ConstantDataArray>(value))
    {
         const llvm::ConstantDataSequential &sequentialValue =
            checkedCast<llvm::ConstantDataSequential>(value);

        unsigned elementCount = sequentialValue.getNumElements();
        std::vector<Domain*> values;
        for (unsigned i = 0; i < elementCount; ++i)
        {
            values.push_back(create(*sequentialValue.getElementAsConstant(i),
                                    place,
                                    state));
        }

        return createArray(*sequentialValue.getType(), values);
    }
#endif

    if (llvm::isa<llvm::ConstantAggregateZero>(value))
    {
        const llvm::Type *type = value.getType();
        Domain *result = Constructors::create(*type);
        result->setZero(&place);
        return result;
    }

    if (llvm::isa<llvm::Function>(value))
    {
        const llvm::Function &functionValue =
            checkedCast<llvm::Function>(value);

        Domain *constPointer;
        constPointer = createPointer(*llvm::PointerType::getUnqual(
                                         functionValue.getFunctionType()));

        Pointer::Utils::addTarget(*constPointer,
                                  Pointer::Target::Function,
                                  &place,
                                  &value,
                                  std::vector<Domain*>(),
                                  NULL);

        return constPointer;
    }

    CANAL_NOT_IMPLEMENTED();
}