jpayne@69: /* jpayne@69: * tclOO.h -- jpayne@69: * jpayne@69: * This file contains the public API definitions and some of the function jpayne@69: * declarations for the object-system (NB: not Tcl_Obj, but ::oo). jpayne@69: * jpayne@69: * Copyright (c) 2006-2010 by Donal K. Fellows jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #ifndef TCLOO_H_INCLUDED jpayne@69: #define TCLOO_H_INCLUDED jpayne@69: jpayne@69: /* jpayne@69: * Be careful when it comes to versioning; need to make sure that the jpayne@69: * standalone TclOO version matches. Also make sure that this matches the jpayne@69: * version in the files: jpayne@69: * jpayne@69: * tests/oo.test jpayne@69: * tests/ooNext2.test jpayne@69: * unix/tclooConfig.sh jpayne@69: * win/tclooConfig.sh jpayne@69: */ jpayne@69: jpayne@69: #define TCLOO_VERSION "1.1.0" jpayne@69: #define TCLOO_PATCHLEVEL TCLOO_VERSION jpayne@69: jpayne@69: #include "tcl.h" jpayne@69: jpayne@69: /* jpayne@69: * For C++ compilers, use extern "C" jpayne@69: */ jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: extern const char *TclOOInitializeStubs( jpayne@69: Tcl_Interp *, const char *version); jpayne@69: #define Tcl_OOInitStubs(interp) \ jpayne@69: TclOOInitializeStubs((interp), TCLOO_VERSION) jpayne@69: #ifndef USE_TCL_STUBS jpayne@69: # define TclOOInitializeStubs(interp, version) (TCLOO_PATCHLEVEL) jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * These are opaque types. jpayne@69: */ jpayne@69: jpayne@69: typedef struct Tcl_Class_ *Tcl_Class; jpayne@69: typedef struct Tcl_Method_ *Tcl_Method; jpayne@69: typedef struct Tcl_Object_ *Tcl_Object; jpayne@69: typedef struct Tcl_ObjectContext_ *Tcl_ObjectContext; jpayne@69: jpayne@69: /* jpayne@69: * Public datatypes for callbacks and structures used in the TIP#257 (OO) jpayne@69: * implementation. These are used to implement custom types of method calls jpayne@69: * and to allow the attachment of arbitrary data to objects and classes. jpayne@69: */ jpayne@69: jpayne@69: typedef int (Tcl_MethodCallProc)(void *clientData, Tcl_Interp *interp, jpayne@69: Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv); jpayne@69: typedef void (Tcl_MethodDeleteProc)(void *clientData); jpayne@69: typedef int (Tcl_CloneProc)(Tcl_Interp *interp, void *oldClientData, jpayne@69: void **newClientData); jpayne@69: typedef void (Tcl_ObjectMetadataDeleteProc)(void *clientData); jpayne@69: typedef int (Tcl_ObjectMapMethodNameProc)(Tcl_Interp *interp, jpayne@69: Tcl_Object object, Tcl_Class *startClsPtr, Tcl_Obj *methodNameObj); jpayne@69: jpayne@69: /* jpayne@69: * The type of a method implementation. This describes how to call the method jpayne@69: * implementation, how to delete it (when the object or class is deleted) and jpayne@69: * how to create a clone of it (when the object or class is copied). jpayne@69: */ jpayne@69: jpayne@69: typedef struct { jpayne@69: int version; /* Structure version field. Always to be equal jpayne@69: * to TCL_OO_METHOD_VERSION_CURRENT in jpayne@69: * declarations. */ jpayne@69: const char *name; /* Name of this type of method, mostly for jpayne@69: * debugging purposes. */ jpayne@69: Tcl_MethodCallProc *callProc; jpayne@69: /* How to invoke this method. */ jpayne@69: Tcl_MethodDeleteProc *deleteProc; jpayne@69: /* How to delete this method's type-specific jpayne@69: * data, or NULL if the type-specific data jpayne@69: * does not need deleting. */ jpayne@69: Tcl_CloneProc *cloneProc; /* How to copy this method's type-specific jpayne@69: * data, or NULL if the type-specific data can jpayne@69: * be copied directly. */ jpayne@69: } Tcl_MethodType; jpayne@69: jpayne@69: /* jpayne@69: * The correct value for the version field of the Tcl_MethodType structure. jpayne@69: * This allows new versions of the structure to be introduced without breaking jpayne@69: * binary compatibility. jpayne@69: */ jpayne@69: jpayne@69: #define TCL_OO_METHOD_VERSION_CURRENT 1 jpayne@69: jpayne@69: /* jpayne@69: * The type of some object (or class) metadata. This describes how to delete jpayne@69: * the metadata (when the object or class is deleted) and how to create a jpayne@69: * clone of it (when the object or class is copied). jpayne@69: */ jpayne@69: jpayne@69: typedef struct { jpayne@69: int version; /* Structure version field. Always to be equal jpayne@69: * to TCL_OO_METADATA_VERSION_CURRENT in jpayne@69: * declarations. */ jpayne@69: const char *name; jpayne@69: Tcl_ObjectMetadataDeleteProc *deleteProc; jpayne@69: /* How to delete the metadata. This must not jpayne@69: * be NULL. */ jpayne@69: Tcl_CloneProc *cloneProc; /* How to copy the metadata, or NULL if the jpayne@69: * type-specific data can be copied jpayne@69: * directly. */ jpayne@69: } Tcl_ObjectMetadataType; jpayne@69: jpayne@69: /* jpayne@69: * The correct value for the version field of the Tcl_ObjectMetadataType jpayne@69: * structure. This allows new versions of the structure to be introduced jpayne@69: * without breaking binary compatibility. jpayne@69: */ jpayne@69: jpayne@69: #define TCL_OO_METADATA_VERSION_CURRENT 1 jpayne@69: jpayne@69: /* jpayne@69: * Include all the public API, generated from tclOO.decls. jpayne@69: */ jpayne@69: jpayne@69: #include "tclOODecls.h" jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * Local Variables: jpayne@69: * mode: c jpayne@69: * c-basic-offset: 4 jpayne@69: * fill-column: 78 jpayne@69: * End: jpayne@69: */