No need to construct a SmokeBinding per Smoke module.
src/smoke.lisp
Fri Feb 19 22:10:24 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* No need to construct a SmokeBinding per Smoke module.
--- old-smoke/src/smoke.lisp 2014-10-30 08:06:39.000000000 +0100
+++ new-smoke/src/smoke.lisp 2014-10-30 08:06:39.000000000 +0100
@@ -79,6 +79,14 @@
(pointer object)))
(setf (slot-value object 'pointer) (null-pointer)))
+(eval-startup (:load-toplevel :execute)
+ (defparameter *binding* (smoke-construct-binding
+ (callback destructed)
+ (callback dispatch-method)))
+ (defparameter *no-dispatch-binding* (smoke-construct-binding
+ (callback destructed)
+ (null-pointer))))
+
(defun set-binding (object)
"Sets the Smoke binding for OBJECT, that receives its callbacks."
(declare (optimize (speed 3)))
@@ -87,8 +95,8 @@
(setf (foreign-slot-value (mem-aref stack 'smoke-stack-item 1)
'smoke-stack-item 'voidp)
(if (typep class 'cxx:class)
- (smoke-module-binding (smoke class))
- (smoke-module-no-dispatch-binding (smoke class))))
+ *binding*
+ *no-dispatch-binding*))
(foreign-funcall-pointer
(foreign-slot-value (smoke-class-pointer class)
'smoke-class 'class-function)
@@ -101,16 +109,10 @@
(defun init (smoke module)
"Returns the a new Smoke binding for the Smoke module SMOKE."
(use-foreign-library libclsmoke)
- (let ((no-dispatch-binding
- (smoke-construct-binding smoke (callback destructed) (null-pointer)))
- (binding (smoke-construct-binding smoke (callback destructed)
- (callback dispatch-method))))
- (setf (smoke-module-pointer module) smoke
- (smoke-module-no-dispatch-binding module) no-dispatch-binding
- (smoke-module-binding module) binding)
- (init-smoke-module module)
- (setf (gethash (pointer-address smoke) *smoke-modules*) module)
- module))
+ (setf (smoke-module-pointer module) smoke)
+ (init-smoke-module module)
+ (setf (gethash (pointer-address smoke) *smoke-modules*) module)
+ module)
(let ((pointer-symbol-map (make-hash-table)))
;; Used by make-load-form for enums to reference the smoke module.