Example #1
0
void PaintElement::setPosition (const RelativePositionedRectangle& newPosition, const bool undoable)
{
    if (position != newPosition)
    {
        if (undoable)
        {
            perform (new PaintElementMoveAction (this, newPosition),
                     "Move " + getTypeName());
        }
        else
        {
            position = newPosition;

            if (owner != nullptr)
                owner->changed();
        }
    }
}
Example #2
0
void TOutputGLSLBase::declareInterfaceBlock(const TInterfaceBlock *interfaceBlock)
{
    TInfoSinkBase &out = objSink();

    out << hashName(interfaceBlock->name()) << "{\n";
    const TFieldList &fields = interfaceBlock->fields();
    for (size_t i = 0; i < fields.size(); ++i)
    {
        const TField *field = fields[i];
        if (writeVariablePrecision(field->type()->getPrecision()))
            out << " ";
        out << getTypeName(*field->type()) << " " << hashName(field->name());
        if (field->type()->isArray())
            out << arrayBrackets(*field->type());
        out << ";\n";
    }
    out << "}";
}
Example #3
0
Box* dictGetitem(BoxedDict* self, Box* k) {
    if (!isSubclass(self->cls, dict_cls))
        raiseExcHelper(TypeError, "descriptor '__getitem__' requires a 'dict' object but received a '%s'",
                       getTypeName(self));

    auto it = self->d.find(k);
    if (it == self->d.end()) {
        // Try calling __missing__ if this is a subclass
        if (self->cls != dict_cls) {
            static const std::string missing("__missing__");
            Box* r = callattr(self, &missing, CallattrFlags({.cls_only = true, .null_on_nonexistent = true }),
                              ArgPassSpec(1), k, NULL, NULL, NULL, NULL);
            if (r)
                return r;
        }

        raiseExcHelper(KeyError, k);
    }
Example #4
0
File: rdd.c Project: Redsmin/rdd
void keyPrint(char*key)
{   struct keynfo k;
    keyGetNfo(key,&k);
    char * header = "------------------";
    printf("%s\n%s, %u elements, ttl %d\n",header,getTypeName(k.type),*k.nb,*k.ttl);
    for(u32 c=0; c<*k.nb; c++)
    {   if(k.sizes[c])
        {   char *p = &(k.data[c][k.sizes[c]]);
            p--;
            char save = *p;
            *p = 0;
            printf("%2u %u\t[%*s%c]\n",c,k.sizes[c],k.sizes[c]-1,k.data[c],save);
            *p = save;
        } else printf("%2u %u\t[]\n",c,k.sizes[c]);
    }
    printf("%s\n",header);
    free(k.data);
}
Example #5
0
void XmlReaderSOPValueElt::end()
{
    Trim(m_contentData);

    std::vector<double> data;

    try
    {
        data = GetNumbers<double>(m_contentData.c_str(), m_contentData.size());
    }
    catch (Exception&)
    {
        const std::string s = TruncateString(m_contentData.c_str(),
                                             m_contentData.size());
        std::ostringstream oss;
        oss << "Illegal values '" << s << "' in " << getTypeName();
        throwMessage(oss.str());
    }

    if (data.size() != 3)
    {
        throwMessage("SOPNode: 3 values required.");
    }

    XmlReaderSOPNodeBaseElt* pSOPNodeElt = 
        dynamic_cast<XmlReaderSOPNodeBaseElt*>(getParent().get());
    CDLOpDataRcPtr pCDL = pSOPNodeElt->getCDL();

    if (0 == strcmp(getName().c_str(), TAG_SLOPE))
    {
        pCDL->setSlopeParams(CDLOpData::ChannelParams(data[0], data[1], data[2]));
        pSOPNodeElt->setIsSlopeInit(true);
    }
    else if (0 == strcmp(getName().c_str(), TAG_OFFSET))
    {
        pCDL->setOffsetParams(CDLOpData::ChannelParams(data[0], data[1], data[2]));
        pSOPNodeElt->setIsOffsetInit(true);
    }
    else if (0 == strcmp(getName().c_str(), TAG_POWER))
    {
        pCDL->setPowerParams(CDLOpData::ChannelParams(data[0], data[1], data[2]));
        pSOPNodeElt->setIsPowerInit(true);
    }
}
Example #6
0
void URLRequest::cancel(bool cleanup)
{
	if (_handle == NULL || !cleanup)
		return;

	g_Net->cancelRequest(this, cleanup);

	if (cleanup)
		_handle = NULL;

	LOG(0, "*** %s '%s' canceled\n", getTypeName(), _url.c_str());

	_canceled = true;
	_error = CURLE_ABORTED_BY_CALLBACK;
	onError(_error);

	if (_scriptWaitBlock)
		_scriptWaitBlock->signal(0x00);
}
Example #7
0
	PhysicsNode::PhysicsNode(Scene *scene_) : Node(scene_), body(NULL) {
		type = NODE_PHYSICS;
	//	collision = NULL;
		body = scene_->getPhysicsWorld().createBody();
		//body->setPhysicsWorld(&scene->getPhysicsWorld());
	//	collision = physics.createCollision();
		do_invalidate_matrix = true;
		do_init_state = true;
		render_body = true;
		object_2d = false;
		controlled = false;
		init_scale = vec3(1.0f, 1.0f, 1.0f);

		body->setSize(box.getExtents() * 2.0f);
		body->setMass(0.0f);

		invalidate();
		setName(getTypeName());
	}
Example #8
0
void JavaCodeGenerator::generateDispatcher(string file, TalkyUnit* unit, Interface& theInterface) {
// 3. dispatcher
    ofstream ofs(file);
    if (unit->currentPackage != "") {
        ofs << "package " << unit->currentPackage << ";" << endl;
    }

    generateImports(ofs);

    ofs << "public class " + theInterface.name + "Dispatcher {" << endl;
    // 1. dispatcher method
    ofs << "public static void dispatch(DataInputStream dis, " + theInterface.name + "Proxy proxy) throws Exception{" << endl;
    ofs << "int fid = (int)(dis.read()&0xFFFF);" << endl;
    ofs << "switch(fid)" << endl;
    ofs << "{" << endl;
    for (int i = 0; i < theInterface.functions.size(); i++) {
        ofs << "case " + __ITOA(i) + ":" << endl;
        ofs << "{" << endl;
        ofs << theInterface.functions[i]->name << "(dis, proxy);" << endl;
        ofs << "}" << endl;
        ofs << "break;" << endl;
    }
    ofs << "}" << endl; // switch
    ofs << "}" << endl; // dispatch method
    // 2. deserialize param and call proxy
    for (int i = 0; i < theInterface.functions.size(); i++) {
        ofs << "protected static void " + theInterface.functions[i]->name + "(DataInputStream dis, " + theInterface.name + "Proxy proxy) throws Exception{" << endl;
        for (int j = 0; j < theInterface.functions[i]->params.size(); j++) {
            string typeName = getTypeName(*theInterface.functions[i]->params[j]);
            ofs << typeName << " " << theInterface.functions[i]->params[j]->name << ";" << endl;
        }
        for (int j = 0; j < theInterface.functions[i]->params.size(); j++) {
            deserializeField(ofs, *theInterface.functions[i]->params[j]);
        }

        //make the call
        ofs << "proxy." << theInterface.functions[i]->name << "(" + getParamNameListString(theInterface.functions[i]) + ");" << endl;

        ofs << "}" << endl;
    }
    ofs << "}" << endl;
    ofs.close();
}
Example #9
0
void TOutputGLSLBase::writeVariableType(const TType& type)
{
    TInfoSinkBase& out = objSink();
    TQualifier qualifier = type.getQualifier();
    // TODO(alokp): Validate qualifier for variable declarations.
    if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal))
        out << type.getQualifierString() << " ";
    // Declare the struct if we have not done so already.
    if ((type.getBasicType() == EbtStruct) && !structDeclared(type.getStruct()))
    {
        declareStruct(type.getStruct());
    }
    else
    {
        if (writeVariablePrecision(type.getPrecision()))
            out << " ";
        out << getTypeName(type);
    }
}
	ParticleSystemNode::ParticleSystemNode(Scene *scene_) : Node(scene_) {
		type = NODE_PARTICLESYSTEM;
		timeToSpawn = 0;

		box = BBox(vec3(-0.5, -0.5, -0.5), vec3(0.5, 0.5, 0.5));
		particleBox = box;
		sphere = BSphere(vec3(), 0.5);
		first_update = true;

		setSpawnRate(5.0f);
		setLife(5.0f, 0.0f);
		setSize(0.1f, 0.0f);
		setGrowth(1.0f, 0.0f);
		setEmitter(EMITTER_BOX);
		setColor(vec3(0.5f, 0.5f, 0.0f), vec3(1.0f, 0.0f, 0.0f));
		setSpeed(0.1f, 0.0f, 0.0f);
		setGravity(0.0f);
		setName(getTypeName());
	}
