rpav / cl-autowrap

(c-include "file.h") => complete FFI wrapper
BSD 2-Clause "Simplified" License
217 stars 41 forks source link

Wrapping Framework on latest MacOS ? #87

Open Frobitz66 opened 6 years ago

Frobitz66 commented 6 years ago

Disclaimer: I'm a total noob at this so please bear with me.

I've build c2ffi and am trying to figure out how to use cl-autowrap to wrap the MacOS (10.13.x) "ScriptingBridge" framework.

Here's a snapshot of what I'm running up against:

$ ccl
Clozure Common Lisp Version 1.11.5/v1.11.5  (DarwinX8664)

For more information about CCL, please see http://ccl.clozure.com.

CCL is free software.  It is distributed under the terms of the Apache
Licence, Version 2.0.
? (ql:quickload cl-autoload)
> Error: Unbound variable: CL-AUTOLOAD
> While executing: CCL::CHEAP-EVAL-IN-ENVIRONMENT, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Retry getting the value of CL-AUTOLOAD.
> Type :? for other options.
1 > :pop

? (ql:quickload :cl-autowrap)
To load "cl-autowrap":
  Load 1 ASDF system:
    cl-autowrap
; Loading "cl-autowrap"

(:CL-AUTOWRAP)
? (autowrap:c-include "/System/Library/Frameworks/ScriptingBridge.framework/Headers/SBApplication.h")
> Error: Invalid JSON literal name: INF [in #<BASIC-FILE-CHARACTER-INPUT-STREAM ("SBApplication.x86_64-apple-darwin9.spec"/4 UTF-8) #x3020010EC55D> at position 8067018]
> While executing: JSON:JSON-SYNTAX-ERROR, in process listener(1).
> Type :POP to abort, :R for a list of available restarts.
> Type :? for other options.
1 > :pop

A couple of questions: 1) Am I using c-include correctly? 2) Has anyone been able to wrap any MacOS framework? It'd be awful nice if there was a handy example.

TIA, T.S. Abdallah

rpav commented 6 years ago

Sorry for the delay, but I just merged the PR for c2ffi which should fix this. Should be in both 4 and 5 branches. That said you're going to get a string "inf" or similar, but it's probably not something you'll be using in any case.

Frobitz66 commented 6 years ago

Thanks for the response. I am indeed getting the "Invalid JSON name: INF ..." message. Is it safe to [*ABORT] Return to SLIME's top level" at this point?

UPDATE: The problem is caused by the "value" of "LDBL_MAX" being set to the string INF rather than a number in the JSON spec file.