Thu Jun 11 16:35:40 CEST 2009 Tobias Rautenkranz * Modules can specify the package to place the classes, static methods and constants in. diff -rN -u old-smoke/smoke.mbd new-smoke/smoke.mbd --- old-smoke/smoke.mbd 2014-10-01 19:32:15.000000000 +0200 +++ new-smoke/smoke.mbd 2014-10-01 19:32:15.000000000 +0200 @@ -13,7 +13,7 @@ (:default-initargs :type "txt")) (defclass sysdef.cmake:cmake-library (component) - ()) + ((package :initarg :package))) ;;; end SYDDEF.CMAKE (in-package :sysdef-user) diff -rN -u old-smoke/src/clos.lisp new-smoke/src/clos.lisp --- old-smoke/src/clos.lisp 2014-10-01 19:32:15.000000000 +0200 +++ new-smoke/src/clos.lisp 2014-10-01 19:32:15.000000000 +0200 @@ -208,10 +208,11 @@ (lispify (name smoke-class)))) -(defun make-smoke-classes (smoke) - "Construts a lisp class for each one in the Smoke module SMOKE." +(defun make-smoke-classes (package smoke) + "Construts a lisp class in PACKAGE for each one in the Smoke module SMOKE." (declare (foreign-pointer smoke) (optimize (speed 3))) + (let ((*package* (find-package package))) (add-id-class-map smoke) (map-classes #'(lambda (class) @@ -225,7 +226,7 @@ :smoke (smoke class) :metaclass 'smoke-standard-class)) (export (lispify (name class))))) - smoke)) + smoke))) (defclass smoke-gf (cxx-generic-function) ((cxx-name :reader name :initarg :cxx-name diff -rN -u old-smoke/src/method.lisp new-smoke/src/method.lisp --- old-smoke/src/method.lisp 2014-10-01 19:32:15.000000000 +0200 +++ new-smoke/src/method.lisp 2014-10-01 19:32:15.000000000 +0200 @@ -1,18 +1,20 @@ (in-package :smoke) (declaim (optimize (debug 3))) -(defun constant-definition (method smoke) +(defun constant-definition (package method smoke) "Returns an expression that defines a constant for the enum METHOD. The second return value is the expression to export the constant." (let ((symbol (if (string= (name (get-class method)) "Qt") (lispify (concatenate 'string "+" (name method) - "+")) + "+") + package) (lispify (concatenate 'string (name (get-class method)) ".+" - (name method) "+"))))) + (name method) "+") + package)))) (values `(define-constant ,symbol (make-instance 'enum @@ -23,7 +25,7 @@ :test #'enum=) symbol))) -(defun static-method-symbol (method) +(defun static-method-symbol (package method) "Returns the lisp symbol for the static method METHOD." (let ((class (get-class method))) (lispify (concatenate 'string @@ -33,19 +35,20 @@ (concatenate 'string (name class) ".")) - (name method))))) + (name method)) + package))) -(defun static-method-definition (method &optional (argument-count -1)) +(defun static-method-definition (package method &optional (argument-count -1)) "Returns an expression to define a function for the static METHOD. The second return value is the expression to export the function." (let* ((class (get-class method)) (method-name (name method)) - (name (static-method-symbol method))) + (name (static-method-symbol package method))) (values `(defun ,name ,(if (< argument-count 0) '(&rest args) (make-lambda argument-count)) - (call-using-args (find-class (quote ,(lispify (name class)))) + (call-using-args (find-class (quote ,(lispify (name class) package))) ,method-name ,(if (< argument-count 0) 'args @@ -84,7 +87,7 @@ (error "The smoke module ~A changed, you need to recompile the lisp file." (smoke-get-module-name ,smoke))))) -(defmacro define-methods (smoke) +(defmacro define-classes-and-gfs (package smoke) "Process the C++ methods of the Smoke module SMOKE. Expands to DEFUNs for static methods, DEFINE-CONSTANTs for enum methods and a function do define the generic methods a load-time." @@ -103,7 +106,7 @@ ;; http://lists.kde.org/?l=kde-bindings&m=123464781307375 (not (string= (name (get-class method)) "KGlobalSettings"))) - (multiple-value-bind (def export) (constant-definition method smoke) + (multiple-value-bind (def export) (constant-definition package method smoke) (push def constants) (push export exports))) @@ -123,7 +126,7 @@ (setf (gethash (lispify name "CXX") generics) name)) (when (static-p method) - (let* ((function-symbol (static-method-symbol method)) + (let* ((function-symbol (static-method-symbol package method)) (methods (gethash function-symbol function-symbols))) (setf (gethash function-symbol function-symbols) (if methods (- (id method)) (id method))))))) @@ -134,6 +137,7 @@ :smoke (eval smoke)))) (multiple-value-bind (definition export) (static-method-definition + package method (if (< 0 id) (get-arguments-length method) @@ -144,9 +148,9 @@ ,@functions (eval-startup (:execute) (register-smoke-module-var (quote ,smoke)) - (make-smoke-classes ,smoke) + (make-smoke-classes ,package ,smoke) (ensure-generic-methods ',(hash-table-alist generics))) ,@constants (eval-when (:load-toplevel :execute) - (export (quote ,exports)))))) + (export (quote ,exports) ,package))))) diff -rN -u old-smoke/src/smoke-c/smoke-c.lisp new-smoke/src/smoke-c/smoke-c.lisp --- old-smoke/src/smoke-c/smoke-c.lisp 2014-10-01 19:32:15.000000000 +0200 +++ new-smoke/src/smoke-c/smoke-c.lisp 2014-10-01 19:32:15.000000000 +0200 @@ -54,7 +54,6 @@ (smoke smoke-binding)) (defcstruct smoke-module-index - "asdf" (smoke :pointer) (index smoke-index)) diff -rN -u old-smoke/src/smoke.lisp new-smoke/src/smoke.lisp --- old-smoke/src/smoke.lisp 2014-10-01 19:32:15.000000000 +0200 +++ new-smoke/src/smoke.lisp 2014-10-01 19:32:15.000000000 +0200 @@ -162,7 +162,8 @@ (signature method)))) smoke)) -(defmacro define-smoke-module (library (variable variable-name) +(defmacro define-smoke-module (package library + (variable variable-name) (init-function function-name)) "Define a Smoke module." `(progn @@ -178,7 +179,7 @@ (eval-startup (:compile-toplevel :execute) (,init-function) (init ,variable)) - (define-methods ,variable))) + (define-classes-and-gfs ,package ,variable))) (defun fgrep-classes (smoke str)