[26163] trunk/base/src/tclobjc1.0

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 14 14:52:30 PDT 2007


Revision: 26163
          http://trac.macosforge.org/projects/macports/changeset/26163
Author:   landonf at macports.org
Date:     2007-06-14 14:52:29 -0700 (Thu, 14 Jun 2007)

Log Message:
-----------
Add support for unsigned integer arguments.
Clean up method argument type handling to not inject code into NSMethodSignature

Modified Paths:
--------------
    trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.h
    trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.m
    trunk/base/src/tclobjc1.0/tclobjc.m

Added Paths:
-----------
    trunk/base/src/tclobjc1.0/tclobjc_types.m

Removed Paths:
-------------
    trunk/base/src/tclobjc1.0/tclobjc_types.c

Modified: trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.h
===================================================================
--- trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.h	2007-06-14 21:34:58 UTC (rev 26162)
+++ trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.h	2007-06-14 21:52:29 UTC (rev 26163)
@@ -35,10 +35,6 @@
 
 #include <Foundation/Foundation.h>
 
- at interface NSMethodSignature (MPMethodSignatureExtensions)
-
-- (unsigned int) getArgumentTypeSpecifierAtIndex: (unsigned) index;
-- (const char *) getArgumentTypeStringAtIndex: (unsigned) index;
-- (const char*) methodReturnTypeString;
-
- at end
+unsigned int tclobjc_getarg_typespecifier (NSMethodSignature* signature, unsigned int index);
+const char *tclobjc_getarg_typestring (NSMethodSignature* signature, unsigned int index);
+const char *tclobjc_getreturn_typestring (NSMethodSignature* signature);
\ No newline at end of file

Modified: trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.m
===================================================================
--- trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.m	2007-06-14 21:34:58 UTC (rev 26162)
+++ trunk/base/src/tclobjc1.0/MPMethodSignatureExtensions.m	2007-06-14 21:52:29 UTC (rev 26163)
@@ -39,29 +39,29 @@
 
 #include "objc_encoding.h"
 
- at implementation NSMethodSignature (MPMethodSignatureExtensions)
+#ifdef GNU_RUNTIME
 
