Exemplo n.º 1
0
void readMatrix(const std::string& filename, std::vector<T>& A, size_t& m, size_t& n) {
  std::ifstream f;
  f.exceptions(std::ofstream::failbit | std::ofstream::badbit);
  const char* type = getTypeString(A);

  f.open(filename.c_str(), std::ios::in | std::ios::binary);

  // header (size and type)
  f.read(reinterpret_cast<char*>(&m), sizeof(m));
  f.read(reinterpret_cast<char*>(&n), sizeof(n));

  char type2[17];
  f.read(type2, 16);
  type2[16] = 0;

  if (std::string(type) != std::string(type2)) {
    throw std::invalid_argument(
        "The type of the entries in the file "
        "differ from the type of the "
        "entries of A.");
  }

  A.empty();

  // entries
  for (size_t i = 0; i < m * n; i++) {
    T entry;
    readEntry(f, entry);
    A.push_back(entry);
  }
}
Exemplo n.º 2
0
inline static std::string toJson(const Item& item) {
	json::JsonObjectStreamWriter writer;
	const auto type = item.getType();
	writer << std::make_pair("type", getTypeString(type));
	if (type != Item::INVALID) {
		writer << std::make_pair("filename", item.filename.c_str());
		if (type != Item::SINGLE)
			writer << std::make_pair("padding", (int) item.padding);
		switch (type) {
		case Item::INDICED: {
			json::JsonArrayStreamWriter indices;
			for (const auto index : item.indices)
				indices << index;
			writer << std::make_pair("indices", indices.build());
			break;
		}
		case Item::PACKED:
			writer << std::make_pair("start", item.start);
			writer << std::make_pair("end", item.end);
			writer << std::make_pair("step", (int) item.step);
			break;
		default:
			break;
		}
	}
	return writer.build();
}
Exemplo n.º 3
0
QString pki_key::getMsg(msg_type msg)
{
	/*
	 * We do not construct english sentences (just a little bit)
	 * from fragments to allow proper translations.
	 * The drawback are all the slightly different duplicated messages
	 *
	 * %1 will be replaced by "RSA", "DSA", "EC"
	 * %2 is the internal name of the key
	 */
	QString ktype = getTypeString();
	if (isPubKey()) {
		switch (msg) {
		case msg_import: return tr("Successfully imported the %1 public key '%2'").arg(ktype);
		case msg_delete: return tr("Delete the %1 public key '%2'?").arg(ktype);
		default: break;
		}
	} else {
		switch (msg) {
		case msg_import: return tr("Successfully imported the %1 private key '%2'").arg(ktype);
		case msg_delete: return tr("Delete the %1 private key '%2'?").arg(ktype);
		case msg_create: return tr("Successfully created the %1 private key '%2'").arg(ktype);
		default: break;
		}
	}
	if (msg == msg_delete_multi) {
		/* %1: Number of keys; %2: list of keynames */
		return tr("Delete the %1 keys: %2?");
	}
	return pki_base::getMsg(msg);
}
bool CrossfireBreakpoint::toValueObject(Value** _value) {
	Value* result = new Value();
	result->addObjectValue(KEY_HANDLE, &Value((double)m_handle));
	result->addObjectValue(KEY_TYPE, &Value(getTypeString()));
	if (!m_contextId) {
		Value value_null;
		value_null.setType(TYPE_NULL);
		result->addObjectValue(KEY_CONTEXTID, &value_null);
	} else {
		result->addObjectValue(KEY_CONTEXTID, &Value(m_contextId));
	}

	Value value_attributes;
	value_attributes.setType(TYPE_OBJECT);
	std::map<std::wstring, Value*>::iterator iterator = m_attributes->begin();
	while (iterator != m_attributes->end()) {
		value_attributes.addObjectValue((std::wstring*)&iterator->first, iterator->second);
		iterator++;
	}
	result->addObjectValue(KEY_ATTRIBUTES, &value_attributes);

	Value* value_location = NULL;
	if (!getLocationAsValue(&value_location)) {
		delete result;
		return false;
	}
	result->addObjectValue(KEY_LOCATION, value_location);
	delete value_location;

	*_value = result;
	return true;
}
Exemplo n.º 5
0
TString buildArrayConstructorString(const TType& type) {
	std::stringstream constructor;
	constructor << getTypeString(translateType(&type))
				<< '[' << type.getArraySize() << ']';

	return TString(constructor.str().c_str());
}
Exemplo n.º 6
0
static int l_Message_getType(lua_State *L) {
    auto message = lua_tomessage(L, 1);
    enumMessageType messageType = message->getType();
    lua_pushstring(L, message->getTypeString().c_str());

    return 1;
}
Exemplo n.º 7
0
bool DumpWrapper<T>::CompareData(void * data, float threshold, OutputFormat output, size_t length , size_t stride ,size_t start)
{
  size_t size = getSize()/sizeof(T); 
  T * ptrA = (T*)getData();
  T * ptrB = (T*)data;
  size_t n = 0;
  double stddev = 0;
  size_t cnt = 0;   
  size_t i = start;
  size_t l = 0;
  size_t block = 0;

  if(length > stride) size = ( length+start <= size)?(length+start):(size);
  
  while(i < size){


    T diff = abs(ptrA[i] - ptrB[i]);
    double error = abs((double)diff/((ptrA[i] != 0)?(ptrA[i]):(1)));
    if(error>threshold || error != error ){//&& diff > 0.01 ){ 
     if(output > MIN) cout << i <<" " <<block << " " << l <<" " <<  ptrA[i] << " " << ptrB[i] << " " <<  (100.0*error) << "%" << " F" << endl;  
     n++;
     if(error == error) stddev += diff*diff; 
    }else{
     if(output==ALL) cout << i << " " <<block << " " << l <<" " <<  ptrA[i] << " " << ptrB[i] << " " <<  (100.0*error) << "%" << endl;  
     stddev += diff*diff; 
    }

    cnt++; 
    l++;

    if(length == l){
      l = 0;
      block ++;
      if(stride > length){
        i += stride - length; 
//        cout << endl;   
      }
      if(stride == length){
//        cout << endl;
      } 
    }

    i++;
  
  }
  
  stddev =   sqrt(stddev/cnt); 
  
   cout << "compare " << getName()<< " as " << getTypeString() << " relative error threshold of " << threshold  << " failed for "<< n << " out of " << cnt << " ( " << (100.0 *n)/((double)(cnt))  << "% ), standard deviation: "<< stddev << endl;
  
  if(n==0){ 
    cout << _name << " correctness check PASSED" << endl;  
    return true; 
  }

  return false;
}
Exemplo n.º 8
0
/**
 * Update the displayed table of column definitions.
 */
