2000-02-10 06:04:59 -08:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Objective Caml */
|
|
|
|
/* */
|
|
|
|
/* Manuel Serrano and Xavier Leroy, INRIA Rocquencourt */
|
|
|
|
/* */
|
|
|
|
/* Copyright 2000 Institut National de Recherche en Informatique et */
|
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../LICENSE. */
|
2000-02-10 06:04:59 -08:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2003-12-15 08:29:53 -08:00
|
|
|
#ifndef CAML_CUSTOM_H
|
|
|
|
#define CAML_CUSTOM_H
|
2000-02-10 06:04:59 -08:00
|
|
|
|
|
|
|
|
2003-12-29 14:15:02 -08:00
|
|
|
#ifndef CAML_NAME_SPACE
|
2003-12-15 08:29:53 -08:00
|
|
|
#include "compatibility.h"
|
2003-12-29 14:15:02 -08:00
|
|
|
#endif
|
2000-02-10 06:04:59 -08:00
|
|
|
#include "mlvalues.h"
|
|
|
|
|
|
|
|
struct custom_operations {
|
|
|
|
char *identifier;
|
|
|
|
void (*finalize)(value v);
|
|
|
|
int (*compare)(value v1, value v2);
|
2005-09-22 07:21:50 -07:00
|
|
|
intnat (*hash)(value v);
|
2000-02-10 06:04:59 -08:00
|
|
|
void (*serialize)(value v,
|
2005-09-22 07:21:50 -07:00
|
|
|
/*out*/ uintnat * wsize_32 /*size in bytes*/,
|
|
|
|
/*out*/ uintnat * wsize_64 /*size in bytes*/);
|
|
|
|
uintnat (*deserialize)(void * dst);
|
2000-02-10 06:04:59 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define custom_finalize_default NULL
|
2002-06-07 02:49:45 -07:00
|
|
|
#define custom_compare_default NULL
|
2000-02-10 06:04:59 -08:00
|
|
|
#define custom_hash_default NULL
|
2002-06-07 02:49:45 -07:00
|
|
|
#define custom_serialize_default NULL
|
2000-02-10 06:04:59 -08:00
|
|
|
#define custom_deserialize_default NULL
|
|
|
|
|
|
|
|
#define Custom_ops_val(v) (*((struct custom_operations **) (v)))
|
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
CAMLextern value caml_alloc_custom(struct custom_operations * ops,
|
2005-09-22 07:21:50 -07:00
|
|
|
uintnat size, /*size in bytes*/
|
2004-01-01 08:42:43 -08:00
|
|
|
mlsize_t mem, /*resources consumed*/
|
|
|
|
mlsize_t max /*max resources*/);
|
2000-02-11 04:03:31 -08:00
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
CAMLextern void caml_register_custom_operations(struct custom_operations * ops);
|
2002-02-19 06:37:44 -08:00
|
|
|
|
2005-03-24 09:20:54 -08:00
|
|
|
CAMLextern int caml_compare_unordered;
|
|
|
|
/* Used by custom comparison to report unordered NaN-like cases. */
|
|
|
|
|
2002-02-19 06:37:44 -08:00
|
|
|
/* <private> */
|
2004-01-01 08:42:43 -08:00
|
|
|
extern struct custom_operations * caml_find_custom_operations(char * ident);
|
|
|
|
extern struct custom_operations *
|
|
|
|
caml_final_custom_operations(void (*fn)(value));
|
2000-02-10 06:04:59 -08:00
|
|
|
|
2004-01-01 08:42:43 -08:00
|
|
|
extern void caml_init_custom_operations(void);
|
2002-02-19 06:37:44 -08:00
|
|
|
/* </private> */
|
2000-02-11 07:09:27 -08:00
|
|
|
|
2003-12-15 08:29:53 -08:00
|
|
|
#endif /* CAML_CUSTOM_H */
|