OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SchemeAdHoc.cc
Go to the documentation of this file.
1 /*
2  * SchemeAdHoc.c
3  *
4  * Scheme adhoc callback into opencog
5  *
6  * Copyright (c) 2008 Linas Vepstas <linas@linas.org>
7  */
8 
9 #ifdef HAVE_GUILE
10 
11 #include <libguile.h>
12 #include "SchemeSmob.h"
13 
14 using namespace opencog;
15 
16 /* ============================================================== */
17 
22 SCM SchemeSmob::ss_ad_hoc(SCM command, SCM optargs)
23 {
24  std::string cmdname = verify_string (command, "cog-ad-hoc", 2, "string command name");
25 
26 #if REVIVE_OLD_C_CODE_FOR_SENTENCE_PATTERN_MATCH
27  // As of September 2009, this code is "obsolete", in that all sentence
28  // pattern matching is now done via scheme, and not C++. This makes
29  // sentence-handling code simpler, easier to structure, and less
30  // squirmy. The code below can be deleted after its allowed to smolder
31  // for a while, say, sometime in 2010. We keep it just in case :-)
32  if (0 == cmdname.compare("question")) {
33  Handle h = verify_handle(optargs, "cog-ad-hoc question", 2);
34  AtomSpace *as = &atomspace();
35 
36  SentenceQuery rlx;
37  if (rlx.is_query(h)) {
38  rlx.solve(as, h);
39  return SCM_BOOL_T;
40  }
41  return SCM_BOOL_F;
42 #if EXAMPLE_FRAME_QUERY_API
43  FrameQuery frq;
44  if (frq.is_query(h)) {
45  frq.solve(as, h);
46  }
47 #endif
48 
49  return handle_to_scm(h);
50  }
51 #endif // REVIVE_OLD_C_CODE_FOR_SENTENCE_PATTERN_MATCH
52  return SCM_BOOL_F;
53 }
54 
55 #endif
56 /* ===================== END OF FILE ============================ */
static std::string verify_string(SCM, const char *, int pos=1, const char *msg="expecting string")
static Handle verify_handle(SCM, const char *, int pos=1)
static SCM handle_to_scm(Handle)
static SCM ss_ad_hoc(SCM, SCM)
Definition: SchemeAdHoc.cc:22