Skip to content

Commit

Permalink
Fix [afdb56e633]: Tcl_MethodType2 not documented
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 3, 2025
2 parents 388084f + 9727cd0 commit ed91fb4
Showing 1 changed file with 40 additions and 9 deletions.
49 changes: 40 additions & 9 deletions doc/Method.3
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.BS
'\" Note: do not modify the .SH NAME line immediately below!
.SH NAME
Tcl_ClassSetConstructor, Tcl_ClassSetDestructor, Tcl_MethodDeclarerClass, Tcl_MethodDeclarerObject, Tcl_MethodIsPublic, Tcl_MethodIsPrivate, Tcl_MethodIsType, Tcl_MethodName, Tcl_NewInstanceMethod, Tcl_NewMethod, Tcl_ObjectContextInvokeNext, Tcl_ObjectContextIsFiltering, Tcl_ObjectContextMethod, Tcl_ObjectContextObject, Tcl_ObjectContextSkippedArgs \- manipulate methods and method-call contexts
Tcl_ClassSetConstructor, Tcl_ClassSetDestructor, Tcl_MethodDeclarerClass, Tcl_MethodDeclarerObject, Tcl_MethodIsPublic, Tcl_MethodIsPrivate, Tcl_MethodIsType, Tcl_MethodIsType2, Tcl_MethodName, Tcl_NewInstanceMethod, Tcl_NewInstanceMethod2, Tcl_NewMethod, Tcl_NewMethod2, Tcl_ObjectContextInvokeNext, Tcl_ObjectContextIsFiltering, Tcl_ObjectContextMethod, Tcl_ObjectContextObject, Tcl_ObjectContextSkippedArgs \- manipulate methods and method-call contexts
.SH SYNOPSIS
.nf
\fB#include <tclOO.h>\fR
Expand All @@ -19,9 +19,17 @@ Tcl_Method
clientData\fR)
.sp
Tcl_Method
\fBTcl_NewMethod2\fR(\fIinterp, class, nameObj, flags, methodType2Ptr,
clientData\fR)
.sp
Tcl_Method
\fBTcl_NewInstanceMethod\fR(\fIinterp, object, nameObj, flags, methodTypePtr,
clientData\fR)
.sp
Tcl_Method
\fBTcl_NewInstanceMethod2\fR(\fIinterp, object, nameObj, flags, methodType2Ptr,
clientData\fR)
.sp
\fBTcl_ClassSetConstructor\fR(\fIinterp, class, method\fR)
.sp
\fBTcl_ClassSetDestructor\fR(\fIinterp, class, method\fR)
Expand All @@ -47,6 +55,9 @@ int
\fBTcl_MethodIsType\fR(\fImethod, methodTypePtr, clientDataPtr\fR)
.sp
int
\fBTcl_MethodIsType2\fR(\fImethod, methodType2Ptr, clientDataPtr\fR)
.sp
int
\fBTcl_ObjectContextInvokeNext\fR(\fIinterp, context, objc, objv, skip\fR)
.sp
int
Expand Down Expand Up @@ -84,6 +95,9 @@ and \fBTCL_OO_METHOD_PRIVATE\fR for a private method.
.AP Tcl_MethodType *methodTypePtr in
A description of the type of the method to create, or the type of method to
compare against.
.AP Tcl_MethodType2 *methodType2Ptr in
A description of the type of the method to create, or the type of method to
compare against.
.AP void *clientData in
A piece of data that is passed to the implementation of the method without
interpretation.
Expand Down Expand Up @@ -126,30 +140,32 @@ can also be introspected upon to a limited degree; the function
\fBTcl_MethodIsType\fR returns whether a method is of a particular type,
assigning the per-method \fIclientData\fR to the variable pointed to by
\fIclientDataPtr\fR if (that is non-NULL) if the type is matched.
\fBTcl_MethodIsType2\fR does the same for TCL_OO_METHOD_VERSION_2.
.SS "METHOD CREATION"
.PP
Methods are created by \fBTcl_NewMethod\fR and \fBTcl_NewInstanceMethod\fR,
which
or by \fBTcl_NewMethod2\fR and \fBTcl_NewInstanceMethod2\fR which
create a method attached to a class or an object respectively. In both cases,
the \fInameObj\fR argument gives the name of the method to create, the
\fIflags\fR argument states whether the method should be exported
initially
.VS TIP500
or be marked as a private method,
.VE TIP500
the \fImethodTypePtr\fR argument describes the implementation of
the \fImethodTypePtr\fR or \fImethodType2Ptr\fR (for TCL_OO_METHOD_VERSION_2)
argument describes the implementation of
the method (see the \fBMETHOD TYPES\fR section below) and the \fIclientData\fR
argument gives some implementation-specific data that is passed on to the
implementation of the method when it is called.
.PP
When the \fInameObj\fR argument to \fBTcl_NewMethod\fR is NULL, an
When the \fInameObj\fR argument to \fBTcl_NewMethod\fR or \fBTcl_NewMethod2\fR is NULL, an
unnamed method is created, which is used for constructors and destructors.
Constructors should be installed into their class using the
\fBTcl_ClassSetConstructor\fR function, and destructors (which must not
require any arguments) should be installed into their class using the
\fBTcl_ClassSetDestructor\fR function. Unnamed methods should not be used for
any other purpose, and named methods should not be used as either constructors
or destructors. Also note that a NULL \fImethodTypePtr\fR is used to provide
or destructors. Also note that a NULL \fImethodTypePtr\fR or \fImethodType2Ptr\fR is used to provide
internal signaling, and should not be used in client code.
.SS "METHOD CALL CONTEXTS"
.PP
Expand Down Expand Up @@ -178,8 +194,8 @@ executing. Note also that the method-call context is \fInever\fR deleted
during the execution of this function.
.SH "METHOD TYPES"
.PP
The types of methods are described by a pointer to a Tcl_MethodType structure,
which is defined as:
The types of methods are described by a pointer to a Tcl_MethodType or
Tcl_MethodType2 (for TCL_OO_METHOD_VERSION_2) structure, which are defined as:
.PP
.CS
typedef struct {
Expand All @@ -189,10 +205,18 @@ typedef struct {
Tcl_MethodDeleteProc *\fIdeleteProc\fR;
Tcl_CloneProc *\fIcloneProc\fR;
} \fBTcl_MethodType\fR;

typedef struct {
int \fIversion\fR;
const char *\fIname\fR;
Tcl_MethodCallProc2 *\fIcallProc\fR;
Tcl_MethodDeleteProc *\fIdeleteProc\fR;
Tcl_CloneProc *\fIcloneProc\fR;
} \fBTcl_MethodType2\fR;
.CE
.PP
The \fIversion\fR field allows for future expansion of the structure, and
should always be declared equal to TCL_OO_METHOD_VERSION_CURRENT. The
The \fIversion\fR field should always be declared equal to TCL_OO_METHOD_VERSION_CURRENT,
TCL_OO_METHOD_VERSION_1 or TCL_OO_METHOD_VERSION_2. The
\fIname\fR field provides a human-readable name for the type, and is the value
that is exposed via the \fBinfo class methodtype\fR and
\fBinfo object methodtype\fR Tcl commands.
Expand All @@ -219,6 +243,13 @@ typedef int \fBTcl_MethodCallProc\fR(
Tcl_ObjectContext \fIobjectContext\fR,
int \fIobjc\fR,
Tcl_Obj *const *\fIobjv\fR);

typedef int \fBTcl_MethodCallProc2\fR(
void *\fIclientData\fR,
Tcl_Interp *\fIinterp\fR,
Tcl_ObjectContext \fIobjectContext\fR,
Tcl_Size \fIobjc\fR,
Tcl_Obj *const *\fIobjv\fR);
.CE
.PP
The \fIclientData\fR argument to a Tcl_MethodCallProc is the value that was
Expand Down

0 comments on commit ed91fb4

Please sign in to comment.