Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Plug] Remove TF_FOR_ALL usage. #396

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 21 additions & 23 deletions pxr/base/lib/plug/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ PlugPlugin::_LoadWithDependents(_SeenPlugins *seenPlugins)

// Load any dependencies.
JsObject dependencies = GetDependencies();
TF_FOR_ALL(i, dependencies) {
string baseTypeName = i->first;
for (const auto& p : dependencies) {
string baseTypeName = p.first;
TfType baseType = TfType::FindByName(baseTypeName);

// Check that each base class type is defined.
Expand All @@ -327,15 +327,14 @@ PlugPlugin::_LoadWithDependents(_SeenPlugins *seenPlugins)

// Get dependencies, as typenames
typedef vector<string> TypeNames;
if (!i->second.IsArrayOf<string>()) {
if (!p.second.IsArrayOf<string>()) {
TF_CODING_ERROR("Load failed: dependency list has wrong type");
return false;
}
const TypeNames & dependents = i->second.GetArrayOf<string>();
const TypeNames & dependents = p.second.GetArrayOf<string>();

// Load the dependencies for each base class.
TF_FOR_ALL(j, dependents) {
const string & dependName = *j;
for (const auto& dependName : dependents) {
TfType dependType = TfType::FindByName(dependName);

if (dependType.IsUnknown()) {
Expand Down Expand Up @@ -472,8 +471,8 @@ PlugPlugin::_GetAllPlugins()
std::lock_guard<std::mutex> lock(_allPluginsMutex);
PlugPluginPtrVector plugins;
plugins.reserve(_allPlugins->size());
TF_FOR_ALL(it, *_allPlugins) {
plugins.push_back(it->second);
for (const auto& p : *_allPlugins) {
plugins.push_back(p.second);
}
return plugins;
}
Expand Down Expand Up @@ -517,8 +516,8 @@ PlugPlugin::DeclaresType(const TfType& type, bool includeSubclasses) const
if (const JsValue* typesEntry = TfMapLookupPtr(_dict, "Types")) {
if (typesEntry->IsObject()) {
const JsObject& typesDict = typesEntry->GetJsObject();
TF_FOR_ALL(it, typesDict) {
const TfType typeFromPlugin = TfType::FindByName(it->first);
for (const auto& p : typesDict) {
const TfType typeFromPlugin = TfType::FindByName(p.first);
const bool match =
(includeSubclasses ?
typeFromPlugin.IsA(type) : (typeFromPlugin == type));
Expand Down Expand Up @@ -562,16 +561,15 @@ PlugPlugin::_DeclareAliases( TfType t, const JsObject & metadata )

const JsObject& aliasDict = i->second.GetJsObject();

TF_FOR_ALL(aliasIt, aliasDict) {

if (!aliasIt->second.IsString()) {
for (const auto& p : aliasDict) {
if (!p.second.IsString()) {
TF_WARN("Expected string for alias name, but found %s",
aliasIt->second.GetTypeName().c_str() );
p.second.GetTypeName().c_str() );
continue;
}

const string& aliasName = aliasIt->second.GetString();
TfType aliasBase = TfType::Declare(aliasIt->first);
const string& aliasName = p.second.GetString();
TfType aliasBase = TfType::Declare(p.first);

t.AddAlias( aliasBase, aliasName );
}
Expand All @@ -586,9 +584,9 @@ PlugPlugin::_DeclareTypes()
const JsObject& types = typesValue.GetJsObject();

// Declare TfTypes for all the types found in the plugin.
TF_FOR_ALL(i, types) {
if (i->second.IsObject()) {
_DeclareType(i->first, i->second.GetJsObject());
for (const auto& p : types) {
if (p.second.IsObject()) {
_DeclareType(p.first, p.second.GetJsObject());
}
}
}
Expand Down Expand Up @@ -633,15 +631,15 @@ PlugPlugin::_DeclareType(
} else {
// Make sure that the bases mentioned in the plugin
// metadata are among them.
TF_FOR_ALL(i, basesVec) {
TfType base = *i;
for (const auto& base : basesVec) {
std::string const &baseName = base.GetTypeName();
if (std::find(existingBases.begin(), existingBases.end(),
base) == existingBases.end()) {
// Our expected base was not found.
std::string basesStr;
TF_FOR_ALL(j, existingBases)
basesStr += j->GetTypeName() + " ";
for (const auto& j : existingBases) {
basesStr += j.GetTypeName() + " ";
}
TF_CODING_ERROR(
"The metadata for plugin '%s' defined in %s declares "
"type '%s' with base type '%s', but the type has "
Expand Down
8 changes: 4 additions & 4 deletions pxr/base/lib/plug/testenv/testPlugPixver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ int main(int argc, char* argv[])
// Print out the paths so we can compare runs when something fails
cout << "==== paths ====" << endl;
sort(paths.begin(), paths.end());
TF_FOR_ALL(it, paths) {
cout << *it << endl;
if (IsPathToCheck(*it)) {
filtered_paths.push_back(*it);
for (const auto& path : paths) {
cout << path << endl;
if (IsPathToCheck(path)) {
filtered_paths.push_back(path);
}
}
cout << endl;
Expand Down
7 changes: 3 additions & 4 deletions pxr/base/lib/plug/wrapPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include "pxr/base/tf/pyContainerConversions.h"
#include "pxr/base/tf/pyPtrHelpers.h"
#include "pxr/base/tf/pyResultConversions.h"
#include "pxr/base/tf/iterator.h"

#include <boost/python.hpp>
#include <string>
Expand All @@ -45,9 +44,9 @@ static dict
_ConvertDict( const JsObject & dictionary )
{
dict result;
TF_FOR_ALL(i, dictionary) {
const string & key = i->first;
const JsValue & val = i->second;
for (const auto& p : dictionary) {
const string & key = p.first;
const JsValue & val = p.second;

result[key] = JsConvertToContainerType<object, dict>(val);
}
Expand Down