Handle<Value> TiAppPropertiesObject::_get(const Arguments& args, PropertyType type)
{
    HandleScope scope;

    Local<Value> k = args[0], defaultValue = args[1];

    // If key is undefined or null do nothing.
    if (k->IsUndefined() || k->IsNull()) {
        return Undefined();
    }

    // Lookup property value from the application settings.
    QString key = QString::fromUtf8(*String::Utf8Value(k));
    QVariant value = settings.value(key);
    if (value.isValid()) {
        // Parse JSON value and return value as type requested by caller.
        return scope.Close(convertType(type, parseJson(value.toString())));
    }

    // Fallback to default settings if no property found.
    value = defaultSettings.value(key);
    if (value.isValid()) {
        // The default property values should be valid strings, not JSON.
        // We still must convert the type if the user requests a non-string type.
        Q_ASSERT(value.canConvert(QVariant::String));
        return scope.Close(convertType(type, String::New(value.toString().toUtf8())));
    }

    return defaultValue;
}
Handle<Value> TiAppPropertiesObject::_set(const Arguments& args, PropertyType type)
{
    HandleScope scope;

    Local<Value> key = args[0], value = args[1];

    if (key->IsUndefined() || key->IsNull()) {
        return Undefined();
    }

    // Remove property if value is set to null or undefined.
    if (value->IsUndefined() || value->IsNull()) {
        settings.remove(QString::fromUtf8(*String::Utf8Value(key)));
        return Undefined();
    }

    // Serialize the property value to JSON.
    Local<String> json = stringify(convertType(type, value));

    // Update the application settings with the new property value.
    settings.setValue(QString::fromUtf8(*String::Utf8Value(key)),
                      QString::fromUtf8(*String::Utf8Value(json)));

    return Undefined();
}
예제 #3
0
void ConvertVarType( char *typebuf, char *arraybuf, id_type id, ArrayInfo *array ) {
/***************************************************************************/

    char        *type;

    if( _BaseType( id ) == TY_STRING ) {
        type = "String";
    } else {
        type = convertType( id );
    }
    formatType( typebuf, arraybuf, "", type, _IsRefType( id ), array );
}
예제 #4
0
const IR::Type* ReplacementMap::convertType(const IR::Type* type) {
    auto it = replacement.find(type);
    if (it != replacement.end())
        return it->second;
    if (type->is<IR::Type_Struct>()) {
        auto st = type->to<IR::Type_Struct>();
        bool changes = false;
        IR::IndexedVector<IR::StructField> fields;
        for (auto f : st->fields) {
            auto ftype = typeMap->getType(f);
            auto cftype = convertType(ftype);
            if (cftype != ftype)
                changes = true;
            auto field = new IR::StructField(f->name, f->annotations, cftype->getP4Type());
            fields.push_back(field);
        }
        if (changes) {
            auto result = new IR::Type_Struct(st->srcInfo, st->name, st->annotations, fields);
            LOG3("Converted " << dbp(type) << " to " << dbp(result));
            replacement.emplace(type, result);
            return result;
        } else {
            return type;
        }
    } else if (type->is<IR::Type_Tuple>()) {
        cstring name = ng->newName("tuple");
        IR::IndexedVector<IR::StructField> fields;
        for (auto t : type->to<IR::Type_Tuple>()->components) {
            auto ftype = convertType(t);
            auto fname = ng->newName("field");
            auto field = new IR::StructField(IR::ID(fname), ftype->getP4Type());
            fields.push_back(field);
        }
        auto result = new IR::Type_Struct(name, fields);
        LOG3("Converted " << dbp(type) << " to " << dbp(result));
        replacement.emplace(type, result);
        return result;
    }
    return type;
}
예제 #5
0
int exprWidth(ACCExpr *expr, bool forceNumeric)
{
    if (!expr)
        return 0;
    std::string op = expr->value;
    if (relationalOp(op))
        return 1;
    if (isdigit(op[0])) {
        int ind = op.find("'");
        if (ind > 0) {
            std::string temp = op.substr(0, ind);
            return atoi(temp.c_str());
        }
        else if (forceNumeric)
            return 1;
    }
    if (isIdChar(op[0])) {
        ACCExpr *lhs = getRHS(expr, 0);
        if (lhs && lhs->value == "[" && lhs->operands.size() > 0) {
            ACCExpr *first = getRHS(lhs, 0);
            if (first->value == ":") {
                ACCExpr *second = getRHS(first);
                first = getRHS(first, 0);
                if (!second)
                    return 1;
                if (isdigit(first->value[0]) && isdigit(second->value[0]))
                    return atoi(first->value.c_str()) - atoi(second->value.c_str()) + 1;
            }
            else if (isdigit(first->value[0]))
                return 1;
        }
        return convertType(refList[op].type);
    }
    if (op == "?") {
        if (int len = exprWidth(getRHS(expr, 1), forceNumeric))
            return len;
        if (int len = exprWidth(getRHS(expr, 2), forceNumeric))
            return len;
    }
    if (op == "&" || op == "|" || op == "^") {
        for (auto item: expr->operands)
            if (exprWidth(item, forceNumeric) != 1)
                goto nextand;
        return 1;
nextand:;
    }
    if (op == "!") {
        return exprWidth(expr->operands.front(), forceNumeric);
    }
    return 0;
}
예제 #6
0
void ConvertParmType( char *buf, char *name, id_type id, ArrayInfo *array ) {
/**************************************************************************/

    char        *type;
    char        arraybuf[30];

    if( _BaseType( id ) == TY_STRING && array == NULL && _IsRefType( id ) ) {
        type = "char";
    } else {
        type = convertType( id );
    }
    formatType( buf, arraybuf, name, type, _IsRefType( id ), array );
    strcat( buf, arraybuf );
}
예제 #7
0
파일: AcDc.c 프로젝트: haiwei624/data
void checkexpression( Expression * expr, SymbolTable * table ,HashTable *Htable)//changed
{
    IdName c;
    if(expr->leftOperand == NULL && expr->rightOperand == NULL){
        switch(expr->v.type){
            case Identifier:
                //c = expr->v.val.id;
				strcpy(c, expr->v.val.id);
                printf("identifier : %s\n",c);
                expr->type = lookup_table(table, c,Htable);
                break;
            case IntConst:
                printf("constant : int\n");
                expr->type = Int;
                break;
            case FloatConst:
                printf("constant : float\n");
                expr->type = Float;
                break;
                //case PlusNode: case MinusNode: case MulNode: case DivNode:
            default:
                break;
        }
    }
    else{
        Expression *left = expr->leftOperand;
        Expression *right = expr->rightOperand;

        checkexpression(left, table,Htable);
        checkexpression(right, table,Htable);

        DataType type = generalize(left, right);
        convertType(left, type);//left->type = type;//converto
        convertType(right, type);//right->type = type;//converto
        expr->type = type;
    }
}
예제 #8
0
void checkexpression( Expression * expr, SymbolTable * table )
{
    char name[256];
    if(expr->leftOperand == NULL && expr->rightOperand == NULL){
        switch(expr->v.type){
            case Identifier:
                strcpy(name, expr->v.val.id);
                expr->v.val.regId = variableToRegister(table, name); 
                printf("identifier : %s(%c)\n", name, expr->v.val.regId);
                expr->type = lookup_table(table, name);
                break;
            case IntConst:
                printf("constant : int\n");
                expr->type = Int;
                break;
            case FloatConst:
                printf("constant : float\n");
                expr->type = Float;
                break;
                //case PlusNode: case MinusNode: case MulNode: case DivNode:
            default:
                break;
        }
    }
    else{
        Expression *left = expr->leftOperand;
        Expression *right = expr->rightOperand;

        checkexpression(left, table);
        checkexpression(right, table);

        DataType type = generalize(left, right);
        convertType(left, type);//left->type = type;//converto
        convertType(right, type);//right->type = type;//converto
        expr->type = type;
    }
}
예제 #9
0
bool ShaderProgram::useAttributeArray(const std::string& name, int offset,
                                      size_t stride, Type elementType,
                                      int elementTupleSize,
                                      NormalizeOption normalize)
{
  GLint location = static_cast<GLint>(findAttributeArray(name));
  if (location == -1) {
    m_error = "Could not use attribute " + name + ". No such attribute.";
    return false;
  }
  glVertexAttribPointer(location, elementTupleSize, convertType(elementType),
                        normalize == Normalize ? GL_TRUE : GL_FALSE,
                        static_cast<GLsizei>(stride), BUFFER_OFFSET(offset));
  return true;
}
예제 #10
0
bool ShaderProgram::setAttributeArrayInternal(
  const std::string& name, void* buffer, Avogadro::Type type, int tupleSize,
  ShaderProgram::NormalizeOption normalize)
{
  if (type == Avogadro::UnknownType) {
    m_error = "Unrecognized data type for attribute " + name + ".";
    return false;
  }
  GLint location = static_cast<GLint>(findAttributeArray(name));
  if (location == -1) {
    m_error = "Could not set attribute " + name + ". No such attribute.";
    return false;
  }
  const GLvoid* data = static_cast<const GLvoid*>(buffer);
  glVertexAttribPointer(location, tupleSize, convertType(type),
                        normalize == Normalize ? GL_TRUE : GL_FALSE, 0, data);
  return true;
}
예제 #11
0
파일: AcDc.c 프로젝트: haiwei624/data
void checkstmt( Statement *stmt, SymbolTable * table, HashTable *Htable)//changed
{
    if(stmt->type == Assignment){
        AssignmentStatement assign = stmt->stmt.assign;
        printf("assignment : %s \n",assign.id);//changed
        checkexpression(assign.expr, table,Htable);
        stmt->stmt.assign.type = lookup_table(table, assign.id,Htable);
        if (assign.expr->type == Float && stmt->stmt.assign.type == Int) {
            printf("error : can't convert float to integer\n");
        } else {
            convertType(assign.expr, stmt->stmt.assign.type);
        }
    }
    else if (stmt->type == Print){
        printf("print : %s \n",stmt->stmt.variable);//changed
        lookup_table(table, stmt->stmt.variable, Htable);
    }
    else printf("error : statement error\n");//error
}
예제 #12
0
bool GwfTranslator::processString(const String &data)
{
    tinyxml2::XMLDocument doc;
    tinyxml2::XMLError error = doc.Parse(data.c_str());

    if (error != tinyxml2::XML_SUCCESS)
    {
        THROW_EXCEPT(Exception::ERR_PARSE,
                     doc.GetErrorStr2(),
                     mParams.fileName,
                     -1);
    }

    tinyxml2::XMLElement *root = doc.FirstChildElement("GWF");
    if (!root)
    {
        THROW_EXCEPT(Exception::ERR_PARSE,
                     "Can't find root element",
                     mParams.fileName,
                     -1);
    }
    root = root->FirstChildElement("staticSector");
    if (!root)
    {
        THROW_EXCEPT(Exception::ERR_PARSE,
                     "Cna't find static sector",
                     mParams.fileName,
                     -1);
    }

    // collect elements
    std::vector<tinyxml2::XMLElement*> nodes;
    std::vector<tinyxml2::XMLElement*> edges;
    std::vector<tinyxml2::XMLElement*> buses;
    std::vector<tinyxml2::XMLElement*> all;

    static std::string s_arc = "arc";
    static std::string s_pair = "pair";
    static std::string s_bus = "bus";

    tinyxml2::XMLElement *el = root->FirstChildElement();
    while (el)
    {
        all.push_back(el);
        if (el->Name() == s_arc || el->Name() == s_pair)
            edges.push_back(el);
        else if (el->Name() == s_bus)
            buses.push_back(el);
        else
            nodes.push_back(el);

        el = el->NextSiblingElement();
    }

    static std::string s_node = "node";
    static std::string s_contour = "contour";

    tStringAddrMap id_map;
    tStringAddrMap::iterator itId;

    // create all nodes
    std::vector<tinyxml2::XMLElement*>::iterator it, itEnd = nodes.end();
    for (it = nodes.begin(); it != itEnd; ++it)
    {
        el = *it;

        String idtf = el->Attribute("idtf");
        String id = el->Attribute("id");
        sc_addr addr;

        itId = id_map.find(id);
        if (itId != id_map.end())
            continue;

        if (idtf.size() > 0)
        {
            if (getScAddr(idtf, addr))
            {
                id_map[id] = addr;
                continue;    // skip elements that already exists
            }
        }

        if (el->Name() == s_contour)
        {
            addr = sc_memory_node_new(sc_type_const | sc_type_node_struct);
            appendScAddr(addr, idtf);
        } else
        {
            tinyxml2::XMLElement *content = el->FirstChildElement("content");
            if (!content)
            {
                THROW_EXCEPT(Exception::ERR_PARSE,
                             "There are no child content for node with id=" + id,
                             mParams.fileName,
                             -1);
            }

            if (content->IntAttribute("type") == 0)
            {
                addr = sc_memory_node_new(convertType(el->Attribute("type")));
                appendScAddr(addr, idtf);
            } else
            {
                // need to create link
                addr = sc_memory_link_new();
                // setup content
                String data = content->GetText();

                if (content->IntAttribute("type") == 4)
                    data = base64_decode(data);

                sc_stream *stream = sc_stream_memory_new(data.c_str(), data.size(), SC_STREAM_READ, SC_FALSE);
                sc_memory_set_link_content(addr, stream);
                sc_stream_free(stream);

                if (mParams.autoFormatInfo)
                {
                    String ext = StringUtil::getFileExtension(content->Attribute("file_name"));
                    if (!ext.empty())
                        generateFormatInfo(addr, ext);
                }
            }
        }

        if (!idtf.empty())
            sc_helper_set_system_identifier(addr, idtf.c_str(), idtf.size());

        id_map[id] = addr;
    }

    // process buses
    itEnd = buses.end();
    for (it = buses.begin(); it != itEnd; ++it)
    {
        el = *it;

        tStringAddrMap::iterator itOwner = id_map.find(el->Attribute("owner"));
        if (itOwner == id_map.end())
            continue;

        id_map[el->Attribute("id")] = itOwner->second;
    }

    // now create edges
    bool created = true;
    while (created)
    {
        created = false;

        itEnd = edges.end();
        for (it = edges.begin(); it != itEnd; ++it)
        {
            el = *it;

            sc_addr addr;
            String id = el->Attribute("id");
            String idtf = el->Attribute("idtf");

            if (id_map.find(id) != id_map.end())
                continue;

            if (getScAddr(idtf, addr))
                continue;

            // get begin and end elements
            tStringAddrMap::iterator itB = id_map.find(el->Attribute("id_b"));
            if (itB == id_map.end())
                continue;

            tStringAddrMap::iterator itE = id_map.find(el->Attribute("id_e"));
            if (itE == id_map.end())
                continue;

            // create arc
            created = true;
            addr = sc_memory_arc_new(convertType(el->Attribute("type")), itB->second, itE->second);
            appendScAddr(addr, idtf);
            id_map[id] = addr;

            if (!idtf.empty())
                sc_helper_set_system_identifier(addr, idtf.c_str(), idtf.size());
        }
    }

    // now append elemnts into contours
    itEnd = all.end();
    for (it = all.begin(); it != itEnd; ++it)
    {
        el = *it;

        tStringAddrMap::iterator itSelf = id_map.find(el->Attribute("id"));
        if (itSelf == id_map.end())
            continue;

        tStringAddrMap::iterator itP = id_map.find(el->Attribute("parent"));
        if (itP == id_map.end())
            continue;

        sc_memory_arc_new(sc_type_arc_pos_const_perm, itP->second, itSelf->second);
    }

    return false;
}
예제 #13
0
PluginInputDomainAdapter::Impl::Impl(Plugin *plugin, float inputSampleRate) :
    m_plugin(plugin),
    m_inputSampleRate(inputSampleRate),
    m_channels(0),
    m_stepSize(0),
    m_blockSize(0),
    m_freqbuf(0),
    m_ri(0),
    m_windowType(HanningWindow),
    m_window(0),
    m_method(ShiftTimestamp),
    m_processCount(0),
    m_shiftBuffers(0),