-#ifdef GNU_RUNTIME
-- (unsigned int) getArgumentTypeSpecifierAtIndex: (unsigned int) index {
-	NSArgumentInfo info;
-	info = [self argumentInfoAtIndex: index];
-	return info.qual;
+unsigned int tclobjc_getarg_typespecifier (NSMethodSignature* signature, unsigned int index) {
+    	NSArgumentInfo info;
+    	info = [signature argumentInfoAtIndex: index];
+    	return info.qual;    
 }
 
-- (const char *) getArgumentTypeStringAtIndex: (unsigned int) index {
-	return [self getArgumentTypeAtIndex: index];
+const char *tclobjc_getarg_typestring (NSMethodSignature* signature, unsigned int index) {
+    return [signature getArgumentTypeAtIndex: index];
 }
 
-
-- (const char*) methodReturnTypeString {
-	return [self methodReturnType];
+const char *tclobjc_getreturn_typestring (NSMethodSignature* signature) {
+    return [signature methodReturnType];
 }
 
-#endif
+#elif defined(APPLE_RUNTIME)
 
-#ifdef APPLE_RUNTIME
-
-static const char * stripSpecifiers (const char *type) {
+/**
+ * Skips any initial argument type specifiers, and returns a pointer
+ * to the argument type.
+ */
+static const char *strip_specifiers (const char *type) {
 	const char *p;
 	for (p = type; p != '\0'; p++) {
 		switch (*p) {
@@ -79,62 +79,66 @@
 	return (NULL);
 }
 
-- (unsigned int) getArgumentTypeSpecifierAtIndex: (unsigned int) index {
-	const char *type;
-	unsigned int qual = 0;
-	type = [self getArgumentTypeAtIndex: index];
-	for (; type != '\0'; type++) {
-		switch (type[0]) {
-			case _C_BYCOPY:
-				qual |= _F_BYCOPY;
-				break;
-			case _C_IN:
-				qual |= _F_IN;
-				break;
-			case _C_OUT:
-				qual |= _F_OUT;
-				break;
-			case _C_INOUT:
-				qual |= _F_INOUT;
-				break;
-			case _C_CONST:
-				qual |= _F_CONST;
-				break;
-			case _C_ONEWAY:
-				qual |= _F_ONEWAY;
-				break;
-			default:
-				goto finish;
-		}
-	}
+/**
+ * Returns the argument's type specifier (in GNU Objective-C style).
+ */
+unsigned int tclobjc_getarg_typespecifier (NSMethodSignature* signature, unsigned int index) {
+    	const char *type;
+    	unsigned int qual = 0;
+    	type = [signature getArgumentTypeAtIndex: index];
+    	for (; type != '\0'; type++) {
+    		switch (type[0]) {
+    			case _C_BYCOPY:
+    				qual |= _F_BYCOPY;
+    				break;
+    			case _C_IN:
+    				qual |= _F_IN;
+    				break;
+    			case _C_OUT:
+    				qual |= _F_OUT;
+    				break;
+    			case _C_INOUT:
+    				qual |= _F_INOUT;
+    				break;
+    			case _C_CONST:
+    				qual |= _F_CONST;
+    				break;
+    			case _C_ONEWAY:
+    				qual |= _F_ONEWAY;
+    				break;
+    			default:
+    				goto finish;
+    		}
+    	}
 finish:
-	return (qual);
+    	return (qual);
 }
 
+/**
+ * Returns apointer to the argument's type string.
+ */
+const char *tclobjc_getarg_typestring (NSMethodSignature* signature, unsigned int index) {
+    const char *type;
 
-- (const char *) getArgumentTypeStringAtIndex: (unsigned int) index {
-	const char *type;
-	type = stripSpecifiers([self getArgumentTypeAtIndex: index]);
-	if (!type) {
+    /* Fetch the argument type, and strip the type specifiers. */
+	type = strip_specifiers([signature getArgumentTypeAtIndex: index]);
+	if (type == NULL) {
 		/* This is a fatal condition */
 		NSLog(@"No type found in string at %s:%d", __FILE__, __LINE__);
-		exit(1);
+        abort();
 	}
 	return (type);
 }
 
-
-- (const char*) methodReturnTypeString {
-	const char *type;
-	type = stripSpecifiers([self methodReturnType]);
-	if (!type) {
+const char *tclobjc_getreturn_typestring (NSMethodSignature* signature) {
+    const char *type;
+	type = strip_specifiers([signature methodReturnType]);
+	if (type == NULL) {
 		/* This is a fatal condition */
 		NSLog(@"No type found in string at %s:%d", __FILE__, __LINE__);
-		exit(1);
+		abort();
 	}
 	return (type);
 }
 
-#endif
-
- at end
+#endif
\ No newline at end of file

Modified: trunk/base/src/tclobjc1.0/tclobjc.m
===================================================================
--- trunk/base/src/tclobjc1.0/tclobjc.m	2007-06-14 21:34:58 UTC (rev 26162)
+++ trunk/base/src/tclobjc1.0/tclobjc.m	2007-06-14 21:52:29 UTC (rev 26163)
@@ -38,13 +38,12 @@
 #include <Foundation/Foundation.h>
 #include <tcl.h>
 
+#include "objc_encoding.h"
 #include "MPMethodSignatureExtensions.h"
-#include "objc_encoding.h"
-
 #include "tclobjc_types.h"
 
 /*
- * Type Encodings
+ * Dispatch an Objective-C method call
  */
 int tclobjc_dispatch(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
 	NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -94,7 +93,7 @@
 	for (i = 2; i < objc; i += 2) {
 		int arg_num = i / 2 + 1;
 
-		const char* arg_type = [signature getArgumentTypeStringAtIndex:arg_num];
+		const char* arg_type = tclobjc_getarg_typestring(signature, arg_num);
 		fprintf(stderr, "argument type %s\n", arg_type);
 		if (arg_type[0] == _C_ID) {
 			id obj;
@@ -106,6 +105,19 @@
 			if (Tcl_GetIntFromObj(interp, objv[i], &word) == TCL_OK) {
 				[invocation setArgument:&word atIndex:arg_num];
 			}
+		} else if (arg_type[0] == _C_UINT) {
+            long value;
+            if (Tcl_GetLongFromObj(interp, objv[i], &value) == TCL_OK) {
+                if (value > UINT_MAX || value < 0) {
+                    NSString *str = [NSString stringWithFormat:@"Unsigned integer argument invalid: %ld", value];
+                    Tcl_Obj *tcl_result = Tcl_NewStringObj([str cString], -1);
+                    Tcl_SetObjResult(interp, tcl_result);
+                    result = TCL_ERROR;
+                } else {
+                    unsigned int word = value;
+                    [invocation setArgument:&value atIndex:arg_num];
+                }
+            }
 		} else if (arg_type[0] == _C_CHARPTR) {
 			int length;
 			char* buf = Tcl_GetStringFromObj(objv[i], &length);
@@ -126,8 +138,9 @@
 		[invocation invoke];
 		fprintf(stderr, "result size = %d\n", [signature methodReturnLength]);
 		void* result_ptr;
-		[invocation getReturnValue:&result_ptr];
-		const char* result_type = [signature methodReturnTypeString];
+		[invocation getReturnValue:&result_ptr];        
+		
+		const char* result_type = tclobjc_getreturn_typestring(signature);
 		result = objc_to_tclobj(interp, &tcl_result, result_type, result_ptr);
 		Tcl_SetObjResult(interp, tcl_result);
 	}

Deleted: trunk/base/src/tclobjc1.0/tclobjc_types.c
===================================================================
--- trunk/base/src/tclobjc1.0/tclobjc_types.c	2007-06-14 21:34:58 UTC (rev 26162)
+++ trunk/base/src/tclobjc1.0/tclobjc_types.c	2007-06-14 21:52:29 UTC (rev 26163)
@@ -1,198 +0,0 @@
-/*
- * TclObjTypes.c
- *
- * Copyright (c) 2004 Landon J. Fuller <landonf at opendarwin.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright owner nor the names of contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-/* Required by glibc for asprintf() */
-#define _GNU_SOURCE
-#include <stdio.h>
-
-#include <string.h>
-#include <stdlib.h>
-
-#include <objc/objc.h>
-
-#include <tcl.h>
-
-/*
- * Tcl Objc Id Object
- */
-
-/** All (evil) Objective-C string pointer representations start with a common prefix. */
-static const char tclobjc_name_prefix[] = "objc.id-";
-
-/** Invalid Objective-C pointer string representation. */
-static const char tclobjc_invalid_string_error[] = "Invalid Objective-C object: ";
-
-/* Standard prototypes */
-static void dup_objc_internalrep(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr);
-static void update_objc_string(Tcl_Obj *objPtr);
-static int set_objc_fromstring(Tcl_Interp *interp, Tcl_Obj *objPtr);
-
-static Tcl_ObjType tclObjcIdType = {
-	/* Name */
-	"tclObjcId",
-	/* Tcl_FreeInternalRepProc */
-	NULL,
-	/* Tcl_DupInternalRepProc */
-	&dup_objc_internalrep,
-	/* Tcl_UpdateStringProc */
-	&update_objc_string,
-	/* Tcp_SetFromAnyProc */
-	&set_objc_fromstring
-};
-
-/*
- * Private Functions
- */
-
-/**
- * Duplicate the internal objective-c pointer.
- */
-static void dup_objc_internalrep(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) {
-	dupPtr->internalRep.otherValuePtr = srcPtr->internalRep.otherValuePtr;
-}
-
-
-/**
- * Update the string value based on the internal pointer address.
- */
-static void update_objc_string (Tcl_Obj *objPtr) {
-	char *string;
-	int length;
-
-	if ((length = asprintf(&string, "objc.id-%p", objPtr->internalRep.otherValuePtr)) <= 0) {
-		/* ack! malloc failed! */
-		abort();
-	}
-
-	/* Terminating NULL */
-	length++;
-
-	/* objPtr->bytes must be allocated with Tcl_Alloc */
-	objPtr->bytes = Tcl_Alloc(length);
-	strcpy(objPtr->bytes, string);
-	free(string);
-}
-
-/**
- * Evil piece of code that set's the internal ObjC pointer value by
- * converting the provided string value.
- */
-static int set_objc_fromstring (Tcl_Interp *interp, Tcl_Obj *objPtr) {
-	Tcl_ObjType *oldTypePtr = objPtr->typePtr;
-	Tcl_Obj *tcl_result;
-	char *string, *p;
-	id objcId;
-	int length;
-
-	string = Tcl_GetStringFromObj(objPtr, &length);
-
-	/* Verify that this is a valid string */
-	if ((length < sizeof(tclobjc_name_prefix)) ||
-			(strncmp(string, tclobjc_name_prefix,
-				 sizeof(tclobjc_name_prefix)) != 0)) {
-			goto invalid_obj;
-	}
-
-	p = string + sizeof(tclobjc_name_prefix);
-
-	if (sscanf(p, "%p", &objcId) != 1)
-		goto invalid_obj;
-	
-	/* Free the old internal representation before setting new one */
-	if (oldTypePtr != NULL && oldTypePtr->freeIntRepProc != NULL) {
-		oldTypePtr->freeIntRepProc(objPtr);
-	}
-
-	objPtr->internalRep.otherValuePtr = objcId;
-	objPtr->typePtr = &tclObjcIdType;
-
-	return (TCL_OK);
-
-
-	/* Cleanup Handler */
-invalid_obj:
-	if (interp) {
-		tcl_result = Tcl_NewStringObj(tclobjc_invalid_string_error, sizeof(tclobjc_invalid_string_error));
-		Tcl_AppendObjToObj(tcl_result, objPtr);
-		Tcl_SetObjResult(interp, tcl_result);
-	}
-	return (TCL_ERROR);
-}
-
-/*
- * Public Functions
- */
-
-/**
- * Create a new Tcl Object wrapper for a given Objective-C object.
- */
-Tcl_Obj *TclObjC_NewIdObj(id objcId) {
-	Tcl_Obj *objPtr;
-
-	objPtr = Tcl_NewObj();
-
-	objPtr->bytes = NULL;
-
-	objPtr->internalRep.otherValuePtr = objcId;
-	objPtr->typePtr = &tclObjcIdType;
-	return (objPtr);
-}
-
-/**
- * Returns a pointer to the wrapped Objective-C object.
- */
-int TclObjC_GetIdFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, id *objcId)
-{
-	int result;
-
-	if (objPtr->typePtr == &tclObjcIdType) {
-		*objcId = objPtr->internalRep.otherValuePtr;
-		return (TCL_OK);
-	}
-
-	result = set_objc_fromstring(interp, objPtr);
-
-	if (result == TCL_OK)
-		*objcId = objPtr->internalRep.otherValuePtr;
-
-	return (result);
-}
-
-/**
- * Register the Tcl Objective-C Object type(s).
- */
-void TclObjC_RegisterTclObjTypes(void) {
-	Tcl_RegisterObjType(&tclObjcIdType);
-}

Copied: trunk/base/src/tclobjc1.0/tclobjc_types.m (from rev 26137, trunk/base/src/tclobjc1.0/tclobjc_types.c)
===================================================================
--- trunk/base/src/tclobjc1.0/tclobjc_types.m	                        (rev 0)
+++ trunk/base/src/tclobjc1.0/tclobjc_types.m	2007-06-14 21:52:29 UTC (rev 26163)
@@ -0,0 +1,207 @@
+/*
+ * TclObjTypes.c
+ *
+ * Copyright (c) 2004 Landon J. Fuller <landonf at opendarwin.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright owner nor the names of contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* Required by glibc for asprintf() */
+#define _GNU_SOURCE
+#include <stdio.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <Foundation/Foundation.h>
+#include <objc/objc.h>
+
+#include <tcl.h>
+
+/*
+ * Tcl Objc Id Object
+ */
+
+/** All (evil) Objective-C string pointer representations start with a common prefix. */
+static const char tclobjc_name_prefix[] = "objc.id-";
+
+/** Invalid Objective-C pointer string representation. */
+static const char tclobjc_invalid_string_error[] = "Invalid Objective-C object: ";
+
+/* Standard prototypes */
+static void free_objc_internalrep(Tcl_Obj *objPtr);
+static void dup_objc_internalrep(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr);
+static void update_objc_string(Tcl_Obj *objPtr);
+static int set_objc_fromstring(Tcl_Interp *interp, Tcl_Obj *objPtr);
+
+static Tcl_ObjType tclObjcIdType = {
+	/* Name */
+	"tclObjcId",
+	/* Tcl_FreeInternalRepProc */
+	&free_objc_internalrep,
+	/* Tcl_DupInternalRepProc */
+	&dup_objc_internalrep,
+	/* Tcl_UpdateStringProc */
+	&update_objc_string,
+	/* Tcp_SetFromAnyProc */
+	&set_objc_fromstring
+};
+
+/*
+ * Private Functions
+ */
+
+/**
+ * Release the internal objective-c instance.
+ */
+static void free_objc_internalrep(Tcl_Obj *objPtr) {
+    // TODO cleanup
+}
+
+/**
+ * Duplicate the internal objective-c pointer.
+ */
+static void dup_objc_internalrep(Tcl_Obj *srcPtr, Tcl_Obj *dupPtr) {
+	dupPtr->internalRep.otherValuePtr = srcPtr->internalRep.otherValuePtr;
+}
+
+
+/**
+ * Update the string value based on the internal pointer address.
+ */
+static void update_objc_string (Tcl_Obj *objPtr) {
+	char *string;
+	int length;
+
+	if ((length = asprintf(&string, "objc.id-%p", objPtr->internalRep.otherValuePtr)) <= 0) {
+		/* ack! malloc failed! */
+		abort();
+	}
+
+	/* Terminating NULL */
+	length++;
+
+	/* objPtr->bytes must be allocated with Tcl_Alloc */
+	objPtr->bytes = Tcl_Alloc(length);
+	strcpy(objPtr->bytes, string);
+	free(string);
+}
+
+/**
+ * Evil piece of code that set's the internal ObjC pointer value by
+ * converting the provided string value.
+ */
+static int set_objc_fromstring (Tcl_Interp *interp, Tcl_Obj *objPtr) {
+	Tcl_ObjType *oldTypePtr = objPtr->typePtr;
+	Tcl_Obj *tcl_result;
+	char *string, *p;
+	id objcId;
+	int length;
+
+	string = Tcl_GetStringFromObj(objPtr, &length);
+
+	/* Verify that this is a valid string */
+	if ((length < sizeof(tclobjc_name_prefix)) ||
+			(strncmp(string, tclobjc_name_prefix,
+				 sizeof(tclobjc_name_prefix)) != 0)) {
+			goto invalid_obj;
+	}
+
+	p = string + sizeof(tclobjc_name_prefix);
+
+	if (sscanf(p, "%p", &objcId) != 1)
+		goto invalid_obj;
+	
+	/* Free the old internal representation before setting new one */
+	if (oldTypePtr != NULL && oldTypePtr->freeIntRepProc != NULL) {
+		oldTypePtr->freeIntRepProc(objPtr);
+	}
+
+	objPtr->internalRep.otherValuePtr = objcId;
+	objPtr->typePtr = &tclObjcIdType;
+
+	return (TCL_OK);
+
+
+	/* Cleanup Handler */
+invalid_obj:
+	if (interp) {
+		tcl_result = Tcl_NewStringObj(tclobjc_invalid_string_error, sizeof(tclobjc_invalid_string_error));
+		Tcl_AppendObjToObj(tcl_result, objPtr);
+		Tcl_SetObjResult(interp, tcl_result);
+	}
+	return (TCL_ERROR);
+}
+
+/*
+ * Public Functions
+ */
+
+/**
+ * Create a new Tcl Object wrapper for a given Objective-C object.
+ */
+Tcl_Obj *TclObjC_NewIdObj(id objcId) {
+	Tcl_Obj *objPtr;
+
+	objPtr = Tcl_NewObj();
+
+	objPtr->bytes = NULL;
+
+	objPtr->internalRep.otherValuePtr = objcId;
+	objPtr->typePtr = &tclObjcIdType;
+	return (objPtr);
+}
+
+/**
+ * Returns a pointer to the wrapped Objective-C object.
+ */
+int TclObjC_GetIdFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, id *objcId)
+{
+	int result;
+
+	if (objPtr->typePtr == &tclObjcIdType) {
+		*objcId = objPtr->internalRep.otherValuePtr;
+		return (TCL_OK);
+	}
+
+	result = set_objc_fromstring(interp, objPtr);
+
+	if (result == TCL_OK)
+		*objcId = objPtr->internalRep.otherValuePtr;
+
+	return (result);
+}
+
+/**
+ * Register the Tcl Objective-C Object type(s).
+ */
+void TclObjC_RegisterTclObjTypes(void) {
+	Tcl_RegisterObjType(&tclObjcIdType);
+}

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070614/098cd84c/attachment.html


More information about the macports-changes mailing list