#include <iostream>

#include <ecl/ecl.h>

// A function to be called from lisp
cl_object c_func(cl_object cl_x)
{
  int x = fixint(cl_x);
  return make_integer(2 * x);
}

inline
cl_object eval(char *str)
{
  // For simplicity
  return cl_safe_eval(c_string_to_object(str), Cnil, OBJNULL);
}

inline
cl_object symbol(char *str)
{
  // For simplicity
  return cl_intern(1, make_simple_base_string(str));
}

int main(int argc, char *argv[])
{
  cl_boot(argc, argv);

  // Registering a C function
  cl_def_c_function(symbol("C-FUNC"), (void *)c_func, 1);

  // Loading a lisp file
  eval("(load \"embedded\")");

  // Executing some lisp code and converting the result to C
  int res = fixint(eval("(emb2 10)"));
  std::cout << res << std::endl;

  cl_shutdown();
  return 0;
}