Example #11
0
__attribute__((always_inline)) bool _doFree(GCAllocation* al, std::vector<Box*>* weakly_referenced) {
    static StatCounter gc_safe_destructors("gc_safe_destructor_calls");

#ifndef NVALGRIND
    VALGRIND_DISABLE_ERROR_REPORTING;
#endif
    GCKind alloc_kind = al->kind_id;
#ifndef NVALGRIND
    VALGRIND_ENABLE_ERROR_REPORTING;
#endif

    if (alloc_kind == GCKind::PYTHON || alloc_kind == GCKind::CONSERVATIVE_PYTHON) {
#ifndef NVALGRIND
        VALGRIND_DISABLE_ERROR_REPORTING;
#endif
        Box* b = (Box*)al->user_data;
#ifndef NVALGRIND
        VALGRIND_ENABLE_ERROR_REPORTING;
#endif

        assert(b->cls);
        if (isWeaklyReferenced(b)) {
            assert(weakly_referenced && "attempting to free a weakly referenced object manually");
            weakly_referenced->push_back(b);
            return false;
        }

        ASSERT(!hasOrderedFinalizer(b->cls) || hasFinalized(al) || alloc_kind == GCKind::CONSERVATIVE_PYTHON, "%s",
               getTypeName(b));

        if (b->cls->tp_dealloc != dealloc_null && b->cls->has_safe_tp_dealloc) {
            gc_safe_destructors.log();

            GCAllocation* al = GCAllocation::fromUserData(b);
            assert(!hasFinalized(al));
            assert(!hasOrderedFinalizer(b->cls));

            // Don't bother setting the finalized flag since the object is getting freed right now.
            b->cls->tp_dealloc(b);
        }
    }
    return true;
}
Example #12
0
Box* floatNew2(BoxedClass *cls, Box* a) {
    assert(cls == float_cls);

    if (a->cls == float_cls) {
        return a;
    } else if (a->cls == str_cls) {
        const std::string &s = static_cast<BoxedString*>(a)->s;
        if (s == "nan")
            return boxFloat(NAN);
        if (s == "-nan")
            return boxFloat(-NAN);
        if (s == "inf")
            return boxFloat(INFINITY);
        if (s == "-inf")
            return boxFloat(-INFINITY);

        return boxFloat(strtod(s.c_str(), NULL));
    }
    RELEASE_ASSERT(0, "%s", getTypeName(a)->c_str());
}
Example #13
0
void TOutputGLSLBase::declareStruct(const TStructure* structure)
{
    TInfoSinkBase& out = objSink();

    out << "struct " << hashName(structure->name()) << "{\n";
    const TFieldList& fields = structure->fields();
    for (size_t i = 0; i < fields.size(); ++i)
    {
        const TField* field = fields[i];
        if (writeVariablePrecision(field->type()->getPrecision()))
            out << " ";
        out << getTypeName(*field->type()) << " " << hashName(field->name());
        if (field->type()->isArray())
            out << arrayBrackets(*field->type());
        out << ";\n";
    }
    out << "}";

    mDeclaredStructs.insert(structure->name());
}
Example #14
0
Box* superInit(Box* _self, Box* _type, Box* obj) {
    RELEASE_ASSERT(_self->cls == super_cls, "");
    BoxedSuper* self = static_cast<BoxedSuper*>(_self);

    if (!PyType_Check(_type))
        raiseExcHelper(TypeError, "must be type, not %s", getTypeName(_type));
    BoxedClass* type = static_cast<BoxedClass*>(_type);

    BoxedClass* obj_type = NULL;
    if (obj == None)
        obj = NULL;
    if (obj != NULL)
        obj_type = superCheck<CXX>(type, obj);

    self->type = type;
    self->obj = obj;
    self->obj_type = obj_type;

    return None;
}
Example #15
0
Box* listAdd(BoxedList* self, Box* _rhs) {
    if (_rhs->cls != list_cls) {
        raiseExcHelper(TypeError, "can only concatenate list (not \"%s\") to list", getTypeName(_rhs)->c_str());
    }

    LOCK_REGION(self->lock.asRead());

    BoxedList* rhs = static_cast<BoxedList*>(_rhs);

    BoxedList* rtn = new BoxedList();

    int s1 = self->size;
    int s2 = rhs->size;
    rtn->ensure(s1 + s2);

    memcpy(rtn->elts->elts, self->elts->elts, sizeof(self->elts->elts[0]) * s1);
    memcpy(rtn->elts->elts + s1, rhs->elts->elts, sizeof(rhs->elts->elts[0]) * s2);
    rtn->size = s1 + s2;
    return rtn;
}
Example #16
0
extern "C" Box* intDivmod(BoxedInt* lhs, Box* rhs) {
    if (!isSubclass(lhs->cls, int_cls))
        raiseExcHelper(TypeError, "descriptor '__divmod__' requires a 'int' object but received a '%s'",
                       getTypeName(lhs));

    Box* divResult = intDiv(lhs, rhs);

    if (divResult == NotImplemented) {
        return NotImplemented;
    }

    Box* modResult = intMod(lhs, rhs);

    if (modResult == NotImplemented) {
        return NotImplemented;
    }

    Box* arg[2] = { divResult, modResult };
    return createTuple(2, arg);
}
Example #17
0
std::string VariantImpl::asString() const
{
    switch(type) {
      case VAR_VOID: return EMPTY;
      case VAR_BOOL: return value.b ? TRUE : FALSE;
      case VAR_UINT8: return boost::lexical_cast<std::string>((int) value.ui8);
      case VAR_UINT16: return boost::lexical_cast<std::string>(value.ui16);
      case VAR_UINT32: return boost::lexical_cast<std::string>(value.ui32);
      case VAR_UINT64: return boost::lexical_cast<std::string>(value.ui64);
      case VAR_INT8: return boost::lexical_cast<std::string>((int) value.i8);
      case VAR_INT16: return boost::lexical_cast<std::string>(value.i16);
      case VAR_INT32: return boost::lexical_cast<std::string>(value.i32);
      case VAR_INT64: return boost::lexical_cast<std::string>(value.i64);
      case VAR_DOUBLE: return boost::lexical_cast<std::string>(value.d);
      case VAR_FLOAT: return boost::lexical_cast<std::string>(value.f);
      case VAR_STRING: return *reinterpret_cast<std::string*>(value.v);
      case VAR_LIST: return toString(asList());
      case VAR_MAP: return toString(asMap());
      default: throw InvalidConversion(QPID_MSG("Cannot convert from " << getTypeName(type) << " to " << getTypeName(VAR_STRING)));
    }
}
Example #18
0
void URLRequest::error(CURLcode err)
{
	if (_canceled)
	{
		_handle = NULL;
		return;
	}

	_error = err;
	LOG(0, "*** %s '%s' failed: %s\n", getTypeName(), _url.c_str(), getErrorString());

	onError(err);

	_handle = NULL;

	if (_channel) 
		_channel->send(EVT::NET_REQUEST_ERROR, new NetRequestEvent(this));

	if (_scriptWaitBlock)
		_scriptWaitBlock->signal(0x00);
}
Example #19
0
//static void break_deref() {}
void AbstractQoreNode::deref(ExceptionSink* xsink) {
   //QORE_TRACE("AbstractQoreNode::deref()");
#ifdef DEBUG
   /*
   if (test(this)) {
      printd(0, "AbstractQoreNode::deref() %p type: %d %s (%d->%d)\n", this, type, getTypeName(), references, references - 1);
      break_deref();
   }
   */
#if TRACK_REFS
   if (type == NT_OBJECT)
      printd(REF_LVL, "QoreObject::deref() %p class: %s (%d->%d) %d\n", this, ((QoreObject*)this)->getClassName(), references, references - 1, custom_reference_handlers);
   else
      printd(REF_LVL, "AbstractQoreNode::deref() %p type: %d %s (%d->%d)\n", this, type, getTypeName(), references, references - 1);

#endif
   if (references > 10000000 || references <= 0){
      if (type == NT_STRING)
	 printd(0, "AbstractQoreNode::deref() WARNING, node %p references: %d (type: %s) (val=\"%s\")\n",
		this, references, getTypeName(), ((QoreStringNode*)this)->getBuffer());
      else
	 printd(0, "AbstractQoreNode::deref() WARNING, node %p references: %d (type: %s)\n", this, references, getTypeName());
      assert(false);
   }
#endif
   assert(references > 0);

   if (there_can_be_only_one) {
      assert(is_unique());
      return;
   }

   if (custom_reference_handlers) {
      customDeref(xsink);
   }
   else if (ROdereference()) {
      if (type < NUM_SIMPLE_TYPES || derefImpl(xsink))
	 delete this;
   }
}
Example #20
0
const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
                                                         const ConstantUnion* pConstUnion)
{
    TInfoSinkBase& out = objSink();

    if (type.getBasicType() == EbtStruct)
    {
        const TStructure* structure = type.getStruct();
        out << hashName(structure->name()) << "(";

        const TFieldList& fields = structure->fields();
        for (size_t i = 0; i < fields.size(); ++i)
        {
            const TType* fieldType = fields[i]->type();
            ASSERT(fieldType != NULL);
            pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
            if (i != fields.size() - 1) out << ", ";
        }
        out << ")";
    }
    else
    {
        size_t size = type.getObjectSize();
        bool writeType = size > 1;
        if (writeType) out << getTypeName(type) << "(";
        for (size_t i = 0; i < size; ++i, ++pConstUnion)
        {
            switch (pConstUnion->getType())
            {
                case EbtFloat: out << std::min(FLT_MAX, std::max(-FLT_MAX, pConstUnion->getFConst())); break;
                case EbtInt: out << pConstUnion->getIConst(); break;
                case EbtBool: out << pConstUnion->getBConst(); break;
                default: UNREACHABLE();
            }
            if (i != size - 1) out << ", ";
        }
        if (writeType) out << ")";
    }
    return pConstUnion;
}
Example #21
0
// Calculate the rectangle size depending on children
void UvmTopView::calculRect()
{
    qreal x = INTER_NAME_X;
    qreal y = INTER_NAME_Y;
    rect = QRectF(0,0,0,0);
    rect.setWidth(QApplication::fontMetrics().boundingRect(getTypeName()).width()+15);

    UvmTestCase* testCase = ((UvmTop*)model)->getTestCase();
    UvmDesign* design = ((UvmTop*)model)->getDesign();
    UvmInterface* uInterface = ((UvmTop*)model)->getInterface();

    UvmTestCaseView* testCaseView = (UvmTestCaseView*)getComponentView(testCase);
    if(testCaseView != 0) {
        testCaseView->calculRect();
        testCaseView->setPos(x, y);
        y += testCaseView->boundingRect().height()+INTER_Y;
        x += testCaseView->boundingRect().width();

        UvmInterfaceView* interfaceView = (UvmInterfaceView*)getComponentView(uInterface);
        if(interfaceView != 0) {
            interfaceView->calculRect();
            interfaceView->setPos(x/2-interfaceView->boundingRect().width()/2, y);
            y += interfaceView->boundingRect().height()+INTER_Y;
        }

        UvmDesignView* designView = (UvmDesignView*)getComponentView(design);
        if(interfaceView != 0) {
            designView->calculRect();
            designView->setPos(x/2-designView->boundingRect().width()/2, y);
            y += designView->boundingRect().height()+INTER_Y;
        }
    }

    y = y-INTER_Y+INTER_Y_END;
    x += INTER_X_END;

    rect = QRectF(0, 0, x, y);
    rect = placeAccessors(rect);
    placePorts();
}
Example #22
0
int PlainObject::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;

