Browse Source

interrogate changes to support freetype

David Rose 24 years ago
parent
commit
68aa6f0e52

+ 40 - 15
dtool/src/cppparser/cppPreprocessor.cxx

@@ -662,19 +662,13 @@ push_string(const string &input, bool lock_position) {
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: CPPPreprocessor::parse_expr
+//     Function: CPPPreprocessor::expand_manifests
 //       Access: Protected
 //  Description: Given a string, expand all manifests within the
-//               string and evaluate it as an expression.  Returns
-//               NULL if the string is not a valid expression.
-//
-//               This is an internal support function for
-//               CPPPreprocessor; however, there is a public variant
-//               of this function defined for CPPParser.
+//               string and return the new string.
 ////////////////////////////////////////////////////////////////////
-CPPExpression *CPPPreprocessor::
-parse_expr(const string &input_expr, CPPScope *current_scope,
-           CPPScope *global_scope) {
+string CPPPreprocessor::
+expand_manifests(const string &input_expr) {
   // Get a copy of the expression string we can modify.
   string expr = input_expr;
 
@@ -721,6 +715,25 @@ parse_expr(const string &input_expr, CPPScope *current_scope,
     // that expands to another manifest.
   } while (manifest_found);
 
+  return expr;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: CPPPreprocessor::parse_expr
+//       Access: Protected
+//  Description: Given a string, expand all manifests within the
+//               string and evaluate it as an expression.  Returns
+//               NULL if the string is not a valid expression.
+//
+//               This is an internal support function for
+//               CPPPreprocessor; however, there is a public variant
+//               of this function defined for CPPParser.
+////////////////////////////////////////////////////////////////////
+CPPExpression *CPPPreprocessor::
+parse_expr(const string &input_expr, CPPScope *current_scope,
+           CPPScope *global_scope) {
+  string expr = expand_manifests(input_expr);
+
   CPPExpressionParser ep(current_scope, global_scope);
   ep._verbose = 0;
   if (ep.parse_expr(expr, *this)) {
@@ -1314,9 +1327,21 @@ handle_include_directive(const string &args, int first_line,
   Filename filename_as_referenced;
   bool angle_quotes = false;
 
-  if (!args.empty()) {
-    if (args[0] == '"' && args[args.size() - 1] == '"') {
-      filename = args.substr(1, args.size() - 2);
+  string expr = args;
+
+  // The filename to include might actually be hidden within a
+  // manifest definition.  Wow.  FreeType depends on this.
+
+  // Just to play things safe, since our manifest-expansion logic
+  // might not filter out quotes and angle brackets properly, we'll
+  // only expand manifests if we don't begin with a quote or bracket.
+  if (!expr.empty() && (expr[0] != '"' && expr[0] != '<')) {
+    expr = expand_manifests(expr);
+  }
+
+  if (!expr.empty()) {
+    if (expr[0] == '"' && expr[expr.size() - 1] == '"') {
+      filename = expr.substr(1, expr.size() - 2);
       okflag = true;
 
       if (_files.size() == 1) {
@@ -1325,8 +1350,8 @@ handle_include_directive(const string &args, int first_line,
         // included files.
         _quote_includes.insert(filename);
       }
-    } else if (args[0] == '<' && args[args.size() - 1] == '>') {
-      filename = args.substr(1, args.size() - 2);
+    } else if (expr[0] == '<' && expr[expr.size() - 1] == '>') {
+      filename = expr.substr(1, expr.size() - 2);
       angle_quotes = true;
       okflag = true;
 

+ 1 - 0
dtool/src/cppparser/cppPreprocessor.h

@@ -107,6 +107,7 @@ protected:
   bool push_file(const CPPFile &file);
   bool push_string(const string &input, bool lock_position);
 
+  string expand_manifests(const string &input_expr);
   CPPExpression *parse_expr(const string &expr, CPPScope *current_scope,
                             CPPScope *global_scope);
 

+ 1 - 1
dtool/src/parser-inc/Sources.pp

@@ -1,5 +1,5 @@
 #define INSTALL_PARSER_INC \
-    algorithm deque iostream list map memory \
+    algorithm deque ft2build.h iostream list map memory \
     pair queue set stack stdcompare.h stdtypedefs.h \
     string vector windows.h zlib.h md5.h files.h hex.h \
     nurbs.hh

+ 35 - 0
dtool/src/parser-inc/ft2build.h

@@ -0,0 +1,35 @@
+// Filename: ft2build.h
+// Created by:  drose (08Feb02)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://www.panda3d.org/license.txt .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+// This file, and all the other files in this directory, aren't
+// intended to be compiled--they're just parsed by CPPParser (and
+// interrogate) in lieu of the actual system headers, to generate the
+// interrogate database.
+
+#ifndef FT2BUILD_H
+#define FT2BUILD_H
+
+// This definition is intentionally recursive.  Why complicate things
+// with multiple files?
+#define FT_FREETYPE_H <ft2build.h>
+
+class FT_Face;
+class FT_Library;
+
+#endif
+