[Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST Guard.hh,NONE,1.1 Makefile,NONE,1.1 SourceFile.cc,NONE,1.1 SourceFile.py,NONE,1.1
Stefan Seefeld stefan at synopsis.fresco.orgSun Jan 11 19:45:23 UTC 2004
- Previous message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Python Command.py,1.1,1.2 Interpreter.cc,1.1,1.2 Makefile,1.1,1.2
- Next message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis Interpreter.hh,1.1,1.2 Object.hh,1.2,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/tests/Cxx-API/Synopsis/AST
In directory frida:/tmp/cvs-serv6537/Synopsis/AST
Added Files:
Guard.hh Makefile SourceFile.cc SourceFile.py
Log Message:
more unit tests and better coverage of the Cxx API
--- NEW FILE: Guard.hh ---
#ifndef _Guard_hh
#define _Guard_hh
#include <Python.h>
struct Guard
{
Guard() { Py_Initialize();}
~Guard() { Py_Finalize();}
};
Guard guard;
#endif
--- NEW FILE: Makefile ---
# $Id: Makefile,v 1.1 2004/01/11 19:45:21 stefan Exp $
#
# Copyright (C) 2003 Stefan Seefeld
# All rights reserved.
# Licensed to the public under the terms of the GNU LGPL (>= 2),
# see the file COPYING for details.
#
SHELL := /bin/sh
python := python
PYPREFIX:=$(shell $(python) -c "import sys; print sys.prefix")
PYVERSION:=$(shell $(python) -c "from distutils import sysconfig; print sysconfig.get_config_var('VERSION')")
PYINC :=$(shell $(python) -c "from distutils import sysconfig; print sysconfig.get_python_inc()")
PYLIBS :=-L $(PYPREFIX)/lib/python$(PYVERSION)/config -lpython$(PYVERSION) -ldl -lutil -lpthread
CPPFLAGS:= -I ../../../../include -I $(PYINC)
LDFLAGS := -rdynamic
LIBS := $(PYLIBS)
TESTS := SourceFile
all: $(TESTS)
%.o: %.cc
$(CXX) $(CPPFLAGS) -ggdb $(CXXFLAGS) -c -o $@ $<
$(TESTS): %: %.o
$(CXX) -ggdb $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o $(TESTS)
--- NEW FILE: SourceFile.cc ---
#include <Synopsis/Interpreter.hh>
#include <Synopsis/AST/ASTModule.hh>
#include <Synopsis/AST/SourceFile.hh>
#include "Guard.hh"
#include <string>
#include <iostream>
using namespace Synopsis;
void test2()
{
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");
}
void test1()
{
ASTModule module = Synopsis::ASTModule();
SourceFile sf = module.create_source_file("filename", "/long/filename", "C++");
std::cout << "created source file "
<< sf.name() << ' '
<< sf.long_name() << ' '
<< sf.is_main() << std::endl;
}
int main(int, char **)
{
try
{
test2();
test1();
}
catch (const Interpreter::Exception &)
{
PyErr_Print();
}
catch (const std::exception &e)
{
std::cout << "Error : " << e.what() << std::endl;
}
}
--- NEW FILE: SourceFile.py ---
from Synopsis.AST import SourceFile
- Previous message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Python Command.py,1.1,1.2 Interpreter.cc,1.1,1.2 Makefile,1.1,1.2
- Next message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis Interpreter.hh,1.1,1.2 Object.hh,1.2,1.3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list