[81757] branches/gsoc11-rev-upgrade/base/src/machista1.0
cal at macports.org
cal at macports.org
Thu Aug 4 11:00:26 PDT 2011
Revision: 81757
http://trac.macports.org/changeset/81757
Author: cal at macports.org
Date: 2011-08-04 11:00:25 -0700 (Thu, 04 Aug 2011)
Log Message:
-----------
rev-upgrade: Add function to get the readable name from a cpu_type_t
Modified Paths:
--------------
branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.c
branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.h
branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i
branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c
Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.c
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.c 2011-08-04 17:59:17 UTC (rev 81756)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.c 2011-08-04 18:00:25 UTC (rev 81757)
@@ -83,6 +83,14 @@
return result;
}
+const char *macho_get_arch_name (cpu_type_t cputype) {
+ const NXArchInfo *archInfo = NXGetArchInfoFromCpuType(cputype, CPU_SUBTYPE_MULTIPLE);
+ if (!archInfo) {
+ return NULL;
+ }
+ return archInfo->name;
+}
+
/* Some byteswap wrappers */
static uint32_t macho_swap32 (uint32_t input) {
return OSSwapInt32(input);
Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.h
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.h 2011-08-04 17:59:17 UTC (rev 81756)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/libmachista.h 2011-08-04 18:00:25 UTC (rev 81757)
@@ -111,6 +111,12 @@
char *macho_format_dylib_version(uint32_t version);
/**
+ * Returns a readable version of any cpu_type_t constant. Returns a valid pointer to the first
+ * character in a 0-terminated string or NULL on error. The pointer must not be free()'d after use.
+ */
+const char *macho_get_arch_name(cpu_type_t cputype);
+
+/**
* Parses the Mach-O file indicated by filepath and writes a pointer to a macho_t describing the
* Mach-O file into the location idicated by res. Returns MACHO_SUCCESS on success or any of the
* following error codes on error:
Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i 2011-08-04 17:59:17 UTC (rev 81756)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/machista.i 2011-08-04 18:00:25 UTC (rev 81757)
@@ -151,3 +151,12 @@
%rename(format_dylib_version) macho_format_dylib_version;
char *macho_format_dylib_version(uint32_t);
+/**
+ * map macho_get_arch_name()
+ * The memory for the returned char * comes from NXGetArchInfoFromCpuType(),
+ * which is documentet in arch(3), without ever mentioning any memory issues. I
+ * assume it's static memory, that should not be free()'d.
+ */
+%rename(get_arch_name) macho_get_arch_name;
+const char *macho_get_arch_name(cpu_type_t);
+
Modified: branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c 2011-08-04 17:59:17 UTC (rev 81756)
+++ branches/gsoc11-rev-upgrade/base/src/machista1.0/machista_wrap.c 2011-08-04 18:00:25 UTC (rev 81757)
@@ -2292,7 +2292,31 @@
}
+SWIGINTERN int
+_wrap_get_arch_name(ClientData clientData SWIGUNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
+ cpu_type_t arg1 ;
+ int val1 ;
+ int ecode1 = 0 ;
+ char *result = 0 ;
+
+ if (SWIG_GetArgs(interp, objc, objv,"o:machista::get_arch_name cpu_type_t ",(void *)0) == TCL_ERROR) SWIG_fail;
+ ecode1 = SWIG_AsVal_int SWIG_TCL_CALL_ARGS_2(objv[1], &val1);
+ if (!SWIG_IsOK(ecode1)) {
+ SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "get_arch_name" "', argument " "1"" of type '" "cpu_type_t""'");
+ }
+ arg1 = (cpu_type_t)(val1);
+ result = (char *)macho_get_arch_name(arg1);
+ Tcl_SetObjResult(interp,SWIG_FromCharPtr((const char *)result));
+ {
+ free(result);
+ }
+ return TCL_OK;
+fail:
+ return TCL_ERROR;
+}
+
+
static swig_command_info swig_commands[] = {
{ SWIG_prefix "macho_handle", (swig_wrapper_func) SWIG_ObjectConstructor, (ClientData)&_wrap_class_macho_handle},
{ SWIG_prefix "macho_loadcmd_mlt_install_name_get", (swig_wrapper_func) _wrap_macho_loadcmd_mlt_install_name_get, NULL},
@@ -2316,6 +2340,7 @@
{ SWIG_prefix "parse_file", (swig_wrapper_func) _wrap_parse_file, NULL},
{ SWIG_prefix "strerror", (swig_wrapper_func) _wrap_strerror, NULL},
{ SWIG_prefix "format_dylib_version", (swig_wrapper_func) _wrap_format_dylib_version, NULL},
+ { SWIG_prefix "get_arch_name", (swig_wrapper_func) _wrap_get_arch_name, NULL},
{0, 0, 0}
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110804/aa5e1d5c/attachment-0001.html>
More information about the macports-changes
mailing list