void TSShapeInstance::listMeshes( const String &state ) const { if ( state.equal( "All", String::NoCase ) ) { for ( U32 i = 0; i < mMeshObjects.size(); i++ ) { const MeshObjectInstance &mesh = mMeshObjects[i]; Con::warnf( "meshidx %3d, %8s, %s", i, ( mesh.forceHidden ) ? "Hidden" : "Visible", mShape->getMeshName(i).c_str() ); } } else if ( state.equal( "Hidden", String::NoCase ) ) { for ( U32 i = 0; i < mMeshObjects.size(); i++ ) { const MeshObjectInstance &mesh = mMeshObjects[i]; if ( mesh.forceHidden ) Con::warnf( "meshidx %3d, %8s, %s", i, "Visible", mShape->getMeshName(i).c_str() ); } } else if ( state.equal( "Visible", String::NoCase ) ) { for ( U32 i = 0; i < mMeshObjects.size(); i++ ) { const MeshObjectInstance &mesh = mMeshObjects[i]; if ( !mesh.forceHidden ) Con::warnf( "meshidx %3d, %8s, %s", i, "Hidden", mShape->getMeshName(i).c_str() ); } } else { Con::warnf( "TSShapeInstance::listMeshes( %s ) - only All/Hidden/Visible are valid parameters." ); } }
Error lookup_programmer(String name, MPSSEConfig * config) { if (name.equal("um232h")) *config = um232h_config; else if (name.equal("bus_blaster")) *config = bus_blaster_config; else return Err::failure; return Err::success; }
void test_time_strftime() { Fixnum* sec = Fixnum::from(8); Fixnum* min = Fixnum::from(10); Fixnum* hour = Fixnum::from(12); Fixnum* day = Fixnum::from(18); Fixnum* mon = Fixnum::from(9); Fixnum* year = Fixnum::from(74); Fixnum* isdst = Fixnum::from(1); Array* ary = Array::create(state, 11); ary->set(state, 0, sec); ary->set(state, 1, min); ary->set(state, 2, hour); ary->set(state, 3, day); ary->set(state, 4, mon); ary->set(state, 5, year); ary->set(state, 6, Fixnum::from(0)); ary->set(state, 7, Fixnum::from(0)); ary->set(state, 8, isdst); ary->set(state, 9, Fixnum::from(-7)); ary->set(state, 10, String::create(state, "")); String* format = String::create(state, "%A, %e %B %G %I:%M:%S %p"); String* expected = String::create(state, "Sunday, 18 October 1973 12:10:08 PM"); Time* t = Time::create(state); String* actual = t->strftime(state, ary, format); TS_ASSERT(actual->equal(state, expected)); }
void test_lookup_with_empty_string() { String* str = String::create(state, ""); Symbol* sym = symbols->lookup(state, str); String* str2 = symbols->lookup_string(state, sym); TS_ASSERT_EQUALS(cTrue, str->equal(state, str2)); }
void ShaderGen::initShaderGen() { if (mInit) return; const GFXAdapterType adapterType = GFX->getAdapterType(); if (!mInitDelegates[adapterType]) return; mInitDelegates[adapterType](this); mFeatureInitSignal.trigger( adapterType ); mInit = true; String shaderPath = Con::getVariable( "$shaderGen::cachePath"); #if defined(TORQUE_SHADERGEN) && ( defined(TORQUE_OS_XENON) || defined(TORQUE_OS_PS3) ) // If this is a console build, and TORQUE_SHADERGEN is defined // (signifying that new shaders should be generated) then clear the shader // path so that the MemFileSystem is used instead. shaderPath.clear(); #endif if (!shaderPath.equal( "shadergen:" ) && !shaderPath.isEmpty() ) { // this is necessary, especially under Windows with UAC enabled if (!Torque::FS::VerifyWriteAccess(shaderPath)) { // we don't have write access so enable the virtualized memory store Con::warnf("ShaderGen: Write permission unavailable, switching to virtualized memory storage"); shaderPath.clear(); } } if ( shaderPath.equal( "shadergen:" ) || shaderPath.isEmpty() ) { // If we didn't get a path then we're gonna cache the shaders to // a virtualized memory file system. mMemFS = new Torque::Mem::MemFileSystem( "shadergen:/" ); Torque::FS::Mount( "shadergen", mMemFS ); } else Torque::FS::Mount( "shadergen", shaderPath + "/" ); // Delete the auto-generated conditioner include file. Torque::FS::Remove( "shadergen:/" + ConditionerFeature::ConditionerIncludeFileName ); }
Value parse_logical_pathname_directory(AbstractString * s) { Value result; unsigned long i; if (s->length() > 1 && s->char_at(0) == ';') { result = make_cons(K_relative); i = 1; } else { result = make_cons(K_absolute); i = 0; } const unsigned long limit = s->length(); while (i < limit) { String * token = new String(); while (i < limit) { char c = s->char_at(i++); if (is_separator_char(c)) break; else token->append_char(c); } Value value; if (token->equal("*")) value = K_wild; else if (token->equal("**")) value = K_wild_inferiors; else if (token->equal("..")) { if (stringp(car(result))) { result = cdr(result); continue; } value = K_up; } else value = make_value(token); result = make_cons(value, result); } return CL_nreverse(result); }
void TSMaterialManager::mapMaterial(const String & textureName, const String & materialName) { if (getMapEntry(textureName).isNotEmpty()) { if (!textureName.equal("unmapped_mat", String::NoCase)) Log::warnf(LogEntry::General, "Warning, overwriting material for: %s", textureName.c_str()); } mMaterialMap[String::ToLower(textureName)] = materialName; }
VALUE rb_str_equal(VALUE self, VALUE other) { if(self == other) { return Qtrue; } NativeMethodEnvironment* env = NativeMethodEnvironment::get(); String* string = capi_get_string(env, self); String* other_str = capi_get_string(env, other); return env->get_handle(string->equal(env->state(), other_str)); }
FileSystemRef MountSystem::_removeMountFromList(String root) { for (Vector<MountFS>::iterator itr = mMountList.begin(); itr != mMountList.end(); itr++) { if (root.equal( itr->root, String::NoCase )) { FileSystemRef fs = itr->fileSystem; mMountList.erase(itr); return fs; } } return NULL; }
void CmdVariable::PrintVariable(DebuggerClient &client, CStrRef varName) { CmdVariable cmd; cmd.m_frame = client.getFrame(); CmdVariablePtr rcmd = client.xend<CmdVariable>(&cmd); if (!rcmd->m_variables.empty()) { for (ArrayIter iter(rcmd->m_variables); iter; ++iter) { String name = iter.first().toString(); if (!name.equal(varName)) continue; String value = DebuggerClient::FormatVariable(iter.second(), 200); client.print("%s", value.data()); } } }
void CmdVariable::PrintVariable(DebuggerClient &client, const String& varName) { CmdVariable cmd(client.isStackTraceAsync() ? KindOfVariableAsync : KindOfVariable); auto charCount = client.getDebuggerClientShortPrintCharCount(); cmd.m_frame = client.getFrame(); auto rcmd = client.xend<CmdVariable>(&cmd); if (rcmd->m_version == 2) { // Using the new protocol. rcmd contains a list of variables only. // Fetch value of varName only, so that we can recover nicely when its // value is too large to serialize. cmd.m_varName = varName; cmd.m_variables.reset(); cmd.m_version = 2; rcmd = client.xend<CmdVariable>(&cmd); if (rcmd->m_variables.empty()) { // Perhaps the value is too large? See recvImpl. // Retry the command with version 1, in which case values are omitted. cmd.m_version = 1; rcmd = client.xend<CmdVariable>(&cmd); if (!rcmd->m_variables.empty()) { // It's there without values, and gone with values, so it is too large. client.output("...(omitted)"); return; } } } if (!rcmd->m_variables.empty()) { for (ArrayIter iter(rcmd->m_variables); iter; ++iter) { String name = iter.first().toString(); if (!name.equal(varName)) continue; String value = DebuggerClient::FormatVariable(iter.second(), -1); auto excess = value.length() - charCount; if (charCount <= 0 || excess <= 0) { client.output("%s", value.data()); } else { client.output("%s", value.substr(0, charCount).data()); if (client.ask("There are %d more characters. Continue? [y/N]", excess) == 'y') { client.output("%s", value.substr(charCount).data()); client.tutorial("You can use 'set cc n' to increase the character" " limit. 'set cc -1' will remove the limit."); } } } } }
//-------------------------------------------------------------------------- // Sets the specified material in the list to the specified texture. also // remaps mat instances based on the new texture name. Returns false if // the specified texture is not valid. //-------------------------------------------------------------------------- bool TSMaterialList::renameMaterial(U32 i, const String& newName) { if (i > size() || newName.isEmpty()) return false; // Check if already using this name if (newName.equal(mMaterialNames[i], String::NoCase)) { // same material, return true since we aren't changing it return true; } // Allow the rename if the new name is mapped, or if there is a diffuse texture // available (for which a simple Material can be generated in mapMaterial) String mappedName = MATMGR->getMapEntry(newName); if (mappedName.isEmpty()) { // TOFIX GFXTexHandle texHandle; if (mLookupPath.isEmpty()) { //texHandle.set( newName, &GFXDefaultStaticDiffuseProfile, avar("%s() - handle (line %d)", __FUNCTION__, __LINE__) ); } else { String fullPath = String::ToString( "%s/%s", mLookupPath.c_str(), newName.c_str() ); //texHandle.set( fullPath, &GFXDefaultStaticDiffuseProfile, avar("%s() - handle (line %d)", __FUNCTION__, __LINE__) ); } //if (!texHandle.isValid()) // return false; } // change material name mMaterialNames[i] = newName; // Dump the old mat instance and remap the material. if( mMatInstList[ i ] ) SAFE_DELETE( mMatInstList[ i ] ); mapMaterial( i ); return true; }
void TSShapeInstance::reSkin( String newBaseName, String oldBaseName ) { if( newBaseName.isEmpty() ) newBaseName = "base"; if( oldBaseName.isEmpty() ) oldBaseName = "base"; if ( newBaseName.equal( oldBaseName, String::NoCase ) ) return; const U32 oldBaseNameLength = oldBaseName.length(); // Make our own copy of the materials list from the resource if necessary if (ownMaterialList() == false) cloneMaterialList(); TSMaterialList* pMatList = getMaterialList(); pMatList->setTextureLookupPath( mShapeResource.getPath().getPath() ); // Cycle through the materials const Vector<String> &materialNames = pMatList->getMaterialNameList(); for ( S32 i = 0; i < materialNames.size(); i++ ) { // Try changing base const String &pName = materialNames[i]; if ( pName.compare( oldBaseName, oldBaseNameLength, String::NoCase ) == 0 ) { String newName( pName ); newName.replace( 0, oldBaseNameLength, newBaseName ); pMatList->renameMaterial( i, newName ); } } // Initialize the material instances initMaterialList(); }
bool BtPlugin::createWorld( const String &worldName ) { Map<StringNoCase, PhysicsWorld*>::Iterator iter = mPhysicsWorldLookup.find( worldName ); PhysicsWorld *world = NULL; iter != mPhysicsWorldLookup.end() ? world = (*iter).value : world = NULL; if ( world ) { Con::errorf( "BtPlugin::createWorld - %s world already exists!", worldName.c_str() ); return false; } world = new BtWorld(); if ( worldName.equal( smClientWorldName, String::NoCase ) ) world->initWorld( false, ClientProcessList::get() ); else world->initWorld( true, ServerProcessList::get() ); mPhysicsWorldLookup.insert( worldName, world ); return world != NULL; }
Variant binary_deserialize(int8_t thrift_typeID, PHPInputTransport& transport, const Array& fieldspec) { Variant ret; switch (thrift_typeID) { case T_STOP: case T_VOID: return init_null(); case T_STRUCT: { Variant val; if ((val = fieldspec.rvalAt(PHPTransport::s_class)).isNull()) { throw_tprotocolexception("no class type in spec", INVALID_DATA); skip_element(T_STRUCT, transport); return init_null(); } String structType = val.toString(); ret = createObject(structType); if (ret.isNull()) { // unable to create class entry skip_element(T_STRUCT, transport); return init_null(); } Variant spec = HHVM_FN(hphp_get_static_property)(structType, s_TSPEC, false); if (!spec.is(KindOfArray)) { char errbuf[128]; snprintf(errbuf, 128, "spec for %s is wrong type: %d\n", structType.data(), ret.getType()); throw_tprotocolexception(String(errbuf, CopyString), INVALID_DATA); return init_null(); } binary_deserialize_spec(ret.toObject(), transport, spec.toArray()); return ret; } break; case T_BOOL: { uint8_t c; transport.readBytes(&c, 1); return c != 0; } //case T_I08: // same numeric value as T_BYTE case T_BYTE: { uint8_t c; transport.readBytes(&c, 1); return Variant((int8_t)c); } case T_I16: { uint16_t c; transport.readBytes(&c, 2); return Variant((int16_t)ntohs(c)); } case T_I32: { uint32_t c; transport.readBytes(&c, 4); return Variant((int32_t)ntohl(c)); } case T_U64: case T_I64: { uint64_t c; transport.readBytes(&c, 8); return Variant((int64_t)ntohll(c)); } case T_DOUBLE: { union { uint64_t c; double d; } a; transport.readBytes(&(a.c), 8); a.c = ntohll(a.c); return a.d; } case T_FLOAT: { union { uint32_t c; float d; } a; transport.readBytes(&(a.c), 4); a.c = ntohl(a.c); return a.d; } //case T_UTF7: // aliases T_STRING case T_UTF8: case T_UTF16: case T_STRING: { uint32_t size = transport.readU32(); if (size && (size + 1)) { String s = String(size, ReserveString); char* strbuf = s.mutableData(); transport.readBytes(strbuf, size); s.setSize(size); return s; } else { return empty_string_variant(); } } case T_MAP: { // array of key -> value uint8_t types[2]; transport.readBytes(types, 2); uint32_t size = transport.readU32(); Array keyspec = fieldspec.rvalAt(PHPTransport::s_key, AccessFlags::Error_Key).toArray(); Array valspec = fieldspec.rvalAt(PHPTransport::s_val, AccessFlags::Error_Key).toArray(); String format = fieldspec.rvalAt(PHPTransport::s_format, AccessFlags::None).toString(); if (format.equal(PHPTransport::s_collection)) { ret = newobj<c_Map>(); for (uint32_t s = 0; s < size; ++s) { Variant key = binary_deserialize(types[0], transport, keyspec); Variant value = binary_deserialize(types[1], transport, valspec); collectionSet(ret.getObjectData(), key.asCell(), value.asCell()); } } else { ret = Array::Create(); for (uint32_t s = 0; s < size; ++s) { Variant key = binary_deserialize(types[0], transport, keyspec); Variant value = binary_deserialize(types[1], transport, valspec); ret.toArrRef().set(key, value); } } return ret; // return_value already populated } case T_LIST: { // array with autogenerated numeric keys int8_t type = transport.readI8(); uint32_t size = transport.readU32(); Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem, AccessFlags::Error_Key); Array elemspec = elemvar.toArray(); String format = fieldspec.rvalAt(PHPTransport::s_format, AccessFlags::None).toString(); if (format.equal(PHPTransport::s_collection)) { auto const pvec = newobj<c_Vector>(); ret = pvec; for (uint32_t s = 0; s < size; ++s) { Variant value = binary_deserialize(type, transport, elemspec); pvec->t_add(value); } } else { PackedArrayInit pai(size); for (auto s = uint32_t{0}; s < size; ++s) { pai.append(binary_deserialize(type, transport, elemspec)); } ret = pai.toArray(); } return ret; } case T_SET: { // array of key -> TRUE uint8_t type; uint32_t size; transport.readBytes(&type, 1); transport.readBytes(&size, 4); size = ntohl(size); Variant elemvar = fieldspec.rvalAt(PHPTransport::s_elem, AccessFlags::Error_Key); Array elemspec = elemvar.toArray(); String format = fieldspec.rvalAt(PHPTransport::s_format, AccessFlags::None).toString(); if (format.equal(PHPTransport::s_collection)) { auto set_ret = makeSmartPtr<c_Set>(); for (uint32_t s = 0; s < size; ++s) { Variant key = binary_deserialize(type, transport, elemspec); if (key.isInteger()) { set_ret->t_add(key); } else { set_ret->t_add(key.toString()); } } ret = Variant(std::move(set_ret)); } else { ArrayInit init(size, ArrayInit::Mixed{}); for (uint32_t s = 0; s < size; ++s) { Variant key = binary_deserialize(type, transport, elemspec); if (key.isInteger()) { init.set(key, true); } else { init.setKeyUnconverted(key, true); } } ret = init.toArray(); } return ret; } }; char errbuf[128]; sprintf(errbuf, "Unknown thrift typeID %d", thrift_typeID); throw_tprotocolexception(String(errbuf, CopyString), INVALID_DATA); return init_null(); }
void ProcessedCustomMaterial::_setStageData() { // Only do this once if ( mHasSetStageData ) return; mHasSetStageData = true; ShaderRenderPassData* rpd = _getRPD(0); mConditionerMacros.clear(); // Loop through all the possible textures, set the right flags, and load them if needed for(U32 i=0; i<CustomMaterial::MAX_TEX_PER_PASS; i++ ) { rpd->mTexType[i] = Material::NoTexture; // Set none as the default in case none of the cases below catch it. String filename = mCustomMaterial->mTexFilename[i]; if(filename.isEmpty()) continue; if(filename.equal(String("$dynamiclight"), String::NoCase)) { rpd->mTexType[i] = Material::DynamicLight; mMaxTex = i+1; continue; } if(filename.equal(String("$dynamiclightmask"), String::NoCase)) { rpd->mTexType[i] = Material::DynamicLightMask; mMaxTex = i+1; continue; } if(filename.equal(String("$lightmap"), String::NoCase)) { rpd->mTexType[i] = Material::Lightmap; mMaxTex = i+1; continue; } if(filename.equal(String("$cubemap"), String::NoCase)) { if( mCustomMaterial->mCubemapData ) { rpd->mTexType[i] = Material::Cube; mMaxTex = i+1; } else { mCustomMaterial->logError( "Could not find CubemapData - %s", mCustomMaterial->mCubemapName.c_str()); } continue; } if(filename.equal(String("$dynamicCubemap"), String::NoCase)) { rpd->mTexType[i] = Material::SGCube; mMaxTex = i+1; continue; } if(filename.equal(String("$backbuff"), String::NoCase)) { rpd->mTexType[i] = Material::BackBuff; mMaxTex = i+1; continue; } if(filename.equal(String("$reflectbuff"), String::NoCase)) { rpd->mTexType[i] = Material::ReflectBuff; mMaxTex = i+1; continue; } if(filename.equal(String("$miscbuff"), String::NoCase)) { rpd->mTexType[i] = Material::Misc; mMaxTex = i+1; continue; } // Check for a RenderTexTargetBin assignment if (filename.substr( 0, 1 ).equal("#")) { String texTargetBufferName = filename.substr(1, filename.length() - 1); NamedTexTarget *texTarget = NamedTexTarget::find( texTargetBufferName ); rpd->mTexSlot[i].texTarget = texTarget; // Get the conditioner macros. if ( texTarget ) texTarget->getShaderMacros( &mConditionerMacros ); rpd->mTexType[i] = Material::TexTarget; mMaxTex = i+1; continue; } rpd->mTexSlot[i].texObject = _createTexture( filename, &GFXDefaultStaticDiffuseProfile ); if ( !rpd->mTexSlot[i].texObject ) { mMaterial->logError("Failed to load texture %s", _getTexturePath(filename).c_str()); continue; } rpd->mTexType[i] = Material::Standard; mMaxTex = i+1; } // We only get one cubemap if( mCustomMaterial->mCubemapData ) { mCustomMaterial->mCubemapData->createMap(); rpd->mCubeMap = mMaterial->mCubemapData->mCubemap; // BTRTODO ? if ( !rpd->mCubeMap ) mMaterial->logError("Failed to load cubemap"); } // If this has a output target defined, it may be writing // to a tex target bin with a conditioner, so search for // one and add its macros. if ( mCustomMaterial->mOutputTarget.isNotEmpty() ) { NamedTexTarget *texTarget = NamedTexTarget::find( mCustomMaterial->mOutputTarget ); if ( texTarget ) texTarget->getShaderMacros( &mConditionerMacros ); } // Copy the glow state over. mHasGlow = mCustomMaterial->mGlow[0]; }