This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

CFFI - Is the correct name for these, METAOBJECTS

6 posts · 6320 views

I have my CFFI types defined as below so if I call a function that uses these types as a return it outputs a cool looking symbol as a return value e.g.

I have this function:
(defcfun ("create_std_vectorf" %vec-float) vector-float)
when I call it like this:
CV> (VEC-FLOAT)
#<STD-VECTOR-FLOAT {100352FEA3}>  <---It outputs this....what is this called, a METAOBJECT???

;; VECTOR-FLOAT

(define-foreign-type vector-float ()
((garbage-collect :reader garbage-collect :initform nil :initarg
:garbage-collect))
(:actual-type :pointer)
(:simple-parser vector-float))


(defclass std-vector-float ()
((c-pointer :reader c-pointer :initarg :c-pointer)))


(defmethod translate-to-foreign ((lisp-value std-vector-float) (c-type vector-float))
(values (c-pointer lisp-value) lisp-value))


(defmethod translate-from-foreign (c-pointer (c-type vector-float))
(let ((vector-float (make-instance 'std-vector-float :c-pointer c-pointer)))
(when (garbage-collect c-type)
(tg:finalize vector-float (lambda () (del-vec-flt c-pointer))))
vector-float))

Re: CFFI - Is the correct name for these, METAOBJECTS

It's a normal CLOS object and its printed representation isn't readable. (it's denoted by the #< reader macro.)
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: CFFI - Is the correct name for these, METAOBJECTS

So thats why I can do this, because of the reader macro(point-x retrieves the x coordinate of point)

CV> (point 1 2)
#<CV-POINT {1007540673}>
CV> (defparameter a #<CV-POINT {1007540673}>)
A
CV> (point-x a)
1

So in my documentation, what would be the most professional way to refer to it, as a CLOS object, or just "object"?

Re: CFFI - Is the correct name for these, METAOBJECTS

It's precisely what you can't do. And if your record of REPL is reality then CFFI or something else had to changed the behaviour of the #<.

If the documentation were structured I'd mention that objects are from CLOS only in a superficial part of it.
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.

Re: CFFI - Is the correct name for these, METAOBJECTS

Wow..I did that no problem, that is the direct REPL output...my CFFI is stock as is everything else...Emacs is about as tricked out as can be but SBCL is stock. I import SWANK again as a hack though. I do all my coding in my main package, I guess it could be some setting in there.

Re: CFFI - Is the correct name for these, METAOBJECTS

Thanks again for all your help today Goheeca, I learned a lot