#ifdef HAVE_FFTW3
    m_plan(0),
    m_cbuf(0)
#else
    m_ro(0),
    m_io(0)
#endif
{
}

PluginInputDomainAdapter::Impl::~Impl()
{
    // the adapter will delete the plugin

    if (m_shiftBuffers) {
        for (int c = 0; c < m_channels; ++c) {
            delete[] m_shiftBuffers[c];
        }
        delete[] m_shiftBuffers;
    }

    if (m_channels > 0) {
        for (int c = 0; c < m_channels; ++c) {
            delete[] m_freqbuf[c];
        }
        delete[] m_freqbuf;
#ifdef HAVE_FFTW3
        if (m_plan) {
            fftw_destroy_plan(m_plan);
            fftw_free(m_ri);
            fftw_free(m_cbuf);
            m_plan = 0;
        }
#else
        delete[] m_ri;
        delete[] m_ro;
        delete[] m_io;
#endif

        delete m_window;
    }
}

// for some visual studii apparently
#ifndef M_PI
#define M_PI 3.14159265358979232846
#endif

bool
PluginInputDomainAdapter::Impl::initialise(size_t channels, size_t stepSize, size_t blockSize)
{
    if (m_plugin->getInputDomain() == TimeDomain) {

        m_stepSize = int(stepSize);
        m_blockSize = int(blockSize);
        m_channels = int(channels);

        return m_plugin->initialise(channels, stepSize, blockSize);
    }

    if (blockSize < 2) {
        std::cerr << "ERROR: PluginInputDomainAdapter::initialise: blocksize < 2 not supported" << std::endl;
        return false;
    }

    if (blockSize & (blockSize-1)) {
        std::cerr << "ERROR: PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl;
        return false;
    }

    if (m_channels > 0) {
        for (int c = 0; c < m_channels; ++c) {
            delete[] m_freqbuf[c];
        }
        delete[] m_freqbuf;
#ifdef HAVE_FFTW3
        if (m_plan) {
            fftw_destroy_plan(m_plan);
            fftw_free(m_ri);
            fftw_free(m_cbuf);
            m_plan = 0;
        }
#else
        delete[] m_ri;
        delete[] m_ro;
        delete[] m_io;
#endif
        delete m_window;
    }

    m_stepSize = int(stepSize);
    m_blockSize = int(blockSize);
    m_channels = int(channels);

    m_freqbuf = new float *[m_channels];
    for (int c = 0; c < m_channels; ++c) {
        m_freqbuf[c] = new float[m_blockSize + 2];
    }

    m_window = new Window<double>(convertType(m_windowType), m_blockSize);

#ifdef HAVE_FFTW3
    m_ri = (double *)fftw_malloc(blockSize * sizeof(double));
    m_cbuf = (fftw_complex *)fftw_malloc((blockSize/2 + 1) * sizeof(fftw_complex));
    m_plan = fftw_plan_dft_r2c_1d(blockSize, m_ri, m_cbuf, FFTW_MEASURE);
#else
    m_ri = new double[m_blockSize];
    m_ro = new double[m_blockSize];
    m_io = new double[m_blockSize];
#endif

    m_processCount = 0;

    return m_plugin->initialise(channels, stepSize, blockSize);
}

