| 
									
										
										
										
											2014-05-12 17:49:11 +01:00
										 |  |  | /*************************************************************************
 | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *	 YAP Prolog 							 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *	Yap Prolog was developed at NCCUP - Universidade do Porto	 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-2014	 * | 
					
						
							|  |  |  | *									 * | 
					
						
							|  |  |  | *************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-13 13:28:17 +01:00
										 |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2015-01-04 23:58:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     @{ | 
					
						
							| 
									
										
										
										
											2015-04-13 13:28:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-01-04 23:58:23 +00:00
										 |  |  |     @file swi.h | 
					
						
							| 
									
										
										
										
											2014-05-12 17:49:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   @defgroup swi-c-interface SWI-Prolog Foreign Language Interface | 
					
						
							| 
									
										
										
										
											2017-04-07 23:10:59 +01:00
										 |  |  |   @ingroup fli_c_cx | 
					
						
							| 
									
										
										
										
											2014-05-12 17:49:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-14 10:01:11 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  *    @tableofcontents | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * A reimplementation of Jan Wielemaker's SWI-Prolog C-language interface, it supports | 
					
						
							|  |  |  |  * most of the functionality in the original implementation. It allows for: | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *   - Term Construction, Access, and Unification | 
					
						
							|  |  |  |  *   - Manipulation of Atoms, Strings, Lists of Codes and Lists of Atoms | 
					
						
							|  |  |  |  *   - Query evaluation | 
					
						
							|  |  |  |  *   - Thread and Prolog engine management | 
					
						
							|  |  |  |  *   - Data-Base Access | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * In this interface, all Prolog data known by C is referenced through term references (term_t), hence | 
					
						
							|  |  |  |  * Prolog has all the information necessary to perform its memory management without special precautions | 
					
						
							|  |  |  |  *  from the C programmer. | 
					
						
							| 
									
										
										
										
											2014-05-12 17:49:11 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2015-06-19 01:29:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef SWI_H
 | 
					
						
							|  |  |  | #define SWI_H 1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "SWI-Prolog.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-30 21:59:45 +00:00
										 |  |  | void Yap_swi_install(void); | 
					
						
							|  |  |  | void Yap_install_blobs(void); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline Term | 
					
						
							|  |  |  | SWIModuleToModule(module_t m) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-03-07 16:02:55 +00:00
										 |  |  |   CACHE_REGS | 
					
						
							| 
									
										
										
										
											2010-11-30 21:59:45 +00:00
										 |  |  |   if (m) | 
					
						
							| 
									
										
										
										
											2013-11-13 10:38:20 +00:00
										 |  |  |     return MkAtomTerm(m->AtomOfME); | 
					
						
							| 
									
										
										
										
											2010-11-30 21:59:45 +00:00
										 |  |  |   if (CurrentModule) | 
					
						
							|  |  |  |     return CurrentModule; | 
					
						
							|  |  |  |   return USER_MODULE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-19 01:29:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef YATOM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline atom_t | 
					
						
							|  |  |  | AtomToSWIAtom(Atom at) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return (atom_t)at; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline Atom | 
					
						
							|  |  |  | SWIAtomToAtom(atom_t at) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return (Atom)at; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-07 16:57:53 -05:00
										 |  |  | static inline functor_t | 
					
						
							|  |  |  | FunctorToSWIFunctor(Functor f) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return (functor_t)f; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-19 01:29:16 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static inline Functor | 
					
						
							|  |  |  | SWIFunctorToFunctor(functor_t f) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return (Functor)f; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-21 00:22:03 +00:00
										 |  |  | #define isDefinedProcedure(pred) TRUE // TBD
 | 
					
						
							| 
									
										
										
										
											2014-05-14 10:01:11 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-19 01:29:16 +01:00
										 |  |  | int Yap_write_blob(AtomEntry *ref,  FILE *stream); | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-14 10:01:11 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |   @} | 
					
						
							|  |  |  | */ |