Пример #1
0
void *
PL_get_dbref(term_t t, db_ref_type *type_ptr)
{ void *data;
  PL_blob_t *type;

  if ( !PL_get_blob(t, &data, NULL, &type) )
  { error:
    PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_db_reference, t);
    return NULL;
  }

  if ( type == &clause_blob )
  { clref *ref = data;

    if ( false(ref->clause, CL_ERASED) )
    { *type_ptr = DB_REF_CLAUSE;
      return ref->clause;
    }
  } else if ( type == &record_blob )
  { recref *ref = data;

    if ( ref->record->record &&
	 false(ref->record->record, R_ERASED) )
    { *type_ptr = DB_REF_RECORD;
      return ref->record;
    }
  } else
  { goto error;
  }

  return NULL;
}
Пример #2
0
// get my_server_thread from BLOB
static int get_server(term_t server, my_server_thread *a)
{ 
	PL_blob_t *type;
	size_t    len;
	my_server_thread *a1;
  
	PL_get_blob(server, (void **)&a1, &len, &type);
	if (type != &server_blob) {
		return type_error(server, "osc_server");
	} else {
		*a=*a1;
		return TRUE;
	}
} 
Пример #3
0
// get lo_address from BLOB
static int get_addr(term_t addr, lo_address *a)
{ 
	PL_blob_t *type;
	size_t    len;
	lo_address *a1;
  
	PL_get_blob(addr, (void **)&a1, &len, &type);
	if (type != &addr_blob) {
		return type_error(addr, "osc_address");
	} else {
		*a=*a1;
		return TRUE;
	}
} 
Пример #4
0
int
PL_get_clref(term_t t, Clause *cl)
{ struct clref *ref;
  PL_blob_t *type;

  if ( !PL_get_blob(t, (void**)&ref, NULL, &type) ||
       type != &clause_blob )
    return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_db_reference, t);

  *cl = ref->clause;

  if ( true(ref->clause, CL_ERASED) )
    return -1;

  return TRUE;
}
Пример #5
0
gboolean
plgi_blob_is_a(term_t t,
               GType gtype)
{
  PL_blob_t *blob_type;
  gpointer data;

  if ( PL_get_blob(t, &data, NULL, &blob_type) && blob_type == &plgi_blob )
  { PLGIBlob *blob = data;
    if ( blob->magic == PLGI_BLOB_MAGIC &&
         g_type_is_a( blob->gtype, gtype ) )
    { return TRUE;
    }
  }

  return FALSE;
}
Пример #6
0
int
PL_get_recref(term_t t, RecordRef *rec)
{ struct recref *ref;
  PL_blob_t *type;

  if ( !PL_get_blob(t, (void**)&ref, NULL, &type) ||
       type != &record_blob )
    return PL_error(NULL, 0, NULL, ERR_TYPE, ATOM_db_reference, t);

  if ( ref->record->record &&
       false(ref->record->record, R_ERASED) )
  { *rec = ref->record;
    return TRUE;
  }

  return FALSE;
}
Пример #7
0
static int get_clingo(term_t t, clingo_env **ccontrol) {
    PL_blob_t *type;
    void *data;

    if (PL_get_blob(t, &data, NULL, &type) && type == &clingo_blob) {
        clingo_wrapper *ar = data;

        assert(ar->magic == CLINGO_MAGIC);
        if (!ar->clingo->control) {
            return PL_existence_error("clingo", t);
        }
        *ccontrol = ar->clingo;

        return TRUE;
    }

    return PL_type_error("clingo", t);
}
Пример #8
0
static int
get_archive(term_t t, archive_wrapper **arp)
{ PL_blob_t *type;
  void *data;

  if ( PL_get_blob(t, &data, NULL, &type) && type == &archive_blob)
  { archive_wrapper *ar = data;

    assert(ar->magic == ARCHIVE_MAGIC);

    if ( ar->symbol )
    { *arp = ar;

      return TRUE;
    }

    PL_permission_error("access", "closed_archive", t);
    return FALSE;
  }

  return PL_type_error("archive", t);
}
Пример #9
0
gboolean
plgi_get_blob(term_t     t,
              PLGIBlob **blob)
{
  PLGIBlob *blob0;
  PL_blob_t *type;
  gpointer blob_data;

  if ( !( PL_get_blob(t, &blob_data, NULL, &type) &&
          type == &plgi_blob ) )
  { return FALSE;
  }

  blob0 = blob_data;

  if ( blob0->magic != PLGI_BLOB_MAGIC )
  { return FALSE;
  }

  *blob = blob0;

  return TRUE;
}