#ifndef QT_NO_PROPERTIES
    if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0:
            *reinterpret_cast< QString*>(_v) = getTypeName();
            break;
        case 1:
            *reinterpret_cast< void**>(_v) = getValueAddr();
            break;
        }
        _id -= 2;
    } else if (_c == QMetaObject::WriteProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    } else if (_c == QMetaObject::RegisterPropertyMetaType) {
        if (_id < 2)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #23
0
const ConstantUnion* TOutputGLSLBase::writeConstantUnion(const TType& type,
                                                         const ConstantUnion* pConstUnion)
{
    TInfoSinkBase& out = objSink();

    if (type.getBasicType() == EbtStruct)
    {
        out << type.getTypeName() << "(";
        const TTypeList* structure = type.getStruct();
        ASSERT(structure != NULL);
        for (size_t i = 0; i < structure->size(); ++i)
        {
            const TType* fieldType = (*structure)[i].type;
            ASSERT(fieldType != NULL);
            pConstUnion = writeConstantUnion(*fieldType, pConstUnion);
            if (i != structure->size() - 1) out << ", ";
        }
        out << ")";
    }
    else
    {
        int size = type.getObjectSize();
        bool writeType = size > 1;
        if (writeType) out << getTypeName(type) << "(";
        for (int i = 0; i < size; ++i, ++pConstUnion)
        {
            switch (pConstUnion->getType())
            {
                case EbtFloat: out << pConstUnion->getFConst(); break;
                case EbtInt: out << pConstUnion->getIConst(); break;
                case EbtBool: out << pConstUnion->getBConst(); break;
                default: UNREACHABLE();
            }
            if (i != size - 1) out << ", ";
        }
        if (writeType) out << ")";
    }
    return pConstUnion;
}
void StorageSystemModels::fillData(MutableColumns & res_columns, const Context & context, const SelectQueryInfo &) const
{
    const auto & external_models = context.getExternalModels();
    auto objects_map = external_models.getObjectsMap();
    const auto & models = objects_map.get();

    for (const auto & model_info : models)
    {
        res_columns[0]->insert(model_info.first);
        res_columns[1]->insert(model_info.second.origin);

        if (model_info.second.loadable)
        {
            const auto model_ptr = std::static_pointer_cast<IModel>(model_info.second.loadable);

            res_columns[2]->insert(model_ptr->getTypeName());
            res_columns[3]->insert(static_cast<UInt64>(std::chrono::system_clock::to_time_t(model_ptr->getCreationTime())));
        }
        else
        {
            res_columns[2]->insertDefault();
            res_columns[3]->insertDefault();
        }

        if (model_info.second.exception)
        {
            try
            {
                std::rethrow_exception(model_info.second.exception);
            }
            catch (...)
            {
                res_columns[4]->insert(getCurrentExceptionMessage(false));
            }
        }
        else
            res_columns[4]->insertDefault();
    }
}
Example #25
0
template <ExceptionStyle S> Box* tupleGetitem(BoxedTuple* self, Box* slice) {
    if (S == CAPI) {
        try {
            return tupleGetitem<CXX>(self, slice);
        } catch (ExcInfo e) {
            setCAPIException(e);
            return NULL;
        }
    }

    assert(isSubclass(self->cls, tuple_cls));

    if (PyIndex_Check(slice)) {
        Py_ssize_t i = PyNumber_AsSsize_t(slice, PyExc_IndexError);
        if (i == -1 && PyErr_Occurred())
            throwCAPIException();
        return tupleGetitemUnboxed(self, i);
    } else if (slice->cls == slice_cls)
        return tupleGetitemSlice(self, static_cast<BoxedSlice*>(slice));
    else
        raiseExcHelper(TypeError, "tuple indices must be integers, not %s", getTypeName(slice));
}
Example #26
0
bool JucerDocument::loadFromXml (const XmlElement& xml)
{
    if (xml.hasTagName (jucerCompXmlTag)
         && getTypeName().equalsIgnoreCase (xml.getStringAttribute ("documentType")))
    {
        className = xml.getStringAttribute ("className", defaultClassName);
        templateFile = xml.getStringAttribute ("template", String::empty);
        componentName = xml.getStringAttribute ("componentName", String::empty);
        parentClasses = xml.getStringAttribute ("parentClasses", defaultParentClasses);
        constructorParams = xml.getStringAttribute ("constructorParams", String::empty);
        variableInitialisers = xml.getStringAttribute ("variableInitialisers", String::empty);

        fixedSize = xml.getBoolAttribute ("fixedSize", false);
        initialWidth = xml.getIntAttribute ("initialWidth", 300);
        initialHeight = xml.getIntAttribute ("initialHeight", 200);

        snapGridPixels = xml.getIntAttribute ("snapPixels", snapGridPixels);
        snapActive = xml.getBoolAttribute ("snapActive", snapActive);
        snapShown = xml.getBoolAttribute ("snapShown", snapShown);

        componentOverlayOpacity = (float) xml.getDoubleAttribute ("overlayOpacity", 0.0);

        activeExtraMethods.clear();

        if (XmlElement* const methods = xml.getChildByName ("METHODS"))
            forEachXmlChildElementWithTagName (*methods, e, "METHOD")
                activeExtraMethods.addIfNotAlreadyThere (e->getStringAttribute ("name"));

        activeExtraMethods.trim();
        activeExtraMethods.removeEmptyStrings();

        changed();
        getUndoManager().clearUndoHistory();
        return true;
    }

    return false;
}
Example #27
0
Box* tupleMul(BoxedTuple* self, Box* rhs) {
    if (rhs->cls != int_cls) {
        raiseExcHelper(TypeError, "can't multiply sequence by non-int of type '%s'", getTypeName(rhs));
    }

    int n = static_cast<BoxedInt*>(rhs)->n;
    int s = self->size();

    if (n < 0)
        n = 0;

    if (s == 0 || n == 1) {
        return self;
    } else {
        BoxedTuple* rtn = BoxedTuple::create(n * s);
        int rtn_i = 0;
        for (int i = 0; i < n; ++i) {
            memmove(&rtn->elts[rtn_i], &self->elts[0], sizeof(Box*) * s);
            rtn_i += s;
        }
        return rtn;
    }
}
Example #28
0
QString JavaCodeClassField::getInitialValue()
{
    if (parentIsAttribute())
    {
        UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
        if (at) {
            return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
        } else {
            uError() << "parent object is not a UMLAttribute";
            return QString();
        }
    }
    else
    {
        if(fieldIsSingleValue()) {
            // FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1,
            //       then we can just return 'empty' string (minor problem).
            return QString();
        } else {
            return QLatin1String(" new ") + JavaCodeGenerator::getListFieldClassName() + QLatin1String("()");
        }
    }
}
Example #29
0
bool CODEJoint::init(dWorld& world, dJointGroupID groupID)
{
	create(world, groupID);
	if (mID != 0)
	{
		if (!assertAnchors())
		{
			mLogErrorLn("CODEJoint::init() failed because one or both anchors were NULL!");
			return false;
		}

		mLogDebugLn("Created " << getTypeName() << "-joint \"" << name() << "\"!");
		// Connect the bodies: move them into place and notify both bodies that they are connected to each other
		connectBodies();
		// Attach bodies to the joint
		dJointAttach(mID, mpBodyAnchors[0]->body()->id(), mpBodyAnchors[1]->body()->id());
		setParams();
	}
	else
		mLogErrorLn("Trying to initialize joint that failed to be created! Check your configuration.");

	return mID != 0;
}
Example #30
0
 /*public*/ void Engine::propertyChange(PropertyChangeEvent* e)
 {
  RollingStock::propertyChange(e);

  if (e->getPropertyName()==(EngineTypes::ENGINETYPES_NAME_CHANGED_PROPERTY)) {
      if (e->getOldValue()==(getTypeName())) {
          if (log->isDebugEnabled()) {
              log->debug(tr("Loco (%1 %2) sees type name change old: (%3) new: (%4)").arg(toString()).arg(e->getOldValue().toString()).arg(e
                      ->getNewValue().toString())); // NOI18N
          }
          setTypeName(e->getNewValue().toString());
      }
  }
  if (e->getPropertyName()==(EngineLengths::ENGINELENGTHS_NAME_CHANGED_PROPERTY)) {
      if (e->getOldValue().toString()==(getLength())) {
          if (log->isDebugEnabled()) {
              log->debug(tr("Loco (%1) sees length name change old: %2 new: %3").arg(toString()).arg(e->getOldValue().toString()).arg(e
                      ->getNewValue().toString())); // NOI18N
          }
          setLength( e->getNewValue().toString());
      }
  }
 }