void DesktopConfigDbBackend::init() { m_manager->reset(); m_currentOid = 1; //KSimpleConfig config( m_fileName ); // DEPRECATED KDE3 -> KDE4 by Percy KConfig config( m_fileName ); QStringList groups = config.groupList(); QStringList::ConstIterator it( groups.begin() ); QStringList::ConstIterator end( groups.end() ); QMap<QString,QString> map; for ( ; it != end; ++it ) { map = config.entryMap( *it ); ObjectRef<Object> obj; if ( map.contains( "oid" ) ) obj = Classes::classInfo( *it )->create( stringToOid( map["oid"] ), m_manager, true ); else obj = Classes::classInfo( *it )->create( m_manager ); assert( obj ); if ( m_currentOid < obj->oid() ) m_currentOid = obj->oid(); //QMapConstIterator<QString,QString> mit( map.begin() ); // DEPRECATED Qt3 -> Qt4 by Percy //QMapConstIterator<QString,QString> mend( map.end() ); // DEPRECATED Qt3 -> Qt4 by Percy QMap<QString, QString>::const_iterator mit( map.begin() ); QMap<QString, QString>::const_iterator mend( map.end() ); for ( ; mit != mend; ++mit ) { if ( mit.key() != "oid" ) //obj->setProperty( mit.key(), mit.data() ); // DEPRECATED Qt3 -> Qt4 by Percy obj->setProperty( mit.key().toAscii(), QVariant(mit.value()) ); } } }
/* member = string name-separator value */ bool JsonParser::parseMember(ObjectRef o) { BEGIN << "parseMember"; Scope scope(context); QString key; if (!parseString(&key)) return false; QChar token = nextToken(); if (token != NameSeparator) { lastError = QJsonParseError::MissingNameSeparator; return false; } ScopedValue val(scope); if (!parseValue(val)) return false; ScopedString s(scope, context->engine->newIdentifier(key)); uint idx = s->asArrayIndex(); if (idx < UINT_MAX) { o->putIndexed(idx, val); } else { Property *p = o->insertMember(s, Attr_Data); p->value = val.asReturnedValue(); } END; return true; }
void ArrayPrototype::init(ExecutionEngine *engine, ObjectRef ctor) { Scope scope(engine); ScopedObject o(scope); ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor->defineReadonlyProperty(engine->id_prototype, (o = this)); ctor->defineDefaultProperty(QStringLiteral("isArray"), method_isArray, 1); defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString, method_toString, 0); defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString, 0); defineDefaultProperty(QStringLiteral("concat"), method_concat, 1); defineDefaultProperty(QStringLiteral("join"), method_join, 1); defineDefaultProperty(QStringLiteral("pop"), method_pop, 0); defineDefaultProperty(QStringLiteral("push"), method_push, 1); defineDefaultProperty(QStringLiteral("reverse"), method_reverse, 0); defineDefaultProperty(QStringLiteral("shift"), method_shift, 0); defineDefaultProperty(QStringLiteral("slice"), method_slice, 2); defineDefaultProperty(QStringLiteral("sort"), method_sort, 1); defineDefaultProperty(QStringLiteral("splice"), method_splice, 2); defineDefaultProperty(QStringLiteral("unshift"), method_unshift, 1); defineDefaultProperty(QStringLiteral("indexOf"), method_indexOf, 1); defineDefaultProperty(QStringLiteral("lastIndexOf"), method_lastIndexOf, 1); defineDefaultProperty(QStringLiteral("every"), method_every, 1); defineDefaultProperty(QStringLiteral("some"), method_some, 1); defineDefaultProperty(QStringLiteral("forEach"), method_forEach, 1); defineDefaultProperty(QStringLiteral("map"), method_map, 1); defineDefaultProperty(QStringLiteral("filter"), method_filter, 1); defineDefaultProperty(QStringLiteral("reduce"), method_reduce, 1); defineDefaultProperty(QStringLiteral("reduceRight"), method_reduceRight, 1); }
QJsonObject JsonObject::toJsonObject(ObjectRef o, V4ObjectSet &visitedObjects) { QJsonObject result; if (!o || o->asFunctionObject()) return result; Scope scope(o->engine()); if (visitedObjects.contains(o)) { // Avoid recursion. // For compatibility with QVariant{List,Map} conversion, we return an // empty object (and no error is thrown). return result; } visitedObjects.insert(o); ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); ScopedValue name(scope); QV4::ScopedValue val(scope); while (1) { name = it.nextPropertyNameAsString(val); if (name->isNull()) break; QString key = name->toQStringNoThrow(); if (!val->asFunctionObject()) result.insert(key, toJsonValue(val, visitedObjects)); } visitedObjects.remove(o); return result; }
void GameController::tryPlayerMove (Direction direction) { if (isFinished ()) { return; } Coords playerCoords = level.getObjectCoords (player); Coords playerDestination = playerCoords + direction; if (level.isValidCoord (playerDestination)) { if (!level.isEmpty (playerDestination)) { ObjectRef targetObject = level.getObject (playerDestination); auto interaction = targetObject->getGameClass ().interactionFunction; GameCommands commands (*this, targetObject); interaction (commands); } else { level.setObject (playerDestination, player); level.clear (playerCoords); } } displayFunction (data, level); }
void ComponentModelRegistry::dumpComponentGraph(ostream& os, bool display_nodeprops, bool display_linkprops) { renameObjects(); os << "# Microgrid system topology, generated by " << PACKAGE_NAME << " " << PACKAGE_VERSION << endl << "digraph Microgrid {" << endl << "overlap=\"false\"; labeljust=\"l\"; concentrate=\"true\"; splines=\"true\"; node [shape=box]; edge [len=2,constraint=\"false\"];" << endl; for (auto& i : m_objects) { ObjectRef objref = i.first; os << *m_names[objref] << " [label=\"" << *m_names[objref]; string name = objref->GetName(); if (name != *m_names[objref]) os << "\\nconfig:" << name; if (display_nodeprops && !m_objprops[objref].empty()) { for (auto& p : m_objprops[objref]) { os << "\\n" << *p.first; if (p.second->type != Entity::VOID) { os << ':'; printEntity(os, *p.second); } } } os << "\"];" << endl; } for (auto& i : m_linkprops) { auto& endpoints = i.first; auto& props = i.second; os << *m_names[endpoints.first] << " -> " << *m_names[endpoints.second.first] << " [constraint=\"" << (endpoints.second.second.first ? "false" : "true") << "\""; if (endpoints.second.second.second) os << ",dir=both"; if (display_linkprops) { os << ",label=\""; for (auto& p : props) { os << *p.first; if (p.second->type != Entity::VOID) { os << ':'; printEntity(os, *p.second); } os << ' '; } os << "\""; } os << "];" << endl; } os << "}" << endl; }
bool canWork (const URIs &uris, const lvtk::Atom& atom) override { if (atom.as_object().otype() != uris.jobs_ObjectRef) return false; ObjectRef ref (uris, atom.as_object()); return ref.has_class_type (uris.jobs_Disposable); }
const FBox WorldViewer::refBBox(ObjectRef ref) const { int index = ref.index(); if(ref.isEntity() && index >= 0 && index < (int)m_entities.size()) { if(m_entities[index].mode == VisEntity::shadowed) return m_entities[index].shadow->boundingBox(); } return m_world->refBBox(ref); }
QString Stringify::JO(ObjectRef o) { if (stack.contains(o.getPointer())) { ctx->throwTypeError(); return QString(); } Scope scope(ctx); QString result; stack.push(o.getPointer()); QString stepback = indent; indent += gap; QStringList partial; if (propertyList.isEmpty()) { ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); ScopedValue name(scope); ScopedValue val(scope); while (1) { name = it.nextPropertyNameAsString(val); if (name->isNull()) break; QString key = name->toQString(); QString member = makeMember(key, val); if (!member.isEmpty()) partial += member; } } else { ScopedString s(scope); for (int i = 0; i < propertyList.size(); ++i) { bool exists; s = propertyList.at(i); ScopedValue v(scope, o->get(s, &exists)); if (!exists) continue; QString member = makeMember(s->toQString(), v); if (!member.isEmpty()) partial += member; } } if (partial.isEmpty()) { result = QStringLiteral("{}"); } else if (gap.isEmpty()) { result = QStringLiteral("{") + partial.join(QLatin1Char(',')) + QStringLiteral("}"); } else { QString separator = QStringLiteral(",\n") + indent; result = QStringLiteral("{\n") + indent + partial.join(separator) + QStringLiteral("\n") + stepback + QStringLiteral("}"); } indent = stepback; stack.pop(); return result; }
void BooleanPrototype::init(ExecutionEngine *engine, ObjectRef ctor) { Scope scope(engine); ScopedObject o(scope); ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor->defineReadonlyProperty(engine->id_prototype, (o = this)); defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString, method_toString); defineDefaultProperty(engine->id_valueOf, method_valueOf); }
void ObjectFactory::RegisterObject(ObjectRef& objRef) { MutexSentinel mutexSentinel(m_mutex); std::map<CStdString, ObjectRef>::iterator pair = m_classes.find(objRef->GetClassName()); if(pair != m_classes.end()) { m_classes.erase(pair); } m_classes.insert(std::make_pair(objRef->GetClassName(), objRef)); }
void work (const URIs& uris, const lvtk::Atom& atom) override { SampleCache& cache (*getSampleCache()); if (LayerData* data = cache.getLayerData (uris, atom.as_object(), false)) { const ObjectRef ref (jobs->getWorkForge(), uris.ksp1_Layer, data); if (ref.get<LayerData>() != nullptr) { respond (ref.total_size(), ref.cobj()); } } }
// this is the trickest part in the program, because we need to output the objects in each timeline (each timeline // describes one object), but we need to keep refering back to the mainline to see if the object is attached to any // bones, and if so, calculate how this affects the final position of the object // Note that we're only interested in exporting objects - not bones std::ostream& operator<< (std::ostream& out, const Timeline& timeline) { if(!timeline.isTypeObject()) return out; out << "\t\t[" << timeline.m_id + 1 << "] = {" << endl; for(vector<Object*>::const_iterator it = timeline.m_objects.begin(); it != timeline.m_objects.end(); ) { // For each object we have to check if it is attached to a bone. If it is, then // we need to recursively look up the bone's properties and calculate the values to add to the // object position. Object* object = *it; // search the mainline for any references to this timeline and key pair int mainlineKeyId; ObjectRef* objectRef = timeline.m_owner->findReferenceToObject(timeline.m_id, object->getId(), &mainlineKeyId); Transform objectTransform(object->getX(), object->getY(), object->getAngle(), object->getScaleX(), object->getScaleY()); BoneRef* boneRef = timeline.m_owner->getBoneReference(objectRef, mainlineKeyId); Transform parentTransform = timeline.buildTransform(boneRef, mainlineKeyId); objectTransform.apply_parent_transform(parentTransform); float x = objectTransform.x; float y = objectTransform.y; int z = objectRef->getZIndex(); float angle = objectTransform.angle; float scaleX = objectTransform.scale_x; float scaleY = objectTransform.scale_y; out << "\t\t\t[" << object->getId() + 1 << "] = {" << endl; out << "\t\t\t\t['angle'] = " << boost::format("%.4f") % angle << "," << endl; out << "\t\t\t\t['texture'] = '" << timeline.m_owner->getFileName(object->getFolder(), object->getFile()) << "'," << endl; out << "\t\t\t\t['zindex'] = " << z << "," << endl; out << "\t\t\t\t['scale_x'] = " << boost::format("%.4f") % scaleX << "," << endl; out << "\t\t\t\t['scale_y'] = " << boost::format("%.4f") % scaleY << "," << endl; out << "\t\t\t\t['time'] = " << object->getTime() << "," << endl; out << "\t\t\t\t['x'] = " << boost::format("%.6f") % x << "," << endl; out << "\t\t\t\t['y'] = " << boost::format("%.6f") % y << "," << endl; out << "\t\t\t\t['spin'] = " << object->getSpin() << "," << endl; out << "\t\t\t\t['pivot_x'] = " << 0 << "," << endl; out << "\t\t\t\t['pivot_y'] = " << timeline.m_owner->getFile(object->getFolder(), object->getFile())->getHeight()<< endl; out << "\t\t\t}"; if(++it != timeline.m_objects.end()) out << ", "; out << endl; } out << "\t\t}"; return out; }
void testObjectBlock (void) { /*ObjectRef<int> obj; obj.allocate(); *obj.get() = 18;*/ ObjectRef<TestDummyClass> ptr; ptr.allocate(); ptr.get()->i = 19; ptr.get()->j = 20; ObjectRef<TestDummyClass> ptr1 = ptr; }
std::shared_ptr<Ego::Particle> ParticleHandler::spawnParticle(const Vector3f& spawnPos, const Facing& spawnFacing, const PRO_REF spawnProfile, const PIP_REF particleProfile, const ObjectRef spawnAttach, Uint16 vrt_offset, const TEAM_REF spawnTeam, const ObjectRef spawnOrigin, const ParticleRef spawnParticleOrigin, const int multispawn, const ObjectRef spawnTarget, const bool onlyOverWater) { const std::shared_ptr<ParticleProfile> &ppip = ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile); if (!ppip) { const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler()[spawnOrigin]->getName() : "INVALID"; const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname() : "INVALID"; Log::get().debug("spawn_one_particle() - cannot spawn particle with invalid particle profile == %d, spawn origin == %" PRIuZ " (\"%s\"), spawn profile == %d (\"%s\"))\n", REF_TO_INT(particleProfile), spawnOrigin.get(), spawnOriginName.c_str(), REF_TO_INT(spawnProfile), spawnProfileName.c_str()); return Ego::Particle::INVALID_PARTICLE; } // count all the requests for this particle type ppip->_spawnRequestCount++; //Try to get a free particle std::shared_ptr<Ego::Particle> particle = getFreeParticle(ppip->force); if(particle) { //Initialize particle and add it into the game if(particle->initialize(ParticleRef(_totalParticlesSpawned++), spawnPos, spawnFacing, spawnProfile, particleProfile, spawnAttach, vrt_offset, spawnTeam, spawnOrigin, ParticleRef(spawnParticleOrigin), multispawn, spawnTarget, onlyOverWater)) { _pendingParticles.push_back(particle); _particleMap[particle->getParticleID()] = particle; } else { //If we failed to spawn somehow, put it back to the unused pool _unusedPool.push_back(particle); } } if(!particle) { const std::string spawnOriginName = _currentModule->getObjectHandler().exists(spawnOrigin) ? _currentModule->getObjectHandler().get(spawnOrigin)->getName() : "INVALID"; const std::string particleProfileName = LOADED_PIP(particleProfile) ? ProfileSystem::get().ParticleProfileSystem.get_ptr(particleProfile)->_name : "INVALID"; const std::string spawnProfileName = ProfileSystem::get().isValidProfileID(spawnProfile) ? ProfileSystem::get().getProfile(spawnProfile)->getPathname().c_str() : "INVALID"; Log::get().debug("spawn_one_particle() - cannot allocate a particle! owner == %" PRIuZ "(\"%s\"), spawn profile == %d(\"%s\"), particle profile == %d(\"%s\")\n", spawnOrigin.get(), spawnOriginName.c_str(), REF_TO_INT(spawnProfile), spawnProfileName.c_str(), REF_TO_INT(particleProfile), particleProfileName.c_str()); } return particle; }
void work (const URIs& uris, const lvtk::Atom& atom) override { const lvtk::AtomObject object (atom.as_object()); const lvtk::Atom note; lv2_atom_object_get (object, uris.slugs_note, ¬e, 0); if (note) { SamplerSound* s = new SamplerSound (note.as_int(), static_cast<int> (object.id())); const ObjectRef ref (jobs->getWorkForge(), uris.ksp1_Key, s); if (ref.get<SamplerSound>() != nullptr) { respond (ref.total_size(), ref.cobj()); } } }
ObjectIterator::ObjectIterator(Value *scratch1, Value *scratch2, const ObjectRef o, uint flags) : object(ObjectRef::fromValuePointer(scratch1)) , current(ObjectRef::fromValuePointer(scratch2)) , arrayNode(0) , arrayIndex(0) , memberIndex(0) , flags(flags) { object = o.getPointer(); current = o.getPointer(); if (!!object && object->asArgumentsObject()) { Scope scope(object->engine()); Scoped<ArgumentsObject> (scope, object->asReturnedValue())->fullyCreate(); } }
void FunctionPrototype::init(ExecutionEngine *engine, ObjectRef ctor) { Scope scope(engine); ScopedObject o(scope); ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor->defineReadonlyProperty(engine->id_prototype, (o = this)); defineReadonlyProperty(engine->id_length, Primitive::fromInt32(0)); defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString, method_toString, 0); defineDefaultProperty(QStringLiteral("apply"), method_apply, 2); defineDefaultProperty(QStringLiteral("call"), method_call, 1); defineDefaultProperty(QStringLiteral("bind"), method_bind, 1); }
ObjectRef ObjectFactory::NewInstance(CStdString& className) { MutexSentinel mutexSentinel(m_mutex); std::map<CStdString, ObjectRef>::iterator pair; pair = m_classes.find(className); if (pair == m_classes.end()) { return ObjectRef(); // Empty } else { ObjectRef ref = pair->second; return ref->NewInstance(); } }
void NumberPrototype::init(ExecutionEngine *engine, ObjectRef ctor) { Scope scope(engine); ScopedObject o(scope); ctor->defineReadonlyProperty(engine->id_prototype, (o = this)); ctor->defineReadonlyProperty(engine->id_length, Primitive::fromInt32(1)); ctor->defineReadonlyProperty(QStringLiteral("NaN"), Primitive::fromDouble(qSNaN())); ctor->defineReadonlyProperty(QStringLiteral("NEGATIVE_INFINITY"), Primitive::fromDouble(-qInf())); ctor->defineReadonlyProperty(QStringLiteral("POSITIVE_INFINITY"), Primitive::fromDouble(qInf())); ctor->defineReadonlyProperty(QStringLiteral("MAX_VALUE"), Primitive::fromDouble(1.7976931348623158e+308)); #ifdef __INTEL_COMPILER # pragma warning( push ) # pragma warning(disable: 239) #endif ctor->defineReadonlyProperty(QStringLiteral("MIN_VALUE"), Primitive::fromDouble(5e-324)); #ifdef __INTEL_COMPILER # pragma warning( pop ) #endif defineDefaultProperty(QStringLiteral("constructor"), (o = ctor)); defineDefaultProperty(engine->id_toString, method_toString); defineDefaultProperty(QStringLiteral("toLocaleString"), method_toLocaleString); defineDefaultProperty(engine->id_valueOf, method_valueOf); defineDefaultProperty(QStringLiteral("toFixed"), method_toFixed, 1); defineDefaultProperty(QStringLiteral("toExponential"), method_toExponential); defineDefaultProperty(QStringLiteral("toPrecision"), method_toPrecision); }
WithContext::WithContext(ExecutionEngine *engine, ObjectRef with) : ExecutionContext(engine, Type_WithContext) { callData = parent->callData; outer = parent; lookups = parent->lookups; compilationUnit = parent->compilationUnit; withObject = with.getPointer(); }
void Key::Init(TiXmlNode *node, CCSpriterX *animator) { TiXmlElement *element = node->ToElement(); if (element) { int intValue; float floatValue; if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS) mId = intValue; float time = 0; if (element->QueryFloatAttribute("time", &floatValue) == TIXML_SUCCESS) // was in milliseconds, convert to seconds instead time = floatValue/1000.0f; mTime = time; if (element->QueryIntAttribute("spin", &intValue) == TIXML_SUCCESS) mSpinCounterClockwise = !(intValue == -1); for (TiXmlNode* objNode = node->FirstChild(); objNode; objNode = objNode->NextSibling()) { element = objNode->ToElement(); const char *tabObj = element->Value(); if (strcmp(tabObj, "object_ref")==0) { ObjectRef *ref = new ObjectRef(); ref->Init(objNode); mObjectRefs.push_back(ref); } else if (strcmp(tabObj, "object")==0) { Object *obj = new Object(); obj->Init(objNode, animator); mObjects.push_back(obj); } } } }
const FBox World::refBBox(ObjectRef ref) const { if(ref.isTile()) { if(ref.m_index >= 0 && ref.m_index < m_tile_map.size()) return m_tile_map[ref.m_index].bbox; } else { if(ref.m_index >= 0 && ref.m_index < m_entity_map.size()) return m_entity_map[ref.m_index].bbox; } return FBox::empty(); }
ObjectRef GRT::find_object_by_id(const std::string &id, const std::string &subpath) { /* std::map<std::string,internal::Object*>::const_iterator iter= _objects.find(id); if (iter == _objects.end()) return ObjectRef(iter->second); return ObjectRef(); */ std::map<std::string, ObjectRef >::const_iterator iter; if ((iter= _objects_cache.find(id)) != _objects_cache.end()) return iter->second; ValueRef start= get(subpath); ObjectRef result = ObjectRef(); if (start.is_valid()) { switch (start.type()) { case ListType: result = find_child_object(BaseListRef::cast_from(start), id); break; case DictType: result = find_child_object(DictRef::cast_from(start), id); break; case ObjectType: result = find_child_object(ObjectRef::cast_from(start), id); break; default: throw std::invalid_argument("Value at "+subpath+" is not a container"); } } if (result.is_valid()) _objects_cache[id] = result; return result; }
void DomSerializer::GetList(const char* key, std::list<ObjectRef>& value, Object& model, bool required) { // Find the node corresponding to the object list wanting to be populated DOMNode* listNode = FindElementByName(m_node, CStdString(key)); // Create a new serializer and affect it to this object if (listNode) { // Iterate over the nodes ##### DOMNode* node = listNode->getFirstChild(); while(node) { // Create a new object instance ObjectRef newObject = model.NewInstance(); try { DomSerializer serializer(newObject.get()); serializer.DeSerialize(node); value.push_back(newObject); } catch (CStdString& e) { // For now, do not interrupt the deserialization process. // in the future, we might let this exception go through if the node has been // recognized to bear the proper tag name ; } node = node->getNextSibling(); } } else if (required) { throw(CStdString("DomSerializer::GetList: required node missing:") + key); } }
Script::Script(ExecutionEngine *v4, ObjectRef qml, CompiledData::CompilationUnit *compilationUnit) : line(0), column(0), scope(v4->rootContext), strictMode(false), inheritContext(true), parsed(false) , qml(qml.asReturnedValue()), vmFunction(0), parseAsBinding(true) { parsed = true; if (compilationUnit) { vmFunction = compilationUnit->linkToEngine(v4); Q_ASSERT(vmFunction); Scope valueScope(v4); ScopedValue holder(valueScope, new (v4->memoryManager) CompilationUnitHolder(v4, compilationUnit)); compilationUnitHolder = holder; } else vmFunction = 0; }
void SqlBackendTest::testRelations() { Manager::self()->reset(); Manager::self()->setCachePolicy( Manager::FreeAllOnTransaction ); ObjectRef<CustomerOrder> order = CustomerOrder::create(); ObjectRef<Article> a1 = Article::create(); ObjectRef<Article> a2 = Article::create(); ObjectRef<Article> a3 = Article::create(); order->articles()->add( a1 ); order->articles()->add( a2 ); order->articles()->add( a3 ); Manager::self()->commit(); CHECK( Manager::self()->objects().count(), 0 ); CHECK( a2->orders()->count(), 1 ); CHECK( order->articles()->count(), 3 ); order->articles()->remove( a2 ); CHECK( a2->orders()->count(), 0 ); CHECK( order->articles()->count(), 2 ); Manager::self()->rollback(); CHECK( Manager::self()->objects().count(), 0 ); CHECK( Manager::self()->relations().count(), 0 ); CHECK( Manager::self()->collections().count(), 0 ); CHECK( a2->orders()->count(), 1 ); Manager::self()->status(); CHECK( order->articles()->count(), 3 ); a2->orders()->remove( order ); CHECK( a2->orders()->count(), 0 ); CHECK( order->articles()->count(), 2 ); Manager::self()->commit(); CHECK( Manager::self()->objects().count(), 0 ); CHECK( a2->orders()->count(), 0 ); CHECK( order->articles()->count(), 2 ); }
void Daggerstorm::Cast(ObjectRef user, ObjectRef enemy) { for (int i = 0; i < 8; i++) { auto projectileObject = Object::Create(); projectileObject->SetJustEnabled(); static int projectileNumber = 0; std::string name = std::string("projectile") + std::to_string(projectileNumber++); projectileObject->SetName(name); auto projectileComp = projectileObject->AddComponent<ProjectileComponent>(); auto spriteComp = projectileObject->AddComponent<SpriteComponent>(); auto colliderComp = projectileObject->AddComponent<ColliderComponent>(); Vector2f direction = directions[i]; projectileComp->SetDirection(direction); projectileComp->SetSpeed(projectileSpeed); projectileComp->SetSpell(this); projectileComp->SetUser(user); projectileComp->SetCanApplyOnUser(false); spriteComp->SetTexture("dagger.png"); spriteComp->SetSize(Vector2f(20, 40)); colliderComp->InitShape("rectangle", "20, 20"); colliderComp->SetIsStatic(false); colliderComp->SetIsPhantom(true); Vector2f userPos = user->GetComponent<SpriteComponent>()->GetSize(); Vector2f startingPos = user->GetPos() + userPos/2.f; Vector2f projectileSize = spriteComp->GetSize(); float magic = (sqrt(pow(projectileSize.x, 2) + pow(projectileSize.y, 2))) / 2; projectileObject->SetPos(startingPos + magic * direction); g_menuHandler->GetCurrentMenu()->AddChild(std::move(projectileObject)); } r_cooldown = cooldown; }
CallContext::CallContext(ExecutionEngine *engine, ObjectRef qml, FunctionObject *function) : ExecutionContext(engine, Type_QmlContext) { this->function = function; callData = reinterpret_cast<CallData *>(this + 1); callData->tag = QV4::Value::_Integer_Type; callData->argc = 0; callData->thisObject = Primitive::undefinedValue(); strictMode = true; outer = function->scope; activation = qml.getPointer(); if (function->function) { compilationUnit = function->function->compilationUnit; lookups = compilationUnit->runtimeLookups; } locals = (SafeValue *)(this + 1); if (function->varCount) std::fill(locals, locals + function->varCount, Primitive::undefinedValue()); }
int CommandLineServer::svc(void) { for (bool active = true;active == true;) { char buf[2048]; ACE_Time_Value timeout; timeout.sec(3600); int i = 0; // Display prompt char prompt[] = "\r\n>"; peer().send(prompt, 3, MSG_NOSIGNAL); // Get one command line bool foundCRLF = false; while(active && !foundCRLF && i<2040) { ssize_t size = peer().recv(buf+i, 2040-i, &timeout); if (size == 0 || size == -1) { active = false; } else { for(int j=0; j<size && !foundCRLF;j++) { if(buf[i+j] == '\r' || buf[i+j] == '\n') { foundCRLF = true; buf[i+j] = '\0'; CStdString command(buf); try { CStdString className = SingleLineSerializer::FindClass(command); ObjectRef objRef = ObjectFactory::GetSingleton()->NewInstance(className); if (objRef.get()) { objRef->DeSerializeSingleLine(command); ObjectRef response = objRef->Process(); CStdString responseString = response->SerializeSingleLine(); peer().send((PCSTR)responseString, responseString.GetLength(), MSG_NOSIGNAL); } else { CStdString error = "Unrecognized command"; peer().send(error, error.GetLength(), MSG_NOSIGNAL); ; } } catch (CStdString& e) { peer().send(e, e.GetLength(), MSG_NOSIGNAL); ; } } } i += size; } } } return 0; }