From 0d206996cd68b9f08ae1b4d9da6f16293984302c Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 4 Feb 2019 12:11:18 -0500 Subject: Feature/casting tidyup (#822) * Use 'is' over 'as' where appropriate. * dynamic_cast -> dynamicCast * Replace 'dynamicCast' with 'as' where has no change in behavior/ambiguity. * Replace dynamicCast with as where doesn't change behavior/non ambiguous. --- source/slang/reflection.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source/slang/reflection.cpp') diff --git a/source/slang/reflection.cpp b/source/slang/reflection.cpp index 68e0ce9e5..2b0be98c9 100644 --- a/source/slang/reflection.cpp +++ b/source/slang/reflection.cpp @@ -678,7 +678,7 @@ SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetFieldByIndex( auto typeLayout = convert(inTypeLayout); if(!typeLayout) return nullptr; - if(auto structTypeLayout = dynamic_cast(typeLayout)) + if(auto structTypeLayout = as(typeLayout)) { return (SlangReflectionVariableLayout*) structTypeLayout->fields[index].Ptr(); } @@ -691,7 +691,7 @@ SLANG_API size_t spReflectionTypeLayout_GetElementStride(SlangReflectionTypeLayo auto typeLayout = convert(inTypeLayout); if(!typeLayout) return 0; - if( auto arrayTypeLayout = dynamic_cast(typeLayout)) + if( auto arrayTypeLayout = as(typeLayout)) { switch (category) { @@ -726,15 +726,15 @@ SLANG_API SlangReflectionTypeLayout* spReflectionTypeLayout_GetElementTypeLayout auto typeLayout = convert(inTypeLayout); if(!typeLayout) return nullptr; - if( auto arrayTypeLayout = dynamic_cast(typeLayout)) + if( auto arrayTypeLayout = as(typeLayout)) { return (SlangReflectionTypeLayout*) arrayTypeLayout->elementTypeLayout.Ptr(); } - else if( auto constantBufferTypeLayout = dynamic_cast(typeLayout)) + else if( auto constantBufferTypeLayout = as(typeLayout)) { return convert(constantBufferTypeLayout->offsetElementTypeLayout.Ptr()); } - else if( auto structuredBufferTypeLayout = dynamic_cast(typeLayout)) + else if( auto structuredBufferTypeLayout = as(typeLayout)) { return convert(structuredBufferTypeLayout->elementTypeLayout.Ptr()); } @@ -747,7 +747,7 @@ SLANG_API SlangReflectionVariableLayout* spReflectionTypeLayout_GetElementVarLay auto typeLayout = convert(inTypeLayout); if(!typeLayout) return nullptr; - if( auto constantBufferTypeLayout = dynamic_cast(typeLayout)) + if( auto constantBufferTypeLayout = as(typeLayout)) { return convert(constantBufferTypeLayout->elementVarLayout.Ptr()); } @@ -779,7 +779,7 @@ static SlangParameterCategory getParameterCategory( static TypeLayout* maybeGetContainerLayout(TypeLayout* typeLayout) { - if (auto parameterGroupTypeLayout = dynamic_cast(typeLayout)) + if (auto parameterGroupTypeLayout = as(typeLayout)) { auto containerTypeLayout = parameterGroupTypeLayout->containerVarLayout->typeLayout; if (containerTypeLayout->resourceInfos.Count() != 0) @@ -826,7 +826,7 @@ SLANG_API SlangMatrixLayoutMode spReflectionTypeLayout_GetMatrixLayoutMode(Slang auto typeLayout = convert(inTypeLayout); if(!typeLayout) return SLANG_MATRIX_LAYOUT_MODE_UNKNOWN; - if( auto matrixLayout = dynamic_cast(typeLayout) ) + if( auto matrixLayout = as(typeLayout) ) { return matrixLayout->mode; } @@ -842,7 +842,7 @@ SLANG_API int spReflectionTypeLayout_getGenericParamIndex(SlangReflectionTypeLay auto typeLayout = convert(inTypeLayout); if(!typeLayout) return -1; - if(auto genericParamTypeLayout = dynamic_cast(typeLayout)) + if(auto genericParamTypeLayout = as(typeLayout)) { return genericParamTypeLayout->paramIndex; } @@ -1204,19 +1204,19 @@ SLANG_API void spReflectionEntryPoint_getComputeThreadGroupSize( else { // Fall back to the GLSL case, which requires a search over global-scope declarations - // to look for anything with the `local_size_*` qualifier - auto module = dynamic_cast(entryPointFunc->ParentDecl); + // to look for as with the `local_size_*` qualifier + auto module = as(entryPointFunc->ParentDecl); if (module) { for (auto dd : module->Members) { for (auto mod : dd->GetModifiersOfType()) { - if (auto xMod = dynamic_cast(mod)) + if (auto xMod = as(mod)) sizeAlongAxis[0] = (SlangUInt) getIntegerLiteralValue(xMod->valToken); - else if (auto yMod = dynamic_cast(mod)) + else if (auto yMod = as(mod)) sizeAlongAxis[1] = (SlangUInt) getIntegerLiteralValue(yMod->valToken); - else if (auto zMod = dynamic_cast(mod)) + else if (auto zMod = as(mod)) sizeAlongAxis[2] = (SlangUInt) getIntegerLiteralValue(zMod->valToken); } } -- cgit v1.2.3