void DBEditor::updateTable()
{
    table->clear();
    c4_View temp = info.SortOn(ceNewIndex);
    int size = temp.GetSize();
    QTreeWidgetItem *last = 0;
    for (int i = 0; i < size; i++) {
        QString name = QString::fromUtf8(ceName (temp[i]));
        int type = ceType (temp[i]);
        QString typeString = getTypeString(type);
        QString defaultVal = QString::fromUtf8(ceDefault (temp[i]));
        if (type == NOTE) {
            defaultVal = defaultVal.replace(QRegExp("\n"), " ");
        }
        if (i == 0) {
            last = new QTreeWidgetItem(table);
        }
        else {
            last = new QTreeWidgetItem(table, last);
        }
        last->setText(0, name);
        last->setText(1, typeString);
        last->setText(2, defaultVal);
        if (type == BOOLEAN) {
            last->setText(2, "");
            int checked = defaultVal.toInt();
            last->setCheckState(2, checked ? Qt::Checked : Qt::Unchecked);
            // remove the ability to toggle the checkbox
            last->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
        }
        else if (type == NOTE) {
            last->setIcon(2, QIcon(":/icons/note.png"));
        }
        else if (type == DATE) {
            if (defaultVal == "0") {
                last->setText(2, ColumnEditor::tr("Today"));
            }
            else {
                last->setText(2, ColumnEditor::tr("None"));
            }
        }
        else if (type == TIME) {
            if (defaultVal == "0") {
                last->setText(2, ColumnEditor::tr("Now"));
            }
            else {
                last->setText(2, ColumnEditor::tr("None"));
            }
        }
    }
    if (size == 0) {
        stack->setCurrentWidget(noColumns);
    }
    else {
        stack->setCurrentWidget(table);
    }
}
Exemplo n.º 9
0
size_t DumpBuffer::PrintHeader()
{

  size_t size = getSize();

  cout << _name << "\t " << size <<  " Bytes of type " << getTypeString() << " (Buffer not tempalted)"<< endl;

  return size;
}
Exemplo n.º 10
0
size_t DumpWrapper<T>::PrintHeader()
{

  size_t size = getSize()/sizeof(T);

  cout << _name << "\t " << size <<  " elements of type " << getTypeString() << endl;

  return size;
}
Exemplo n.º 11
0
void SqlApiBindStmt::dump( FILE *f ) const {
  size_t i;
  const HostVarDescription *var;
  m_stmtHead.dump(f);
  for(i = 0,var = m_inHost; i < m_stmtHead.m_ninput; i++, var++) {
    _ftprintf(f,_T("%-20s %4d\n")
               ,getTypeString(var->getType())
               ,var->sqllen
             );
  }
  for(i = 0, var = m_outHost; i < m_stmtHead.m_noutput; i++, var++) {
    _ftprintf(f,_T("%-20s %4d\n")
               ,getTypeString(var->getType())
               ,var->sqllen
             );
  }
  _ftprintf(f, _T("%s\n"), m_stmt);
}
Exemplo n.º 12
0
String ColumnDefinition::toString() const {
  String result = format(_T("%-13s %-8s %8s   %4d   %4d")
                       , m_name.cstr()
                       , getTypeString(getType())
                       , m_nullAllowed ? _T("NULL") : _T("NOT NULL")
                       , m_offset
                       , m_len
                       );
  if(m_defaultValue.length() > 0) {
    result += _T(" <") + m_defaultValue + _T(">");
  }
  return result;
}
Exemplo n.º 13
0
bool HlslLinker::emitReturnValue(const EGlslSymbolType retType, GlslFunction* funcMain, EShLanguage lang, std::stringstream& varying, std::stringstream& postamble)
{
	// void return type
	if (retType == EgstVoid)
	{
		if (lang == EShLangFragment) // fragment shader
		{
			// If no return type, close off the output
			postamble << ";\n";
		}
		return true;
	}
	
	// non-struct return type
	assert (retType != EgstVoid);
	if (retType != EgstStruct)
	{
		std::string name, ctor;
		int pad;
		
		GlslSymbolOrStructMemberBase fakedMainSym("", funcMain->getSemantic(), retType, EqtNone, EbpMedium, 0);

		if (!getArgumentData2(&fakedMainSym, lang==EShLangVertex ? EClassVarOut : EClassRes,
								name, ctor, pad, -1))
		{
			assert(0);
			infoSink.info << (lang==EShLangVertex ? "Unsupported type for shader return value (" : "Unsupported return type for shader entry function (");
			infoSink.info << getTypeString(retType) << ")\n";
			return true; //@TODO: real error and return false?
		}
		
		postamble << "    ";
		postamble << name << " = ";
		emitSymbolWithPad (postamble, ctor, "xl_retval", pad);		
		postamble << ";\n";
		
		// In vertex shader, add to varyings
		if (lang == EShLangVertex)
			AddToVaryings (varying, lang, m_Target, funcMain->getPrecision(), ctor, name);
		return true;
	}
	
	// struct return type
	assert (retType == EgstStruct);
	GlslStruct *retStruct = funcMain->getStruct();
	assert (retStruct);
	return emitReturnStruct(retStruct, std::string("xl_retval."), lang, varying, postamble);
}
Exemplo n.º 14
0
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
//
//
// Returns the record's type (enum)
//
//
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
directoryRecord::tDirectoryRecordType directoryRecord::getType()
{
	std::wstring typeString(getTypeString());

	for(size_t scanTypes(0); typesList[scanTypes].m_type != endOfDirectoryRecordTypes; ++scanTypes)
	{
		if(typesList[scanTypes].m_name == typeString)
		{
			return typesList[scanTypes].m_type;
		}
	}

	// Invalid value found . Throw an exception
	///////////////////////////////////////////////////////////
	throw dicomDirUnknownDirectoryRecordType("Unknown directory record type");
}
Exemplo n.º 15
0
void writeMatrix(const std::string& filename, const std::vector<T>& A, size_t m, size_t n) {
  std::ofstream f;
  f.exceptions(std::ofstream::failbit | std::ofstream::badbit);
  const char* type = getTypeString(A);

  f.open(filename.c_str(), std::ios::out | std::ios::binary);

  // header (size and type)
  f.write(reinterpret_cast<const char*>(&m), sizeof(m));
  f.write(reinterpret_cast<const char*>(&n), sizeof(n));
  f.write(type, 16);

  // entries
  for (size_t i = 0; i < m * n; i++) {
    writeEntry(f, A[i]);
  }
}
Exemplo n.º 16
0
std::string GEntity::getInfoString()
{
  std::ostringstream sstream;
  sstream << getTypeString() << " " << tag();

  std::string info = getAdditionalInfoString();
  if(info.size()) sstream << " " << info;

  if(physicals.size()){
    sstream << " (Physical:";
    for(unsigned int i = 0; i < physicals.size(); i++)
      sstream << " " << physicals[i];
    sstream << ")";
  }

  return sstream.str();
}
Exemplo n.º 17
0
void HlslLinker::emitOutputNonStructParam(GlslSymbol* sym, EShLanguage lang, bool usePrecision, EAttribSemantic attrSem, std::stringstream& varying, std::stringstream& preamble, std::stringstream& postamble, std::stringstream& call)
{
	std::string name, ctor;
	int pad;
	
	if (!getArgumentData( sym, lang==EShLangVertex ? EClassVarOut : EClassRes, name, ctor, pad))
	{
		//should deal with fall through cases here
		assert(0);
		infoSink.info << "Unsupported type for shader entry parameter (";
		infoSink.info << getTypeString(sym->getType()) << ")\n";
		return;
	}
	
	// For "inout" parameters, the preamble was already written so no need to do it here.
	if (sym->getQualifier() != EqtInOut)
	{
		preamble << "    ";

        // UNITY CUSTOM: for vprog output with position semantic - force highp
        TPrecision prec = usePrecision ? sym->getPrecision() : EbpUndefined;
        if(sym->hasSemantic() && usePrecision)
        {
            const char* str = sym->getSemantic().c_str();
            int         len = sym->getSemantic().length();

            extern bool IsPositionSemantics(const char* sem, int len);
            if(IsPositionSemantics(str, len))
                prec = EbpHigh;
        }

        writeType (preamble, sym->getType(), NULL,prec);
		preamble << " xlt_" << sym->getName() << ";\n";                     
	}
	
	// In vertex shader, add to varyings
	if (lang == EShLangVertex)
		AddVertexOutput (varying, m_Target, sym->getPrecision(), ctor, name);
	
	call << "xlt_" << sym->getName();
	
	postamble << "    ";
	postamble << name << " = ";
	emitSymbolWithPad (postamble, ctor, "xlt_"+sym->getName(), pad);
	postamble << ";\n";
}
Exemplo n.º 18
0
  void MaterialObject::build() {
    check();
    if (!debugInactivate_()) {
      // for (auto& currentSensor : sensorNode_) {
      //   ReferenceSensor temporarySensor;
      //   temporarySensor.store(currentSensor.second);
      //   temporarySensor.check();
      //   temporarySensor.cleanup();

      //   std::cout << "[" << currentSensor.first << "]=" << temporarySensor.numChannels() << "; ";
      //   sensorChannels[currentSensor.first] = temporarySensor.numChannels();
      // }
      // std::cout << "}" << std::endl;
      

      static std::map<MaterialObjectKey, Materials*> materialsMap_; //for saving memory
      for (auto& currentMaterialNode : materialsNode_) {
        store(currentMaterialNode.second);

        check();
        if (type_().compare(getTypeString()) == 0) {
          MaterialObjectKey myKey(currentMaterialNode.first, sensorChannels, destination_.state()? destination_() : std::string(""));
          if (materialsMap_.count(myKey) == 0) {
            Materials * newMaterials  = new Materials(materialType_);
            newMaterials->store(currentMaterialNode.second);

            //pass destination to newMaterials
            if(destination_.state()) {
              PropertyTree destinationPt;
              destinationPt.add(destination_.name(), destination_());
              newMaterials->store(destinationPt);
            }

            newMaterials->build(sensorChannels);
            materialsMap_[myKey] = newMaterials;
          }
          materials_ = materialsMap_[myKey];

          break;
        }
      }

    }
    cleanup();
  }
