Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

lisp_writer.cxx

Go to the documentation of this file.
00001 //  $Id: lisp_writer.cxx,v 1.2 2002/12/28 00:19:53 grumbel Exp $
00002 //
00003 //  Construo - A wire-frame construction game
00004 //  Copyright (C) 2002 Ingo Ruhnke <[email protected]>
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #include "lisp_writer.hxx"
00021 
00022 LispWriter::LispWriter (const char* name)
00023 {
00024   lisp_objs.push_back(lisp_make_symbol (name));
00025 }
00026 
00027 void
00028 LispWriter::append (lisp_object_t* obj)
00029 {
00030   lisp_objs.push_back(obj);
00031 }
00032 
00033 lisp_object_t*
00034 LispWriter::make_list3 (lisp_object_t* a, lisp_object_t* b, lisp_object_t* c)
00035 {
00036   return lisp_make_cons (a, lisp_make_cons(b, lisp_make_cons(c, lisp_nil())));
00037 }
00038 
00039 lisp_object_t*
00040 LispWriter::make_list2 (lisp_object_t* a, lisp_object_t* b)
00041 {
00042   return lisp_make_cons (a, lisp_make_cons(b, lisp_nil()));
00043 }
00044 
00045 void
00046 LispWriter::write_vector (const char* name, const Vector2d& pos)
00047 {
00048   append(lisp_make_cons (lisp_make_symbol (name),
00049                          make_list2(lisp_make_real(pos.x),
00050                                     lisp_make_real(pos.y))));
00051 }
00052 
00053 void
00054 LispWriter::write_float (const char* name, float f)
00055 {
00056   append(make_list2 (lisp_make_symbol (name),
00057                      lisp_make_real(f)));
00058 }
00059 
00060 void 
00061 LispWriter::write_int (const char* name, int i)
00062 {
00063   append(make_list2 (lisp_make_symbol (name),
00064                      lisp_make_integer(i)));
00065 }
00066 
00067 void
00068 LispWriter::write_string (const char* name, const char* str)
00069 {
00070   append(make_list2 (lisp_make_symbol (name),
00071                      lisp_make_string(str)));
00072 }
00073 
00074 void
00075 LispWriter::write_symbol (const char* name, const char* symname)
00076 {
00077   append(make_list2 (lisp_make_symbol (name),
00078                      lisp_make_symbol(symname)));
00079 }
00080 
00081 void
00082 LispWriter::write_lisp_obj(const char* name, lisp_object_t* lst)
00083 {
00084   append(make_list2 (lisp_make_symbol (name),
00085                      lst));
00086 }
00087 
00088 void
00089 LispWriter::write_boolean (const char* name, bool b)
00090 {
00091   append(make_list2 (lisp_make_symbol (name),
00092                      lisp_make_boolean(b)));
00093 }
00094 
00095 lisp_object_t*
00096 LispWriter::create_lisp ()
00097 {
00098   lisp_object_t* lisp_obj = lisp_nil();
00099   
00100   for(std::vector<lisp_object_t*>::reverse_iterator i = lisp_objs.rbegin (); 
00101       i != lisp_objs.rend (); ++i)
00102     {
00103       lisp_obj = lisp_make_cons (*i, lisp_obj);
00104     }
00105   lisp_objs.clear();
00106   
00107   return lisp_obj;
00108 }
00109 
00110 /* EOF */

Generated on Thu Jul 24 10:24:30 2003 for Construo by doxygen1.3-rc3