some changes to be able to generate bindings for mozjs
Thu May 15 13:53:27 PDT 2008 attila.lendvai@gmail.com
* some changes to be able to generate bindings for mozjs
diff -rN -u old-verrazano/src/backends/cffi/writers.lisp new-verrazano/src/backends/cffi/writers.lisp
--- old-verrazano/src/backends/cffi/writers.lisp 2014-07-23 15:13:51.000000000 -0700
+++ new-verrazano/src/backends/cffi/writers.lisp 2014-07-23 15:13:51.000000000 -0700
@@ -17,7 +17,7 @@
(asdf:find-system :verrazano)))
(write-formatted-text ";;; WARNING: This is a generated file, editing it is unwise!~%~%")
(write-form '(cl:in-package :cl-user))
- (write-form '(asdf:operate 'asdf:load-op :verrazano-runtime))
+ ;;(write-form '(asdf:operate 'asdf:load-op :verrazano-runtime))
(write-form `(defpackage
,package-name
(:use :cffi)
@@ -51,18 +51,19 @@
(defmethod process-gccxml-node ((backend cffi-backend) (node gccxml:typedef))
(bind ((type (type-of node)))
- (if (and (typep type '(or gccxml:struct gccxml:class gccxml:union))
+ (if (and (typep type '(or gccxml:struct gccxml:class gccxml:union gccxml:enumeration))
(string= (name-of type) (name-of node)))
;; it's an instance of the "deftype struct foo {} foo;" pattern, write the struct/union instead
(process-gccxml-node backend type)
(progn
- (when (string-equal (name-of node) "graph_t")
+ #+nil
+ (when (string-equal (name-of node) "JSAccessMode")
(break "here: ~A" node))
(process-gccxml-node backend type)
(assert (null (find-node-by-name (name-of node) 'gccxml:struct *parser* :otherwise nil)))
(process-gccxml-node backend type)
- (format t "~%(cffi::defctype* ~A " (enqueue-for-export
- (transform-name (name-of node) :type)))
+ (format t "~%(cffi::defctype ~A " (enqueue-for-export
+ (transform-name (name-of node) :type)))
(write-cffi-type type)
(format t ")~%")))))
@@ -135,12 +136,12 @@
(defmethod write-cffi-type ((node gccxml:pointertype))
(bind ((target-type (type-of node)))
- (if (typep target-type 'gccxml:functiontype)
- (write-string ":pointer")
+ (if (typep target-type 'gccxml:fundamentaltype)
(progn
(write-string "(:pointer ")
(write-cffi-type target-type)
- (write-string ")")))))
+ (write-string ")"))
+ (write-string ":pointer"))))
(defmethod write-cffi-type ((node gccxml:arraytype))
(write-cffi-type (type-of node))
@@ -203,7 +204,7 @@
node))
(bind ((type (type-of field))
(offset-in-bits (offset-of field))
- ((values offset-in-bytes remainder) (truncate offset-in-bits 8)))
+ ((:values offset-in-bytes remainder) (truncate offset-in-bits 8)))
(declare (ignore offset-in-bytes))
(if (zerop remainder)
(progn
@@ -226,7 +227,7 @@
field (context-of field))
(bind ((type (type-of field))
(offset-in-bits (offset-of field))
- ((values offset-in-bytes remainder) (truncate offset-in-bits 8)))
+ ((:values offset-in-bytes remainder) (truncate offset-in-bits 8)))
(declare (ignore offset-in-bytes))
(if (zerop remainder)
(progn
@@ -284,7 +285,7 @@
(do-arguments-of-function (argument node)
(incf index)
(if (typep argument 'gccxml:ellipsis)
- (write-string "&rest")
+ (write-string "common-lisp:&rest")
(bind ((argument-name (aif (name-of argument)
(transform-name it :variable)
(format nil "arg~A" index)))
diff -rN -u old-verrazano/src/frontend/driver.lisp new-verrazano/src/frontend/driver.lisp
--- old-verrazano/src/frontend/driver.lisp 2014-07-23 15:13:51.000000000 -0700
+++ new-verrazano/src/frontend/driver.lisp 2014-07-23 15:13:51.000000000 -0700
@@ -1,5 +1,5 @@
(in-package :verrazano)
-
+
(defun generate-binding (backend &key keep-temporary-files)
"This is the primary entry point, given a CONFIGURATION generate a binding using BACKEND."
(bind ((*backend* (make-backend backend))
@@ -15,10 +15,10 @@
(format out "#include \"~A\"~%" inc))
(format out "const int __verrazano_binding = 1;"))
(run-gccxml c-file xml-file macro-file)
- (bind ((*parser* (parse-gccxml-output xml-file macro-file)))
- (process-gccxml-node *backend* (flexml:root-of *parser*))
- #+nil
- (break)))
+ (bind ((*parser* (parse-gccxml-output xml-file macro-file))
+ (root-node (flexml:root-of *parser*)))
+ (process-gccxml-node *backend* root-node)
+ #+nil(break)))
(unless keep-temporary-files
(dolist (file (temporary-files-of *backend*))
(ignore-errors
diff -rN -u old-verrazano/src/frontend/utility.lisp new-verrazano/src/frontend/utility.lisp
--- old-verrazano/src/frontend/utility.lisp 2014-07-23 15:13:51.000000000 -0700
+++ new-verrazano/src/frontend/utility.lisp 2014-07-23 15:13:51.000000000 -0700
@@ -43,7 +43,7 @@
(defun bits-to-bytes (number)
(declare (type integer number))
- (bind (((values bytes remainder) (truncate number 8)))
+ (bind (((:values bytes remainder) (truncate number 8)))
(assert (zerop remainder))
bytes))
diff -rN -u old-verrazano/src/packages.lisp new-verrazano/src/packages.lisp
--- old-verrazano/src/packages.lisp 2014-07-23 15:13:51.000000000 -0700
+++ new-verrazano/src/packages.lisp 2014-07-23 15:13:51.000000000 -0700
@@ -94,7 +94,14 @@
#:type-of))
(defpackage :verrazano-user
- (:use :common-lisp :verrazano :iterate :alexandria :metabang-bind))
+ (:use
+ :common-lisp
+ :verrazano
+ :iterate
+ :alexandria
+ :metabang-bind
+ :cffi
+ ))
(in-package :verrazano)