tclOO.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * tclOO.h --
  3. *
  4. * This file contains the public API definitions and some of the function
  5. * declarations for the object-system (NB: not Tcl_Obj, but ::oo).
  6. *
  7. * Copyright (c) 2006-2010 by Donal K. Fellows
  8. *
  9. * See the file "license.terms" for information on usage and redistribution of
  10. * this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11. */
  12. #ifndef TCLOO_H_INCLUDED
  13. #define TCLOO_H_INCLUDED
  14. /*
  15. * Be careful when it comes to versioning; need to make sure that the
  16. * standalone TclOO version matches. Also make sure that this matches the
  17. * version in the files:
  18. *
  19. * tests/oo.test
  20. * tests/ooNext2.test
  21. * unix/tclooConfig.sh
  22. * win/tclooConfig.sh
  23. */
  24. #define TCLOO_VERSION "1.1.0"
  25. #define TCLOO_PATCHLEVEL TCLOO_VERSION
  26. #include "tcl.h"
  27. /*
  28. * For C++ compilers, use extern "C"
  29. */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. extern const char *TclOOInitializeStubs(
  34. Tcl_Interp *, const char *version);
  35. #define Tcl_OOInitStubs(interp) \
  36. TclOOInitializeStubs((interp), TCLOO_VERSION)
  37. #ifndef USE_TCL_STUBS
  38. # define TclOOInitializeStubs(interp, version) (TCLOO_PATCHLEVEL)
  39. #endif
  40. /*
  41. * These are opaque types.
  42. */
  43. typedef struct Tcl_Class_ *Tcl_Class;
  44. typedef struct Tcl_Method_ *Tcl_Method;
  45. typedef struct Tcl_Object_ *Tcl_Object;
  46. typedef struct Tcl_ObjectContext_ *Tcl_ObjectContext;
  47. /*
  48. * Public datatypes for callbacks and structures used in the TIP#257 (OO)
  49. * implementation. These are used to implement custom types of method calls
  50. * and to allow the attachment of arbitrary data to objects and classes.
  51. */
  52. typedef int (Tcl_MethodCallProc)(ClientData clientData, Tcl_Interp *interp,
  53. Tcl_ObjectContext objectContext, int objc, Tcl_Obj *const *objv);
  54. typedef void (Tcl_MethodDeleteProc)(ClientData clientData);
  55. typedef int (Tcl_CloneProc)(Tcl_Interp *interp, ClientData oldClientData,
  56. ClientData *newClientData);
  57. typedef void (Tcl_ObjectMetadataDeleteProc)(ClientData clientData);
  58. typedef int (Tcl_ObjectMapMethodNameProc)(Tcl_Interp *interp,
  59. Tcl_Object object, Tcl_Class *startClsPtr, Tcl_Obj *methodNameObj);
  60. /*
  61. * The type of a method implementation. This describes how to call the method
  62. * implementation, how to delete it (when the object or class is deleted) and
  63. * how to create a clone of it (when the object or class is copied).
  64. */
  65. typedef struct {
  66. int version; /* Structure version field. Always to be equal
  67. * to TCL_OO_METHOD_VERSION_CURRENT in
  68. * declarations. */
  69. const char *name; /* Name of this type of method, mostly for
  70. * debugging purposes. */
  71. Tcl_MethodCallProc *callProc;
  72. /* How to invoke this method. */
  73. Tcl_MethodDeleteProc *deleteProc;
  74. /* How to delete this method's type-specific
  75. * data, or NULL if the type-specific data
  76. * does not need deleting. */
  77. Tcl_CloneProc *cloneProc; /* How to copy this method's type-specific
  78. * data, or NULL if the type-specific data can
  79. * be copied directly. */
  80. } Tcl_MethodType;
  81. /*
  82. * The correct value for the version field of the Tcl_MethodType structure.
  83. * This allows new versions of the structure to be introduced without breaking
  84. * binary compatability.
  85. */
  86. #define TCL_OO_METHOD_VERSION_CURRENT 1
  87. /*
  88. * The type of some object (or class) metadata. This describes how to delete
  89. * the metadata (when the object or class is deleted) and how to create a
  90. * clone of it (when the object or class is copied).
  91. */
  92. typedef struct {
  93. int version; /* Structure version field. Always to be equal
  94. * to TCL_OO_METADATA_VERSION_CURRENT in
  95. * declarations. */
  96. const char *name;
  97. Tcl_ObjectMetadataDeleteProc *deleteProc;
  98. /* How to delete the metadata. This must not
  99. * be NULL. */
  100. Tcl_CloneProc *cloneProc; /* How to copy the metadata, or NULL if the
  101. * type-specific data can be copied
  102. * directly. */
  103. } Tcl_ObjectMetadataType;
  104. /*
  105. * The correct value for the version field of the Tcl_ObjectMetadataType
  106. * structure. This allows new versions of the structure to be introduced
  107. * without breaking binary compatability.
  108. */
  109. #define TCL_OO_METADATA_VERSION_CURRENT 1
  110. /*
  111. * Include all the public API, generated from tclOO.decls.
  112. */
  113. #include "tclOODecls.h"
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117. #endif
  118. /*
  119. * Local Variables:
  120. * mode: c
  121. * c-basic-offset: 4
  122. * fill-column: 78
  123. * End:
  124. */