void
PluginInputDomainAdapter::Impl::reset()
{
    m_processCount = 0;
    m_plugin->reset();
}
예제 #14
0
void checkexpression( Expression * expr, SymbolTable * table )
{
    char *c;
    if(expr->leftOperand == NULL && expr->rightOperand == NULL){
        switch(expr->v.type){
            case Identifier:
                c = expr->v.val.id;
                printf("identifier : %s\n",c);
                expr->type = lookup_table(table, c);
                break;
            case IntConst:
                printf("constant : int\n");
                expr->type = Int;
                break;
            case FloatConst:
                printf("constant : float\n");
                expr->type = Float;
                break;
                //case PlusNode: case MinusNode: case MulNode: case DivNode:
            default:
                break;
        }
    }
    else if (expr->rightOperand == NULL){
        checkexpression(expr->leftOperand, table);
        expr->type = expr->leftOperand->type;
    }
	else{
        Expression *left = expr->leftOperand;
        Expression *right = expr->rightOperand;

        checkexpression(left, table);
        checkexpression(right, table);

        DataType type = generalize(left, right);
        convertType(left, type);//left->type = type;//converto
        convertType(right, type);//right->type = type;//converto
        expr->type = type;
		//	constant folding
		switch (expr->v.type) {
            case PlusNode: case MinusNode: case MulNode: case DivNode:
			    if (type == Int && left->v.type == IntConst && right->v.type == IntConst) {
                    int *a = &left->v.val.ivalue;
					int *b = &right->v.val.ivalue; 
                    int *c = &expr->v.val.ivalue;
					char op;
                    // c = a <op> b
                    switch (expr->v.type) {
                        case PlusNode:
							*c = *a + *b; 
							op = '+'; 
							break;
                        case MinusNode: 
							*c = *a - *b; 
							op = '-'; 
							break;
                        case MulNode:   
							*c = *a * *b; 
							op = '*'; 
							break;
                        case DivNode:   
							*c = *a / *b; 
							op = '/'; 
							break;
                        default: 
							break;
                    }
                    expr->v.type = IntConst;
                    expr->leftOperand = expr->rightOperand = NULL;
                    printf("After constant folding: %d %c %d = %d\n", *a, op, *b, *c);
                }
                else if (type == Float && left->v.type == FloatConst && right->v.type == FloatConst) {
                    float *a = &left->v.val.fvalue;
					float *b = &right->v.val.fvalue; // c = a <op> b
                    float *c = &expr->v.val.fvalue;
                    char op;
                    switch (expr->v.type) {
                        case PlusNode:
							*c = *a + *b; 
							op = '+'; 
							break;
                        case MinusNode: 
							*c = *a - *b; 
							op = '-'; 
							break;
                        case MulNode:   
							*c = *a * *b; 
							op = '*'; 
							break;
                        case DivNode:   
							*c = *a / *b; 
							op = '/'; 
							break;
                        default: 
							break;
                    }
                    expr->v.type = FloatConst;
                    expr->leftOperand = expr->rightOperand = NULL;
                    printf("After constant folding: %f %c %f = %f\n", *a, op, *b, *c);
                }
                break;
            default:
                break;
        }
    }
}
예제 #15
0
const IR::Type_Struct* ReplacementMap::getReplacement(const IR::Type_Tuple* tt) {
    auto st = convertType(tt)->to<IR::Type_Struct>();
    CHECK_NULL(st);
    replacement.emplace(tt, st);
    return st;
}
예제 #16
0
TileObjectBattleMapPart::TileObjectBattleMapPart(TileMap &map, sp<BattleMapPart> map_part)

    : TileObject(map, convertType(map_part->type->type), Vec3<float>{1.0f, 1.0f, 1.0f}),
      map_part(map_part)
{
}
bool CUniformParameterBuilder::build()
{
	//assert(mEffectVariable);

	// building the uniform based on the type
	// ---------------------------------------
	MUniformParameter::DataType		type		= convertType    ();
	MUniformParameter::DataSemantic semantic	= convertSemantic();

	updateLightInfoFromSemantic();

	// If we don't know what this parameter is, and we've been told to hide it, do so
	// NOTE that for now, we only hide simple constants as hiding everything we're
	// told to hide actually starts hiding textures and things the artist wants to see.
	// ----------------------------------------------------------------------------------
	if (semantic == MUniformParameter::kSemanticUnknown && (type == MUniformParameter::kTypeFloat || type == MUniformParameter::kTypeString))
	{

		if (mDesc.Semantic && _stricmp(mDesc.Semantic, dx11ShaderSemantic::kSTANDARDSGLOBAL)==0)
		{
			return false;
		}
	}

	/*
		The UIGroup annotation is used to groups multiple parameters in a single
		collapsible panel in the attribute editor. This helps organize related
		parameters.

		- All parameters sharing the same UIGroup annotation string will group together
		- The name of the group, as shown as the header of the collapsible panel, will
		   be the value of the annotation
		- The order of the panels in the attribute editor will be sorted according to
			the parameter with the lowest UIOrder in that group
		- UIGroups win over UIOrder, this means all parameters will be grouped in a
			single panel even if there are non grouped parameters that have a UIOrder
			that falls within the range of UIOrders for parameters in that group
		- This commands lists all UIGroups: dx11Shader -listUIGroupInformation
		- This command lists all parameters for a group: dx11Shader -listUIGroupParameters <group>
	*/
	if (mUIGroupIndex == -1)
	{
		LPCSTR pszUIGroupName;
		if( getAnnotation( dx11ShaderAnnotation::kUIGroup, pszUIGroupName) && *pszUIGroupName)
		{
			MString uiGroupName(pszUIGroupName);
			mUIGroupIndex = mShader->getIndexForUIGroupName(uiGroupName, true);
		}
	}

	/*
		The name of the parameter in the attribute editor defaults to
		the name of the variable associated with the parameter. If there
		is a UIName attribute on the parameter, and the 'kVariableNameAsAttributeName'
		semantic is not set, this name will be used to
		define all three of the parameter short/long/nice name. If the
		UIName contains spaces or other script unfriendly characters,
		those will be replaced by underscores in the short and long names
		used in scripting.

		Using UIName as attribute name can lead to ambiguity since UIName annotations 
		are not required to be unique by the compiler. The MPxHardwareShader class
		will add numbers at the end of the short/long names as required to
		make them unique.
	*/
	LPCSTR paramName = NULL;

	bool varAsAttr = false;
	if (mShader)
		varAsAttr = mShader->getVariableNameAsAttributeName();

	LPCSTR uiName = NULL ;
	bool hasUIName = getAnnotation( dx11ShaderAnnotation::kUIName, uiName);

	if( varAsAttr || !hasUIName )
		paramName = mDesc.Name;
	else
		paramName = uiName;

	/*
		If an integer parameter has a UIFieldNames annotation, then the
		annotation contents will be used to populate a dropdown menu when the
		parameter is shown in the attribute editor. The parameter type is
		changed from integer to enum.
	*/
	LPCSTR uiFieldNames = NULL ;
	MString fieldNames;
	if(type == MUniformParameter::kTypeInt && getAnnotation(dx11ShaderAnnotation::kUIFieldNames,uiFieldNames) && uiFieldNames)
	{
		fieldNames = uiFieldNames;
		type = MUniformParameter::kTypeEnum;
	}

	MUniformParameter uniform( paramName, type, semantic, mDescType.Rows, mDescType.Columns, (void*)mEffectVariable);
	mParam = uniform;

	// If shader author has specified to use var as attribute name and provided a UIName, then
	// tell Maya to use the UIName for the attribute's 'Nice Name':
	if (varAsAttr && hasUIName)
		mParam.setUINiceName( uiName );

	updateRangeFromAnnotation();
	updateUIVisibilityFromAnnotation();
	if (fieldNames.length())
	{
		mParam.setEnumFieldNames(fieldNames);
	}

	/*
		The UIOrder annotation can be used to make sure all parameters
		appear in a predictable sequence in the attribute editors even
		if the compiler decides to reorder them is the input block.

		- The content of the annotation is an integer
		- Parameters will be sorted according to increasing values of
		  UIOrder annotation
		- The sort is stable, so parameters with identical UIOrder will
		  appear in the order the compiler outputs them (which is not as
		  stable as the sort)
	*/
	getAnnotation(dx11ShaderAnnotation::kUIOrder, mUIOrder);

	// set keyable for visible attributes other than textures
	mParam.setKeyable(!mParam.UIHidden() && !mParam.isATexture());

	bool result = setParameterValueFromEffect();
	if(result)
	{
		mValidUniformParameter = true;
	}

	return result;
}
예제 #18
0
파일: deck.cpp 프로젝트: whazell/21Bot
/*
* Card() - Generates a card based on given type
*/
Card::Card (char t, int id) {
	type  = t;
	value = convertType(t);
	ID    = id;		
}
BattleTileObjectMapPart::BattleTileObjectMapPart(BattleTileMap &map, sp<BattleMapPart> map_part)
    : BattleTileObject(map, convertType(map_part->type->type), Vec3<float>{1, 1, 1}),
      map_part(map_part)
{
}
예제 #20
0
char *ConvertRetType( id_type id ) {
/***********************************/
    return( convertType( id ) );
}