[Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST/src Declaration.cc,NONE,1.1 Type.cc,NONE,1.1 SourceFile.cc,1.2,1.3

Stefan Seefeld stefan at synopsis.fresco.org
Sun Jan 25 21:21:56 UTC 2004


Update of /cvs/synopsis/Synopsis/tests/Cxx-API/Synopsis/AST/src
In directory frida:/tmp/cvs-serv20957/tests/Cxx-API/Synopsis/AST/src

Modified Files:
	SourceFile.cc 
Added Files:
	Declaration.cc Type.cc 
Log Message:
more work on C++ API

--- NEW FILE: Declaration.cc ---
#include <Synopsis/AST/ASTKit.hh>
#include <Synopsis/AST/TypeKit.hh>
#include "Guard.hh"
#include <string>
#include <iostream>

using namespace Synopsis;

void test1()
{
  AST::ASTKit kit = AST::ASTKit();
  AST::TypeKit types = AST::TypeKit();
  AST::SourceFile sf = kit.create_source_file("filename", "/long/filename", "C++");
  AST::Declaration d = kit.create_declaration(sf, 2, "C--", "foo", Tuple("bar"));
  std::cout << d << std::endl;
  std::cout << "file='" << d.file() << "\'\n"
	    << "line='" << d.line() << "\'\n"
	    << "language='" << d.language() << "\'\n"
	    << "type='" << d.type() << "\'\n"
	    << "name='" << d.name() << "\'\n"
	    << "comments='" << d.comments() << std::endl;
  std::cout << kit.create_builtin(sf, 3, "C--", "eos", Tuple("eos")) << std::endl;
  std::cout << kit.create_macro(sf, 4, "C--", Tuple("ZAP"), List(), "") << std::endl;
  std::cout << kit.create_forward(sf, 5, "C--", "forward", Tuple("flip")) << std::endl;
  std::cout << kit.create_module(sf, 6, "C--", "namespace", Tuple("flop")) << std::endl;
  AST::Class c = kit.create_class(sf, 7, "C--", "class", Tuple("faz"));
  std::cout << c << std::endl;
  AST::Type t = types.create_declared("C--", Tuple("faz"), c);
  std::cout << kit.create_typedef(sf, 7, "C--", "class", Tuple("faz"), t, false) << std::endl;
}

int main(int, char **)
{
  try
  {
    test1();
  }
  catch (const std::exception &e)
  {
    std::cout << "Error : " << e.what() << std::endl;
  }
}


--- NEW FILE: Type.cc ---
#include <Synopsis/AST/TypeKit.hh>
#include "Guard.hh"
#include <string>
#include <iostream>

using namespace Synopsis;

void test1()
{
  AST::TypeKit kit = AST::TypeKit();
  std::cout << kit.create_type("C--") << std::endl;
  std::cout << kit.create_named("C--", Tuple("Foo")) << std::endl;
  std::cout << kit.create_base("C--", Tuple("integer")) << std::endl;
  std::cout << kit.create_dependent("C--", Tuple("dep")) << std::endl;
  std::cout << kit.create_unknown("C--", Tuple("FooBar")) << std::endl;
}

int main(int, char **)
{
  try
  {
    test1();
  }
  catch (const std::exception &e)
  {
    std::cout << "Error : " << e.what() << std::endl;
  }
}


Index: SourceFile.cc
===================================================================
RCS file: /cvs/synopsis/Synopsis/tests/Cxx-API/Synopsis/AST/src/SourceFile.cc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -d -r1.2 -r1.3
--- SourceFile.cc	13 Jan 2004 07:43:08 -0000	1.2
+++ SourceFile.cc	25 Jan 2004 21:21:54 -0000	1.3
@@ -1,35 +1,40 @@
 #include <Synopsis/Interpreter.hh>
-#include <Synopsis/AST/ASTModule.hh>
-#include <Synopsis/AST/SourceFile.hh>
+#include <Synopsis/AST/ASTKit.hh>
 #include "Guard.hh"
 #include <string>
 #include <iostream>
 
 using namespace Synopsis;
 
+char SEP = '/';
+
 void test2()
 {
+  std::string scripts = __FILE__;
+  scripts = scripts.substr(0, scripts.rfind(SEP, scripts.rfind(SEP) - 1) + 1);
+  scripts += "scripts";
+  scripts += SEP;
+  
   Interpreter interp;
   Module module("__main__");
   Dict global = module.dict();
   Dict local;
-  Object retn = interp.run_file("SourceFile.py", Interpreter::FILE,
-                                global, local);
-  Callable type = local.get("SourceFile");
+  Object retn = interp.run_file(scripts + "SourceFile.py", Interpreter::FILE,
+				global, local);
+  Object type = local.get("SourceFile");
   
 }
 
 void test1()
 {
-  ASTModule module = Synopsis::ASTModule();
-  SourceFile sf = module.create_source_file("filename", "/long/filename", "C++");
+  AST::ASTKit kit = AST::ASTKit();
+  AST::SourceFile sf = kit.create_source_file("filename", "/long/filename", "C++");
   sf.is_main(true);
   std::cout << "created source file "
 	    << sf.name() << ' '
 	    << sf.long_name() << ' '
 	    << sf.is_main() << std::endl;
-
-  MacroCall mc = module.create_macro_call("FOO", 1, 2, 3);
+  AST::MacroCall mc = kit.create_macro_call("FOO", 1, 2, 3);
   Dict mmap = sf.macro_calls();
   List line = mmap.get(0, List());
   line.append(mc);
@@ -37,7 +42,7 @@ void test1()
 }
 
 int main(int, char **)
-{  
+{
   try
   {
     test2();





More information about the Synopsis-changes mailing list