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$ */
|
|
|
|
|
|
|
|
#ifndef _custom_
|
|
|
|
#define _custom_
|
|
|
|
|
|
|
|
|
|
|
|
#include "mlvalues.h"
|
|
|
|
|
|
|
|
struct custom_operations {
|
|
|
|
char *identifier;
|
|
|
|
void (*finalize)(value v);
|
|
|
|
int (*compare)(value v1, value v2);
|
|
|
|
long (*hash)(value v);
|
|
|
|
void (*serialize)(value v,
|
|
|
|
/*out*/ unsigned long * wsize_32 /*size in bytes*/,
|
|
|
|
/*out*/ unsigned long * wsize_64 /*size in bytes*/);
|
|
|
|
unsigned long (*deserialize)(void * dst);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define custom_finalize_default NULL
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLextern int custom_compare_default(value v1, value v2);
|
2000-02-10 06:04:59 -08:00
|
|
|
#define custom_hash_default NULL
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLextern void custom_serialize_default(value v, unsigned long * wsize_32,
|
|
|
|
unsigned long * wsize_64);
|
2000-02-10 06:04:59 -08:00
|
|
|
#define custom_deserialize_default NULL
|
|
|
|
|
|
|
|
#define Custom_ops_val(v) (*((struct custom_operations **) (v)))
|
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLextern value alloc_custom(struct custom_operations * ops,
|
|
|
|
unsigned long size, /*size in bytes*/
|
|
|
|
mlsize_t mem, /*resources consumed*/
|
|
|
|
mlsize_t max /*max resources*/);
|
2000-02-11 04:03:31 -08:00
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
CAMLextern void register_custom_operations(struct custom_operations * ops);
|
2002-02-19 06:37:44 -08:00
|
|
|
|
|
|
|
/* <private> */
|
2001-08-28 07:47:48 -07:00
|
|
|
extern struct custom_operations * find_custom_operations(char * ident);
|
|
|
|
extern struct custom_operations * final_custom_operations(void (*fn)(value));
|
2000-02-10 06:04:59 -08:00
|
|
|
|
2001-08-28 07:47:48 -07:00
|
|
|
extern void init_custom_operations(void);
|
2002-02-19 06:37:44 -08:00
|
|
|
/* </private> */
|
2000-02-11 07:09:27 -08:00
|
|
|
|
2000-02-10 06:04:59 -08:00
|
|
|
#endif
|