/*
 * --- GSMP-COPYRIGHT-NOTE-BEGIN ---
 * 
 * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
 * Please add additional copyright information _after_ the line containing
 * the GSMP-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
 * the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
 * 
 * GSMP: dam/utility/regtester/TestParserActions.cc
 * General Sound Manipulation Program is Copyright (C) 2000 - 2004
 *   Valentin Ziegler and René Rebe
 * 
 * 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; version 2. A copy of the GNU General
 * Public License can be found in the file LICENSE.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT-
 * ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 * Public License for more details.
 * 
 * --- GSMP-COPYRIGHT-NOTE-END ---
 */
extern "C" {
#include "TestParserActions.h"
}

#include <string>
#include "Operations.hh"

using namespace std;

string prelude = "";
string startup = "";

template <typename OBJ, typename S> OBJ* CUnwrap (S s)
{
  return (OBJ*) s.object;
}

template <typename OBJ, typename S> S CWrap (OBJ* o)
{
  S t_s;
  t_s.object = (void *) o;
  return t_s;
}

extern "C" void DefineScopes (param_list parameters) {}

/*************************************** Inputs ******************************/


extern "C" void PreludeAppend (const char* txt)
{
  prelude += txt;
}

extern "C" void StartupAppend (const char* txt)
{
  startup += txt;
}

extern "C" void GlobalInsert (declaration_list decls) {}
extern "C" void CreateLocal (const char* id, int count, declaration_list decls, const char* text) {}
extern "C" void CreateAction (const char* id, param_list params, bool_func guard, assigment_list post, const char* text) {}

/*************************************** Declarations ******************************/

extern "C" declaration_list ChainDeclaration (declaration_struct d, declaration_list l) {}
extern "C" declaration_list DeclListEnd () {}
extern "C" declaration_struct CreateDeclaration (const char* id, bool_func val, const char* text) {}

/*************************************** Assigments ******************************/

extern "C" assigment_list ChainAssigment (assigment_struct a, assigment_list l) {}
extern "C" assigment_list AssigmentListEnd () {}
extern "C" assigment_struct CreateSimpleAssigment (const char* id, bool_func val, const char* text) {}
extern "C" assigment_struct CreateScopedAssigment (const char* scope, const char* id, bool_func val, const char* text) {}

/*************************************** Parameters ******************************/

extern "C" param_list ChainParameter (param_struct p, param_list l) {}
extern "C" param_list ParameterListEnd (param_struct p) {}
extern "C" param_struct CreateParameter (const char* type, const char* id) {}

/*************************************** Functions ******************************/

template <typename SEM> bool_func Create_un_b (bool_func f)
{
  return CWrap <BOP, bool_func>
    (new OP_Unary <bool, BOP, SEM>
     ( CUnwrap <BOP, bool_func> (f)));
}

template <typename SEM> bool_func Create_bin_b (bool_func a, bool_func b)
{
  return CWrap <BOP, bool_func>
    (new OP_Binary <bool, BOP, BOP, SEM>
     ( CUnwrap <BOP, bool_func> (a), CUnwrap <BOP, bool_func> (b)));
}

template <typename SEM> int_func Create_un_i (int_func f)
{
  return CWrap <IOP, int_func>
    (new OP_Unary <int, IOP, SEM>
     ( CUnwrap <IOP, int_func> (f)));
}

template <typename SEM> int_func Create_bin_i (int_func a, int_func b)
{
  return CWrap <IOP, int_func>
    (new OP_Binary <int, IOP, IOP, SEM>
     ( CUnwrap <IOP, int_func> (a), CUnwrap <IOP, int_func> (b)));
}

template <typename SEM> bool_func Create_cmp (int_func a, int_func b)
{
  return CWrap <BOP, bool_func>
    (new OP_Binary <bool, IOP, IOP, SEM>
     ( CUnwrap <IOP, int_func> (a), CUnwrap <IOP, int_func> (b)));
}





extern "C" bool_func BOP_or (bool_func a, bool_func b)
{
  return Create_bin_b <SEM_BOP_or> (a, b);
}

extern "C" bool_func BOP_xor (bool_func a, bool_func b)
{
  return Create_bin_b <SEM_BOP_xor> (a, b);
}

extern "C" bool_func BOP_and (bool_func a, bool_func b)
{
  return Create_bin_b <SEM_BOP_and> (a, b);
}

extern "C" bool_func BOP_neg (bool_func f)
{
  return Create_un_b <SEM_BOP_neg> (f);
}

extern "C" bool_func BOP_const (int value)
{
  return CWrap <BOP, bool_func> (new ConstValue <bool> ((bool) value));
}

extern "C" bool_func BOP_ref (const char* v) {}
extern "C" bool_func BOP_scoped_ref (const char* scope, const char* v) {}




extern "C" bool_func CMP_le (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_le> (a, b);
}

extern "C" bool_func CMP_ge (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_ge> (a, b);
}

extern "C" bool_func CMP_eq (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_eq> (a, b);
}

extern "C" bool_func CMP_leq (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_leq> (a, b);
}

extern "C" bool_func CMP_geq (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_geq> (a, b);
}

extern "C" bool_func CMP_neq (int_func a, int_func b)
{
  return Create_cmp <SEM_CMP_neq> (a, b);
}



extern "C" int_func IOP_add (int_func a, int_func b)
{
  return Create_bin_i <SEM_IOP_add> (a, b);
}

extern "C" int_func IOP_sub (int_func a, int_func b)
{
  return Create_bin_i <SEM_IOP_sub> (a, b);
}

extern "C" int_func IOP_mul (int_func a, int_func b)
{
  return Create_bin_i <SEM_IOP_mul> (a, b);
}

extern "C" int_func IOP_div (int_func a, int_func b)
{
  return Create_bin_i <SEM_IOP_div> (a, b);
}

extern "C" int_func IOP_mod (int_func a, int_func b)
{
  return Create_bin_i <SEM_IOP_mod> (a, b);
}

extern "C" int_func IOP_neg (int_func f)
{
  return Create_un_i <SEM_IOP_neg> (f);
}

extern "C" int_func IOP_const (int value)
{
  return CWrap <IOP, int_func> (new ConstValue <int> ( value));
}

extern "C" int_func IOP_self_id () {}
extern "C" int_func IOP_scoped_id (const char* scope) {}
