Merge ssh://192.168.66.221/~vitor/Yap/yap-6.3
This commit is contained in:
@@ -23,13 +23,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Yap.h>
|
||||
#include <Yatom.h>
|
||||
#include <iopreds.h>
|
||||
#include <Yap.h>
|
||||
#include <Yatom.h>
|
||||
#include <iopreds.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "YapText.h"
|
||||
|
||||
/* for freeBSD9.1 */
|
||||
#define _WITH_DPRINTF
|
||||
#include <stdio.h>
|
||||
@@ -37,18 +39,12 @@
|
||||
//#include <SWI-Stream.h>
|
||||
//#include <pl-shared.h>
|
||||
|
||||
|
||||
#include "swi.h"
|
||||
|
||||
static PL_blob_t unregistered_blob_atom =
|
||||
{ PL_BLOB_MAGIC,
|
||||
PL_BLOB_NOCOPY|PL_BLOB_TEXT,
|
||||
"unregistered"
|
||||
};
|
||||
static PL_blob_t unregistered_blob_atom = {
|
||||
PL_BLOB_MAGIC, PL_BLOB_NOCOPY | PL_BLOB_TEXT, "unregistered"};
|
||||
|
||||
int
|
||||
PL_is_blob(term_t t, PL_blob_t **type)
|
||||
{
|
||||
int PL_is_blob(term_t t, PL_blob_t **type) {
|
||||
CACHE_REGS
|
||||
Term yt = Yap_GetFromSlot(t);
|
||||
Atom a;
|
||||
@@ -69,8 +65,7 @@ PL_is_blob(term_t t, PL_blob_t **type)
|
||||
/* void check_chain(void); */
|
||||
|
||||
PL_EXPORT(int)
|
||||
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
{
|
||||
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type) {
|
||||
CACHE_REGS
|
||||
AtomEntry *ae;
|
||||
|
||||
@@ -87,15 +82,14 @@ PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
}
|
||||
|
||||
PL_EXPORT(int)
|
||||
PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
{
|
||||
PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type) {
|
||||
CACHE_REGS
|
||||
AtomEntry *ae;
|
||||
int ret;
|
||||
|
||||
if (!blob)
|
||||
return FALSE;
|
||||
ae = Yap_lookupBlob(blob, len, type, & ret);
|
||||
ae = Yap_lookupBlob(blob, len, type, &ret);
|
||||
if (!ae) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -107,8 +101,7 @@ PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
|
||||
}
|
||||
|
||||
PL_EXPORT(int)
|
||||
PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type)
|
||||
{
|
||||
PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type) {
|
||||
CACHE_REGS
|
||||
Atom a;
|
||||
Term tt;
|
||||
@@ -129,59 +122,47 @@ PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type)
|
||||
*len = ae->rep.blob[0].length;
|
||||
if (blob)
|
||||
*blob = ae->rep.blob[0].data;
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
PL_EXPORT(void*)
|
||||
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type)
|
||||
{
|
||||
PL_EXPORT(void *)
|
||||
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type) {
|
||||
Atom x = SWIAtomToAtom(a);
|
||||
|
||||
if (!IsBlob(x)) {
|
||||
if (IsWideAtom(x)) {
|
||||
if ( len )
|
||||
*len = wcslen(x->WStrOfAE);
|
||||
if ( type )
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->WStrOfAE;
|
||||
}
|
||||
if ( len )
|
||||
*len = strlen(x->StrOfAE);
|
||||
if ( type )
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->StrOfAE;
|
||||
if (len)
|
||||
*len = strlen_utf8(x->UStrOfAE);
|
||||
if (type)
|
||||
*type = &unregistered_blob_atom;
|
||||
return x->StrOfAE;
|
||||
}
|
||||
if ( len )
|
||||
if (len)
|
||||
*len = x->rep.blob[0].length;
|
||||
if ( type )
|
||||
if (type)
|
||||
*type = (struct PL_blob_t *)RepBlobProp(x->PropsOfAE)->blob_type;
|
||||
|
||||
return x->rep.blob[0].data;
|
||||
}
|
||||
|
||||
PL_EXPORT(void)
|
||||
PL_register_blob_type(PL_blob_t *type)
|
||||
{
|
||||
PL_register_blob_type(PL_blob_t *type) {
|
||||
type->next = (PL_blob_t *)BlobTypes;
|
||||
BlobTypes = (struct YAP_blob_t *)type;
|
||||
}
|
||||
|
||||
PL_EXPORT(PL_blob_t*)
|
||||
PL_find_blob_type(const char* name)
|
||||
{
|
||||
PL_EXPORT(PL_blob_t *)
|
||||
PL_find_blob_type(const char *name) {
|
||||
Atom at = Yap_LookupAtom((char *)name);
|
||||
|
||||
return YAP_find_blob_type((YAP_Atom)at);
|
||||
}
|
||||
|
||||
PL_EXPORT(int)
|
||||
PL_unregister_blob_type(PL_blob_t *type)
|
||||
{
|
||||
fprintf(stderr,"PL_unregister_blob_type not implemented yet\n");
|
||||
PL_unregister_blob_type(PL_blob_t *type) {
|
||||
fprintf(stderr, "PL_unregister_blob_type not implemented yet\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user