From 5df79c53745fde5d6c3340a2979b1429cd5892c1 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Sat, 8 Oct 2011 20:30:28 +0200 Subject: Initial import of htcd system 1.0 Signed-off-by: Henrik Rydberg --- src/lang/ops.cc | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 src/lang/ops.cc (limited to 'src/lang/ops.cc') diff --git a/src/lang/ops.cc b/src/lang/ops.cc new file mode 100644 index 0000000..7916d96 --- /dev/null +++ b/src/lang/ops.cc @@ -0,0 +1,150 @@ +/************************************************************************* + * + * HTCd - Copyright (C) 1998-2006 Henrik Rydberg + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +////////////////////////////////////////////////////// + +struct xop_t : public op_t { + typedef void (*xop1_t)(mstream&,Env&,const sref&); + typedef void (*xop2_t)(mstream&,Env&,const sref&,const sref&); + xop_t(const mstring& s,int p1,int p2,int l,int r, + xop1_t op1,xop2_t op2,const mstring& d): + op_t(s,p1,p2,l,r,(op1_t)op1,(op2_t)op2,d) {} +}; + +////////////////////////////////////////////////////// + +#define X1_IMPL(name) \ +static void impl_##name(mstream& out,Env& env,const sref& a) throw(merror_t) +#define X2_IMPL(name) \ +static void impl_##name(mstream& out,Env& env,const sref& L,const sref& R) throw(merror_t) + +#define X1_ADDN(p,l,r,f,n,d) M.add(new xop_t(#n,p,0,l,r,impl_##f,0,d)) +#define X2_ADDN(p,l,r,f,n,d) M.add(new xop_t(#n,0,p,l,r,0,impl_##f,d)) + +////////////////////////////////////////////////////// + +X1_IMPL(exist) { + mstring name; + swrite sw(name); + env.eval(sw,a,0); + out<, + "Copy local record\n" + "Syntax: (partial name) -> (partial name)\n" + "Returns: nothing\n" + "\n" + "The partial name @ for data base records works in both arguments.\n" + "\n" + "Generates an error if any of the expanded names of the right\n" + "partial argument does not exist.\n" + ); +} -- cgit v1.2.3