Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
2ede38216f

+ 4 - 4
dtool/src/cppparser/cppManifest.cxx

@@ -53,7 +53,7 @@ CPPManifest(const string &args, const CPPFile &file) : _file(file) {
 
   _name = args.substr(0, p);
   
-  vector<string> parameter_names;
+  vector_string parameter_names;
 
   if (args[p] == '(') {
     // Hmm, parameters.
@@ -95,7 +95,7 @@ CPPManifest::
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 string CPPManifest::
-expand(const vector<string> &args) const {
+expand(const vector_string &args) const {
   string result;
 
   Expansion::const_iterator ei;
@@ -172,7 +172,7 @@ output(ostream &out) const {
 ////////////////////////////////////////////////////////////////////
 void CPPManifest::
 parse_parameters(const string &args, size_t &p, 
-		 vector<string> &parameter_names) {
+		 vector_string &parameter_names) {
   assert(p < args.size());
   assert(args[p] == '(');
 
@@ -211,7 +211,7 @@ parse_parameters(const string &args, size_t &p,
 //  Description: 
 ////////////////////////////////////////////////////////////////////
 void CPPManifest::
-save_expansion(const string &exp, const vector<string> &parameter_names) {
+save_expansion(const string &exp, const vector_string &parameter_names) {
   if (parameter_names.empty()) {
     // No parameters; this is an easy case.
     _expansion.push_back(ExpansionNode(exp));

+ 4 - 5
dtool/src/cppparser/cppManifest.h

@@ -11,8 +11,7 @@
 #include "cppFile.h"
 #include "cppVisibility.h"
 
-#include <vector>
-#include <string>
+#include <vector_string.h>
 
 class CPPExpression;
 class CPPType;
@@ -25,7 +24,7 @@ class CPPManifest {
 public:
   CPPManifest(const string &args, const CPPFile &file = CPPFile());
   ~CPPManifest();
-  string expand(const vector<string> &args = vector<string>()) const;
+  string expand(const vector_string &args = vector_string()) const;
 
   CPPType *determine_type() const;
 
@@ -45,9 +44,9 @@ public:
 
 private:
   void parse_parameters(const string &args, size_t &p,
-			vector<string> &parameter_names);
+			vector_string &parameter_names);
   void save_expansion(const string &exp,
-		      const vector<string> &parameter_names);
+		      const vector_string &parameter_names);
 
   class ExpansionNode {
   public:

+ 5 - 5
dtool/src/cppparser/cppPreprocessor.cxx

@@ -1508,7 +1508,7 @@ get_identifier(int c) {
 ////////////////////////////////////////////////////////////////////
 CPPToken CPPPreprocessor::
 expand_manifest(const CPPManifest *manifest) {
-  vector<string> args;
+  vector_string args;
   
   if (manifest->_has_parameters) {
     // Hmm, we're expecting arguments.
@@ -1538,7 +1538,7 @@ expand_manifest(const CPPManifest *manifest) {
 ////////////////////////////////////////////////////////////////////
 void CPPPreprocessor::
 extract_manifest_args(const string &name, int num_args, 
-		      vector<string> &args) {
+		      vector_string &args) {
   CPPFile first_file = get_file();
   int first_line = get_line_number();
   int first_col = get_col_number();
@@ -1608,7 +1608,7 @@ void CPPPreprocessor::
 expand_defined_function(string &expr, size_t q, size_t &p) {
   string result;
 
-  vector<string> args;
+  vector_string args;
   extract_manifest_args_inline("defined", 1, args, expr, p);
   if (args.size() >= 1) {
     const string &manifest_name = args[0];
@@ -1634,7 +1634,7 @@ expand_defined_function(string &expr, size_t q, size_t &p) {
 void CPPPreprocessor::
 expand_manifest_inline(string &expr, size_t q, size_t &p,
 		       const CPPManifest *manifest) {
-  vector<string> args;
+  vector_string args;
   if (manifest->_has_parameters) {
     extract_manifest_args_inline(manifest->_name, manifest->_num_parameters,
 				 args, expr, p);
@@ -1652,7 +1652,7 @@ expand_manifest_inline(string &expr, size_t q, size_t &p,
 ////////////////////////////////////////////////////////////////////
 void CPPPreprocessor::
 extract_manifest_args_inline(const string &name, int num_args, 
-			     vector<string> &args,
+			     vector_string &args,
 			     const string &expr, size_t &p) {
   // Skip whitespace till paren.
   while (p < expr.size() && isspace(expr[p])) {

+ 3 - 2
dtool/src/cppparser/cppPreprocessor.h

@@ -14,6 +14,7 @@
 #include "cppCommentBlock.h"
 
 #include <dSearchPath.h>
+#include <vector_string.h>
 
 #include <map>
 #include <list>
@@ -129,12 +130,12 @@ private:
   CPPToken get_identifier(int c);
   CPPToken expand_manifest(const CPPManifest *manifest);
   void extract_manifest_args(const string &name, int num_args,
-			     vector<string> &args);
+			     vector_string &args);
   void expand_defined_function(string &expr, size_t q, size_t &p);
   void expand_manifest_inline(string &expr, size_t q, size_t &p,
 			      const CPPManifest *manifest);
   void extract_manifest_args_inline(const string &name, int num_args,
-				    vector<string> &args,
+				    vector_string &args,
 				    const string &expr, size_t &p);
 
   CPPToken get_number(int c, int c2 = 0);

+ 3 - 3
dtool/src/interrogate/wrapperBuilder.cxx

@@ -429,7 +429,7 @@ get_parameter_name(int n) const {
 //               of the nth parameter is it is empty.
 ////////////////////////////////////////////////////////////////////
 string WrapperBuilder::
-get_parameter_expr(int n, const vector<string> &pexprs) const {
+get_parameter_expr(int n, const vector_string &pexprs) const {
   if (n < (int)pexprs.size()) {
     return pexprs[n];
   }
@@ -445,7 +445,7 @@ get_parameter_expr(int n, const vector<string> &pexprs) const {
 //               parameter value.
 ////////////////////////////////////////////////////////////////////
 string WrapperBuilder::
-get_call_str(const vector<string> &pexprs) const {
+get_call_str(const vector_string &pexprs) const {
   // Build up the call to the actual function.
   ostringstream call;
 
@@ -521,7 +521,7 @@ get_call_str(const vector<string> &pexprs) const {
 ////////////////////////////////////////////////////////////////////
 string WrapperBuilder::
 call_function(ostream &out, int indent_level, bool convert_result,
-	      const vector<string> &pexprs) const {
+	      const vector_string &pexprs) const {
   string return_expr;
 
   if (_type == T_destructor) {

+ 4 - 3
dtool/src/interrogate/wrapperBuilder.h

@@ -9,6 +9,7 @@
 #include <dtoolbase.h>
 
 #include <interrogate_interface.h>
+#include <vector_string.h>
 
 #include <vector>
 
@@ -105,12 +106,12 @@ protected:
   void output_ref(ostream &out, int indent_level, const string &varname) const;
 
   string get_parameter_name(int n) const;
-  string get_parameter_expr(int n, const vector<string> &pexprs) const;
+  string get_parameter_expr(int n, const vector_string &pexprs) const;
 
-  string get_call_str(const vector<string> &pexprs = vector<string>()) const;
+  string get_call_str(const vector_string &pexprs = vector_string()) const;
   string call_function(ostream &out, int indent_level, 
 		       bool convert_result = true,
-		       const vector<string> &pexprs = vector<string>()) const;
+		       const vector_string &pexprs = vector_string()) const;
 
   void write_spam_message(ostream &out) const;
   void write_quoted_string(ostream &out, const string &str) const;

+ 1 - 1
dtool/src/interrogate/wrapperBuilderPython.cxx

@@ -57,7 +57,7 @@ write_wrapper(ostream &out, const string &wrapper_name) const {
 
   string format_specifiers;
   string parameter_list;
-  vector<string> pexprs;
+  vector_string pexprs;
 
   // Make one pass through the parameter list.  We will output a
   // one-line temporary variable definition for each parameter, while

+ 23 - 39
pandatool/src/cvscopy/cvsSourceDirectory.cxx

@@ -8,16 +8,6 @@
 
 #include <notify.h>
 
-#ifdef WIN32_VC
-// Windows uses a different API for scanning for files in a directory.
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-
-#else
-#include <sys/types.h>
-#include <dirent.h>
-#endif
-
 ////////////////////////////////////////////////////////////////////
 //     Function: CVSSourceDirectory::Constructor
 //       Access: Public
@@ -230,40 +220,34 @@ find_dirname(const string &dirname) {
 //               success, false on failure.
 ////////////////////////////////////////////////////////////////////
 bool CVSSourceDirectory::
-scan(const string &fullpath, const string &key_filename) {
-  DIR *root = opendir(fullpath.c_str());
-  if (root == (DIR *)NULL) {
-    nout << "Unable to scan directory " << fullpath << "\n";
+scan(const Filename &directory, const string &key_filename) {
+  vector_string contents;
+  if (!directory.scan_directory(contents)) {
+    nout << "Unable to scan directory " << directory << "\n";
     return false;
   }
 
-  struct dirent *d;
-  d = readdir(root);
-  while (d != (struct dirent *)NULL) {
-    string filename = d->d_name;
-
-    if (!filename.empty() && filename[0] != '.') {
-      // Is this possibly a subdirectory name?
-      string next_path = fullpath + "/" + filename;
-      string key = next_path + "/" + key_filename;
-      if (access(key.c_str(), F_OK) == 0) {
-	CVSSourceDirectory *subdir = 
-	  new CVSSourceDirectory(_tree, this, filename);
-	_children.push_back(subdir);
-
-	if (!subdir->scan(next_path, key_filename)) {
-	  closedir(root);
-	  return false;
-	}
-
-      } else {
-	// It's not a subdirectory; call it a regular file.
-	_tree->add_file(filename, this);
+  vector_string::const_iterator fi;
+  for (fi = contents.begin(); fi != contents.end(); ++fi) {
+    const string &filename = (*fi);
+
+    // Is this possibly a subdirectory name?
+    Filename next_path(directory, filename);
+    Filename key(next_path, key_filename);
+    if (key.exists()) {
+      CVSSourceDirectory *subdir = 
+	new CVSSourceDirectory(_tree, this, filename);
+      _children.push_back(subdir);
+      
+      if (!subdir->scan(next_path, key_filename)) {
+	return false;
       }
+      
+    } else {
+      // It's not a subdirectory; call it a regular file.
+      _tree->add_file(filename, this);
     }
-
-    d = readdir(root);
   }
-  closedir(root);
+
   return true;
 }

+ 2 - 1
pandatool/src/cvscopy/cvsSourceDirectory.h

@@ -7,6 +7,7 @@
 #define CVSSOURCEDIRECTORY_H
 
 #include <pandatoolbase.h>
+#include <filename.h>
 
 #include <vector>
 
@@ -37,7 +38,7 @@ public:
   CVSSourceDirectory *find_dirname(const string &dirname);
 
 public:
-  bool scan(const string &prefix, const string &key_filename);
+  bool scan(const Filename &directory, const string &key_filename);
 
 private:
   CVSSourceTree *_tree;

+ 12 - 36
pandatool/src/softprogs/softCVS.cxx

@@ -5,22 +5,10 @@
 
 #include "softCVS.h"
 
-#include <filename.h>
 #include <notify.h>
-#include <vector_string.h>
 
 #include <algorithm>
 
-#ifdef WIN32_VC
-// Windows uses a different API for scanning for files in a directory.
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
-
-#else
-#include <sys/types.h>
-#include <dirent.h>
-#endif
-
 ////////////////////////////////////////////////////////////////////
 //     Function: SoftCVS::Constructor
 //       Access: Public
@@ -114,32 +102,20 @@ run() {
 //               and renames these to *.1-0.ext.
 ////////////////////////////////////////////////////////////////////
 void SoftCVS::
-traverse(const string &dirname) {
+traverse(const Filename &directory) {
   // Get the list of files in the directory.
   vector_string files;
-
-  DIR *root = opendir(dirname.c_str());
-  if (root == (DIR *)NULL) {
-    nout << "Unable to scan directory " << dirname << "\n";
-  }
-
-  struct dirent *d;
-  d = readdir(root);
-  while (d != (struct dirent *)NULL) {
-    files.push_back(d->d_name);
-    d = readdir(root);
+  if (!directory.scan_directory(files)) {
+    nout << "Unable to scan directory " << directory << "\n";
+    return;
   }
-  closedir(root);
-
-  // Sort the directory entries just for the user's sanity.
-  sort(files.begin(), files.end());
 
   // We need to know the set of files in this directory that are CVS
   // elements.
   set<string> cvs_elements;
   bool in_cvs = false;
   if (!_no_cvs) {
-    in_cvs = scan_cvs(dirname, cvs_elements);
+    in_cvs = scan_cvs(directory, cvs_elements);
   }
 
   // Now go through and identify files with version numbers, and
@@ -156,14 +132,14 @@ traverse(const string &dirname) {
 	versions.push_back(v);
       } else {
 	// Maybe this is a subdirectory?
-	Filename subdir = dirname + "/" + filename;
+	Filename subdir(directory, filename);
 	if (subdir.is_directory()) {
 	  traverse(subdir);
 	} else {
 	  // No, not a subdirectory; maybe a regular file that needs
 	  // to get added to CVS?
 	  if (in_cvs) {
-	    consider_add_cvs(dirname, filename, cvs_elements);
+	    consider_add_cvs(directory, filename, cvs_elements);
 	  }
 	}
       }
@@ -190,23 +166,23 @@ traverse(const string &dirname) {
 	  ++vi;
 	}
 	
-	if (rename_file(dirname, start_vi, vi)) {
+	if (rename_file(directory, start_vi, vi)) {
 	  if (in_cvs) {
-	    consider_add_cvs(dirname, file.get_1_0_filename(), cvs_elements);
+	    consider_add_cvs(directory, file.get_1_0_filename(), cvs_elements);
 	  }
 
 	  if (file.get_extension() == ".dsc") {
-	    _scene_files.insert(dirname + "/" + file.get_1_0_filename());
+	    _scene_files.insert(Filename(directory, file.get_1_0_filename()));
 	  }
 	}
 	
       } else {
 	if (in_cvs) {
-	  consider_add_cvs(dirname, file.get_filename(), cvs_elements);
+	  consider_add_cvs(directory, file.get_filename(), cvs_elements);
 	}
 
 	if (file.get_extension() == ".dsc") {
-	  _scene_files.insert(dirname + "/" + file.get_filename());
+	  _scene_files.insert(Filename(directory, file.get_filename()));
 	}
 	++vi;
       }

+ 2 - 1
pandatool/src/softprogs/softCVS.h

@@ -12,6 +12,7 @@
 
 #include <programBase.h>
 #include <vector_string.h>
+#include <filename.h>
 
 #include <vector>
 #include <set>
@@ -29,7 +30,7 @@ public:
   void run();
 
 private:
-  void traverse(const string &dirname);
+  void traverse(const Filename &directory);
 
   bool rename_file(const string &dirname,
 		   vector<SoftFilename>::const_iterator begin,