Exemplo n.º 19
0
UINT ColumnInfo::getMaxStringLen() const {
  switch(getType()) {
  case DBTYPE_CSTRING    :
  case DBTYPE_CSTRINGN   :
    return m_len / sizeof(char);
  case DBTYPE_WSTRING    :
  case DBTYPE_WSTRINGN   :
    return m_len / sizeof(wchar_t);
  case DBTYPE_VARCHAR    :
  case DBTYPE_VARCHARN   :
    return m_len / sizeof(TCHAR);

  default                :
    throwSqlError(SQL_FATAL_ERROR,_T("%s:Type not String or varchar (=%s)")
                                 ,__TFUNCTION__, getTypeString(getType()));
    return 0;
  }
}
Exemplo n.º 20
0
SIPTransaction::SIPTransaction(SIPTransaction::Ptr pParent) :
  _type(pParent->getType()),
  _owner(0),
  _transportService(0),
  _state(TRN_STATE_IDLE),
  _localAddress(),
  _remoteAddress(),
  _sendAddress(),
  _dialogTarget(),
  _isXOREncrypted(false),
  _pParent(pParent),
  _isParent(false)
{
  _id = pParent->getId();
  _logId = pParent->getLogId();
  std::ostringstream logMsg;
  logMsg << _logId << getTypeString() << " " << _id << " CREATED";
  OSS::log_debug(logMsg.str());
}
void FSFloaterWSAssetBlacklist::addElementToList(const LLUUID& id, const LLSD& data)
{
	LLSD element;
	element["id"] = id;
	element["columns"][0]["column"] = "name";
	element["columns"][0]["type"] = "text";
	element["columns"][0]["value"] = !data["asset_name"].asString().empty() ? data["asset_name"].asString() : getString("unknown_object");
	element["columns"][1]["column"] = "region";
	element["columns"][1]["type"] = "text";
	element["columns"][1]["value"] = !data["asset_region"].asString().empty() ? data["asset_region"].asString() : getString("unknown_region");
	element["columns"][2]["column"] = "type";
	element["columns"][2]["type"] = "text";
	element["columns"][2]["value"] = getTypeString(data["asset_type"].asInteger());
	element["columns"][3]["column"] = "date";
	element["columns"][3]["type"] = "text";
	element["columns"][3]["value"] = data["asset_date"].asString();

	mResultList->addElement(element, ADD_BOTTOM);
}
Exemplo n.º 22
0
void HlslLinker::emitOutputStructParam(GlslSymbol* sym, EShLanguage lang, bool usePrecision, EAttribSemantic attrSem, std::stringstream& varying, std::stringstream& preamble, std::stringstream& postamble, std::stringstream& call)
{
	//structs must pass the struct, then process per element
	GlslStruct *Struct = sym->getStruct();
	assert(Struct);
	
	//first create the temp
	std::string tempVar = "xlt_" + sym->getName();
	
	// For "inout" parmaeters the preamble and call were already written, no need to do it here
	if ( sym->getQualifier() != EqtInOut )
	{
		preamble << "    " << Struct->getName() << " ";
		preamble << tempVar <<";\n";
		call << tempVar;
	}
	
	const int elem = Struct->memberCount();
	for (int ii=0; ii<elem; ii++)
	{
		const StructMember &current = Struct->getMember(ii);
		std::string name, ctor;
		int pad;
		
		if (!getArgumentData2( &current, lang==EShLangVertex ? EClassVarOut : EClassRes, name, ctor, pad, -1))
		{
			//should deal with fall through cases here
			assert(0);
			infoSink.info << "Unsupported type in struct element for shader entry parameter (";
			infoSink.info << getTypeString(current.type) << ")\n";
			continue;
		}
		postamble << "    ";
		postamble << name << " = ";
		emitSymbolWithPad (postamble, ctor, tempVar+"."+current.name, pad);		
		postamble << ";\n";

		// In vertex shader, add to varyings
		if (lang == EShLangVertex)
			AddVertexOutput (varying, m_Target, current.precision, ctor, name);
	}
}
Exemplo n.º 23
0
void Shader::printActiveAttribs() const
{
    GLint numAttribs;
    glGetProgramInterfaceiv(id_, GL_PROGRAM_INPUT, GL_ACTIVE_RESOURCES, &numAttribs);

    GLenum properties[] = { GL_NAME_LENGTH, GL_TYPE, GL_LOCATION };

    printf("Active attributes:\n");
    for (int i = 0; i < numAttribs; ++i)
    {
        GLint results[3];
        glGetProgramResourceiv(id_, GL_PROGRAM_INPUT, i, 3, properties, 3, NULL, results);

        GLint nameBufSize = results[0] + 1;
        char *name = new char[nameBufSize];
        glGetProgramResourceName(id_, GL_PROGRAM_INPUT, i, nameBufSize, NULL, name);
        printf("%-5d %s (%s)\n", results[2], name, getTypeString(results[1]));
        delete[] name;
    }
}
Exemplo n.º 24
0
QVariant pki_key::column_data(dbheader *hd)
{
	QStringList sl;
	sl << tr("Common") << tr("Private") << tr("Bogus") << tr("PIN");
	switch (hd->id) {
		case HD_key_type:
			return QVariant(getTypeString());
		case HD_key_size:
			return QVariant(length());
		case HD_key_use:
			return QVariant(getUcount());
		case HD_key_passwd:
			if (isPubKey())
				return QVariant(tr("No password"));
			if (ownPass<0 || ownPass>3)
				return QVariant("Holla die Waldfee");
			return QVariant(sl[ownPass]);
	}
	return pki_base::column_data(hd);
}
Exemplo n.º 25
0
void Shader::printActiveUniformBlocks() const
{
    GLint numBlocks = 0;

    glGetProgramInterfaceiv(id_, GL_UNIFORM_BLOCK, GL_ACTIVE_RESOURCES, &numBlocks);
    GLenum blockProps[] = { GL_NUM_ACTIVE_VARIABLES, GL_NAME_LENGTH };
    GLenum blockIndex[] = { GL_ACTIVE_VARIABLES };
    GLenum props[] = { GL_NAME_LENGTH, GL_TYPE, GL_BLOCK_INDEX };

    for (int block = 0; block < numBlocks; ++block)
    {
        GLint blockInfo[2];
        glGetProgramResourceiv(id_, GL_UNIFORM_BLOCK, block, 2, blockProps, 2, NULL, blockInfo);
        GLint numUnis = blockInfo[0];

        char *blockName = new char[blockInfo[1] + 1];
        glGetProgramResourceName(id_, GL_UNIFORM_BLOCK, block, blockInfo[1] + 1, NULL, blockName);
        printf("Uniform block \"%s\":\n", blockName);
        delete[] blockName;

        GLint *unifIndexes = new GLint[numUnis];
        glGetProgramResourceiv(id_, GL_UNIFORM_BLOCK, block, 1, blockIndex, numUnis, NULL, unifIndexes);

        for (int unif = 0; unif < numUnis; ++unif)
        {
            GLint uniIndex = unifIndexes[unif];
            GLint results[3];
            glGetProgramResourceiv(id_, GL_UNIFORM, uniIndex, 3, props, 3, NULL, results);

            GLint nameBufSize = results[0] + 1;
            char *name = new char[nameBufSize];
            glGetProgramResourceName(id_, GL_UNIFORM, uniIndex, nameBufSize, NULL, name);
            printf("   %s (%s)\n", name, getTypeString(results[1]));
            delete[] name;
        }

        delete[] unifIndexes;
    }
}
Exemplo n.º 26
0
void HlslLinker::emitInputNonStructParam(GlslSymbol* sym, EShLanguage lang, bool usePrecision, EAttribSemantic attrSem, std::stringstream& attrib, std::stringstream& varying, std::stringstream& preamble, std::stringstream& call)
{
	std::string name, ctor;
	int pad;
	
	if (!getArgumentData (sym, lang==EShLangVertex ? EClassAttrib : EClassVarIn, name, ctor, pad))
	{
		// should deal with fall through cases here
		assert(0);
		infoSink.info << "Unsupported type for shader entry parameter (";
		infoSink.info << getTypeString(sym->getType()) << ")\n";
		return;
	}
	
	
	// In fragment shader, pass zero for POSITION inputs
	if (lang == EShLangFragment && attrSem == EAttrSemPosition)
	{
		call << ctor << "(0.0)";
		return; // noting more to do
	}
	// For "in" parameters, just call directly to the main
	else if ( sym->getQualifier() != EqtInOut )
	{
		emitSymbolWithPad (call, ctor, name, pad);
	}
	// For "inout" parameters, declare a temp and initialize it
	else
	{
		preamble << "    ";
		writeType (preamble, sym->getType(), NULL, usePrecision?sym->getPrecision():EbpUndefined);
		preamble << " xlt_" << sym->getName() << " = ";
		emitSymbolWithPad (preamble, ctor, name, pad);
		preamble << ";\n";
	}

	if (!sym->outputSuppressedBy())
		emitSingleInputVariable (lang, m_Target, name, ctor, sym->getType(), sym->getPrecision(), attrib, varying);
}
Exemplo n.º 27
0
LPWSTR getTypeUString (WORD id, LPWSTR lpText, DWORD size)
{
	ItemTypesBIN* itemTypeData = D2GetItemTypesBIN(id);
	if (!itemTypeData)
	{
		mbstowcs(lpText, "Bad Type", size);
		return lpText;
	}
	const char* string = getTypeString(itemTypeData->code);
	if (!string)
	{
		struct {
			DWORD code;
			BYTE zero;
		} code;
		code.code = itemTypeData->code;
		code.zero = 0;
		mbstowcs(lpText, (char*)&code, size);
	} else 
		mbstowcs(lpText, string, size);

	return lpText;
}
Exemplo n.º 28
0
void Shader::printActiveUniforms() const
{
    GLint numUniforms = 0;
    glGetProgramInterfaceiv(id_, GL_UNIFORM, GL_ACTIVE_RESOURCES, &numUniforms);

    GLenum properties[] = { GL_NAME_LENGTH, GL_TYPE, GL_LOCATION, GL_BLOCK_INDEX };

    printf("Active uniforms:\n");
    for (int i = 0; i < numUniforms; ++i)
    {
        GLint results[4];
        glGetProgramResourceiv(id_, GL_UNIFORM, i, 4, properties, 4, NULL, results);

        if (results[3] != -1)
            continue;

        GLint nameBufSize = results[0] + 1;
        char *name = new char[nameBufSize];
        glGetProgramResourceName(id_, GL_UNIFORM, i, nameBufSize, NULL, name);
        printf("%-5d %s (%s)\n", results[2], name, getTypeString(results[1]));
        delete[] name;
    }
}
Exemplo n.º 29
0
void CGLSLProgram::loadUniformVariables(){

	GLenum uniformVariableType;
	GLint uniformMaxLength, numberOfUniforms, uniformVariableSize;

	glGetProgramiv(mProgram, GL_ACTIVE_UNIFORMS, &numberOfUniforms);
	glGetProgramiv(mProgram, GL_ACTIVE_UNIFORM_MAX_LENGTH, &uniformMaxLength);

	GLchar *uniformName = new GLchar[uniformMaxLength];

	printf("\nActive Uniforms\n---------------------------------------------\nID  -  Name  -  Type\n\n");

	for (int k = 0; k < numberOfUniforms; ++k){

		glGetActiveUniform(mProgram, k, uniformMaxLength + 1, NULL, &uniformVariableSize, &uniformVariableType, uniformName);
		addUniform(uniformName);
		printf("%d | %s (%s)\n", mUniformsList[uniformName], uniformName, getTypeString(uniformVariableType).c_str());

	}

	printf("\n---------------------------------------------\n");

}
Exemplo n.º 30
0
	GLuint Shader::load(ShaderType type, const char *path) {
		GLuint shaderID = glCreateShader(type);
		std::string vertSourceString = util::readFile(path);
		const char *source = vertSourceString.c_str();
		glShaderSource(shaderID, 1, &source, NULL);
		glCompileShader(shaderID);
		GLint result;
		glGetShaderiv(shaderID, GL_COMPILE_STATUS, &result);
		if (result == GL_FALSE) {
			GLint length;
			glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &length);
			char *error = new char[length];
			glGetShaderInfoLog(shaderID, length, &length, error);
			error[length - 2] = '\0'; //delete double \n at end of report
			LOG(Error, "GLSL", "Compiling %s as %s Shader: \n\t%s", path, getTypeString(type), error);
			delete error;
			glDeleteShader(shaderID);
		} else {
			LOG(Success, "Shader", "ID: %d | Path: %s", shaderID, path);
			glAttachShader(m_ProgramID, shaderID);
		}
		return shaderID;
	}