1 
2 /******************************************************************************
3 * MODULE     : scheme.hpp
4 * DESCRIPTION: Abstract interface for the manipulation of scheme objects
5 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
6 *******************************************************************************
7 * This software falls under the GNU general public license version 3 or later.
8 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10 ******************************************************************************/
11 
12 #ifndef SCHEME_HH
13 #define SCHEME_HH
14 
15 #include "tree.hpp"
16 #include "path.hpp"
17 #include "command.hpp"
18 #include "url.hpp"
19 
20 class patch;
21 
22 void start_scheme (int argc, char** argv, void (*call_back) (int, char**));
23 void initialize_scheme ();
24 
25 class object_rep : concrete_struct {
26   friend class object;
27 };
28 
29 class tmscm_object_rep;
30 
31 class object {
32 public:
33   CONCRETE(object);
34   object ();
35   object (tmscm_object_rep* o);
36   object (void *); // left intentionally undefined to inhibith implicit conversion of pointers to bool
37   object (bool b); // implicit conversion to bool is dangerous!!! (all pointers match this conversion)
38   object (int i);
39   object (double x);
40   object (const char* s);
41   object (string s);
42   object (tree t);
43   object (list<string> l);
44   object (list<tree> l);
45   object (path p);
46   object (url u);
47   object (modification m);
48   object (patch p);
49 };
50 CONCRETE_CODE(object);
51 
52 tm_ostream& operator << (tm_ostream& out, object obj);
53 bool operator == (object obj1, object obj2);
54 bool operator != (object obj1, object obj2);
55 int hash (object obj);
56 
57 
58 object null_object ();
59 object list_object (object obj1);
60 object list_object (object obj1, object obj2);
61 object list_object (object obj1, object obj2, object obj3);
62 object symbol_object (string s);
63 object cons (object obj1, object obj2);
64 object car (object obj);
65 object cdr (object obj);
66 object caar (object obj);
67 object cdar (object obj);
68 object cadr (object obj);
69 object cddr (object obj);
70 object caddr (object obj);
71 object cadddr (object obj);
72 
73 bool is_null (object obj);
74 bool is_list (object obj);
75 bool is_bool (object obj);
76 bool is_int (object obj);
77 bool is_double (object obj);
78 bool is_string (object obj);
79 bool is_symbol (object obj);
80 bool is_tree (object obj);
81 bool is_path (object obj);
82 bool is_url (object obj);
83 bool is_modification (object obj);
84 bool is_patch (object obj);
85 bool is_widget (object obj);
86 
87 bool as_bool (object obj);
88 int as_int (object obj);
89 double as_double (object obj);
90 string as_string (object obj);
91 string as_symbol (object obj);
92 tree as_tree (object obj);
93 scheme_tree as_scheme_tree (object obj);
94 list<string> as_list_string (object obj);
95 list<tree> as_list_tree (object obj);
96 path as_path (object obj);
97 array<object> as_array_object (object obj);
98 url as_url (object obj);
99 modification as_modification (object obj);
100 patch as_patch (object obj);
101 command as_command (object obj);
102 #ifdef WIDGET_H // FIXME: dirty hack
103 widget as_widget (object obj);
104 promise<widget> as_promise_widget (object obj);
105 #endif
106 
107 object tree_to_stree (tree t);
108 tree   stree_to_tree (object obj);
109 tree   content_to_tree (object obj);
110 object string_to_object (string s);
111 string object_to_string (object obj);
112 object scheme_cmd (const char* s);
113 object scheme_cmd (string s);
114 object scheme_cmd (object cmd);
115 
116 void notify_preferences_booted ();
117 void set_preference (string var, string val);
118 void notify_preference (string var);
119 string get_preference (string var, string def= "default");
120 
121 object eval (const char* expr);
122 object eval (string expr);
123 object eval (object expr);
124 object eval_secure (string expr);
125 object eval_file (string name);
126 bool   exec_file (url u);
127 void   exec_delayed (object cmd);
128 void   exec_delayed_pause (object cmd);
129 void   exec_pending_commands ();
130 void   clear_pending_commands ();
131 void   protected_call (object cmd);
132 
133 object call (const char* fun);
134 object call (const char* fun, object a1);
135 object call (const char* fun, object a1, object a2);
136 object call (const char* fun, object a1, object a2, object a3);
137 object call (const char* fun, object a1, object a2, object a3, object a4);
138 object call (const char* fun, array<object> a);
139 object call (string fun);
140 object call (string fun, object a1);
141 object call (string fun, object a1, object a2);
142 object call (string fun, object a1, object a2, object a3);
143 object call (string fun, object a1, object a2, object a3, object a4);
144 object call (string fun, array<object> a);
145 object call (object fun);
146 object call (object fun, object a1);
147 object call (object fun, object a1, object a2);
148 object call (object fun, object a1, object a2, object a3);
149 object call (object fun, object a1, object a2, object a3, object a4);
150 object call (object fun, array<object> a);
151 
152 
153 #endif // defined SCHEME_HH
154