Rebuild autotool system
[construo.git] / lisp_writer.cxx
blob4496b27c9a33bf654597bc90ea58393b690c3483
1 // $Id: lisp_writer.cxx,v 1.3 2003/07/24 10:10:02 grumbel Exp $
2 //
3 // Construo - A wire-frame construction game
4 // Copyright (C) 2002 Ingo Ruhnke <grumbel@gmx.de>
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #include "lisp_writer.hxx"
22 LispWriter::LispWriter (const char* name)
24 lisp_objs.push_back(lisp_make_symbol (name));
27 void
28 LispWriter::append (lisp_object_t* obj)
30 lisp_objs.push_back(obj);
33 lisp_object_t*
34 LispWriter::make_list3 (lisp_object_t* a, lisp_object_t* b, lisp_object_t* c)
36 return lisp_make_cons (a, lisp_make_cons(b, lisp_make_cons(c, lisp_nil())));
39 lisp_object_t*
40 LispWriter::make_list2 (lisp_object_t* a, lisp_object_t* b)
42 return lisp_make_cons (a, lisp_make_cons(b, lisp_nil()));
45 void
46 LispWriter::write_vector (const char* name, const Vector2d& pos)
48 append(lisp_make_cons (lisp_make_symbol (name),
49 make_list2(lisp_make_real(pos.x),
50 lisp_make_real(pos.y))));
53 void
54 LispWriter::write_float (const char* name, float f)
56 append(make_list2 (lisp_make_symbol (name),
57 lisp_make_real(f)));
60 void
61 LispWriter::write_int (const char* name, int i)
63 append(make_list2 (lisp_make_symbol (name),
64 lisp_make_integer(i)));
67 void
68 LispWriter::write_string (const char* name, const char* str)
70 append(make_list2 (lisp_make_symbol (name),
71 lisp_make_string(str)));
74 void
75 LispWriter::write_symbol (const char* name, const char* symname)
77 append(make_list2 (lisp_make_symbol (name),
78 lisp_make_symbol(symname)));
81 void
82 LispWriter::write_lisp_obj(const char* name, lisp_object_t* lst)
84 append(make_list2 (lisp_make_symbol (name),
85 lst));
88 void
89 LispWriter::write_boolean (const char* name, bool b)
91 append(make_list2 (lisp_make_symbol (name),
92 lisp_make_boolean(b)));
95 lisp_object_t*
96 LispWriter::create_lisp ()
98 lisp_object_t* lisp_obj = lisp_nil();
100 for(std::vector<lisp_object_t*>::reverse_iterator i = lisp_objs.rbegin ();
101 i != lisp_objs.rend (); ++i)
103 lisp_obj = lisp_make_cons (*i, lisp_obj);
105 lisp_objs.clear();
107 return lisp_obj;
110 /* EOF */