diff options
author | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 19:52:30 +0200 |
---|---|---|
committer | Matthias Benkard <code@mail.matthias.benkard.de> | 2007-09-21 19:52:30 +0200 |
commit | 7765ad52e00034edd23bb09bade83d8b282f8040 (patch) | |
tree | 61f3087a64d9667c80ce4bec853b26f8c858927e /Lisp/libobjcl.lisp | |
parent | e8081745f009f2f7c3dc9b46d072094e6bab30d6 (diff) |
Objective-C layer: Add functions for determining the Objective-C runtime used and for asking for the size of types by typespec.
darcs-hash:197f36840c1568c5b3431833a0118d06729b9247
Diffstat (limited to 'Lisp/libobjcl.lisp')
-rw-r--r-- | Lisp/libobjcl.lisp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lisp/libobjcl.lisp b/Lisp/libobjcl.lisp index 1d14e8b..d2f3e3c 100644 --- a/Lisp/libobjcl.lisp +++ b/Lisp/libobjcl.lisp @@ -64,6 +64,17 @@ :pointer (obj :pointer)) +(defcfun ("objcl_get_runtime_type" %objcl-get-runtime-type) :string) + +(defcfun ("objcl_sizeof_type" %objcl-sizeof-type) :long + (typespec :string)) + +(defcfun ("objcl_sizeof_return_type" %objcl-sizeof-return-type) :long + (typespec :string)) + +(defcfun ("objcl_alignof_type" %objcl-alignof-type) :long + (typespec :string)) + (defcfun objcl-get-nil :pointer) (defcfun objcl-get-yes :long) (defcfun objcl-get-no :long) @@ -523,3 +534,23 @@ Returns: (VALUES typespec byte-position string-position)" byte-position) #-(or) nil string-position))) + + +;;;; (@* "Helper functions") +(defun sizeof (typespec) + (%objcl-sizeof-type typespec)) + +(defun alignof (typespec) + (%objcl-alignof-type typespec)) + +(defun return-type-sizeof (typespec) + (%objcl-sizeof-return-type typespec)) + +(defun runtime-type () + (let ((runtime (%objcl-get-runtime-type))) + (assert (member runtime '("GNU" "NeXT") :test #'string=) + (runtime) + "Unkown Objective-C runtime type ~S. Allowed: (\"GNU\" \"NeXT\")." + runtime) + (cond ((string= runtime "GNU") :gnu) + ((string= runtime "NeXT") :next)))) |