Tue Jul 13 21:17:41 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Use libsmokebase instead of libsmokeqtcore.
hunk ./src/libsmoke/CMakeLists.txt 13
-find_library(smokeqtcore_LIB smokeqtcore)
-if (smokeqtcore_LIB)
- set(smokeqtcore_FOUND TRUE)
-endif (smokeqtcore_LIB)
+find_library(smokebase_LIB smokebase)
+if (smokebase_LIB)
+ set(smokebase_FOUND TRUE)
+endif (smokebase_LIB)
hunk ./src/libsmoke/CMakeLists.txt 18
-if (smokeqtcore_FOUND)
- message(STATUS "Found smokeqtcore: ${smokeqtcore}")
-else (smokeqtcore_FOUND)
- message(FATAL_ERROR "Could not find smokeqtcore")
-endif (smokeqtcore_FOUND)
+if (smokebase_FOUND)
+ message(STATUS "Found smokebase: ${smokebase}")
+else (smokebase_FOUND)
+ message(FATAL_ERROR "Could not find smokebase")
+endif (smokebase_FOUND)
hunk ./src/libsmoke/CMakeLists.txt 27
-target_link_libraries(clsmoke ${QT_LIBRARIES} ${smokeqtcore_LIB})
+target_link_libraries(clsmoke ${QT_LIBRARIES} ${smokebase_LIB})
Sat Apr 3 21:11:26 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* slot-value access for static attributes using the class instead of an object.
hunk ./src/overload-resolution.lisp 557
+(defmethod slot-missing (meta-class (class smoke-standard-class) slot-name operation &optional new-value)
+ (let ((method (find-smoke-method class (lisp-to-cxx (string slot-name)))))
+ (if (or (not (valid-p method)) (not (static-p method)))
+ (call-next-method)
+ (ecase operation
+ (setf [_$_]
+ (handler-case (funcall (fdefinition
+ (intern
+ (concatenate 'string "SET-"
+ (string-upcase
+ (string slot-name)))
+ :cxx))
+ class new-value)
+ (undefined-function ()
+ (error "The C++ attribute ~A of ~A is read only." slot-name class))
+ (no-applicable-cxx-method (condition)
+ (if (null (viable-functions (condition-method condition)
+ (length (condition-arguments condition))
+ (condition-class condition)))
+ (error "The C++ attribute ~A of ~A is read only." slot-name class)
+ (error condition)))))
+ (slot-boundp t)
+ (slot-makunbound (error "Can not unbind the C++ attribute ~A of ~A." slot-name class))
+ (slot-value (s-call method (null-pointer)))))))
+
hunk ./src/overload-resolution.lisp 583
- (let ((method (find-smoke-method (class-of object) (lisp-to-cxx (string slot-name)))))
+ (let ((method (find-smoke-method class (lisp-to-cxx (string slot-name)))))
Sat Apr 3 14:04:39 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Make the slot-* functions work for C++ class attributes.
Allow slot-value to be used to access C++ member variables of objects.
hunk ./src/objects/stack.lisp 143
- (get-class type))
+ (get-class type))
hunk ./src/objects/stack.lisp 146
- (cerror "Remove the old object."
- "The object at pointer ~A is ~A but should be a ~A."
- object (get-object object) type)
- (remove-object object)
+ (when (stack-p type)
+ ;; The first member varible of a class can have the
+ ;; same address as its object.
+ ;; e.g.: QSharedData::ref
+ (cerror "Remove the old object."
+ "The object at pointer ~A is ~A but should be a ~A."
+ object (get-object object) type)
+ (remove-object object))
hunk ./src/overload-resolution.lisp 532
-
hunk ./src/overload-resolution.lisp 556
+
+(defmethod slot-missing ((class smoke-standard-class) object slot-name operation &optional new-value)
+ (let ((method (find-smoke-method (class-of object) (lisp-to-cxx (string slot-name)))))
+ (if (not (valid-p method))
+ (call-next-method)
+ (ecase operation
+ (setf [_$_]
+ (handler-case (funcall (fdefinition
+ (intern
+ (concatenate 'string "SET-"
+ (string-upcase
+ (string slot-name)))
+ :cxx))
+ object new-value)
+ (undefined-function ()
+ (error "The C++ attribute ~A of ~A is read only." slot-name object))
+ (no-applicable-cxx-method (condition)
+ (if (null (viable-functions (condition-method condition)
+ (length (condition-arguments condition))
+ (condition-class condition)))
+ (error "The C++ attribute ~A of ~A is read only." slot-name object)
+ (error condition)))))
+ (slot-boundp t)
+ (slot-makunbound (error "Can not unbind the C++ attribute ~A of ~A." slot-name object))
+ (slot-value (s-call method (cast object (get-class method))))))))
Sat Apr 3 14:03:07 CEST 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix attribute vs method map to same Lisp name clash.
e.g.: setWidget() and set_widget are in Lisp both #'set-widget. Prefer the method
over the attribute; the attribute will be accessible with SLOT-VALUE.
hunk ./src/smoke-to-clos.lisp 141
- (setf (gethash (lispify name "CXX") generics)
- name))
+ (let ((lisp-name (lispify name "CXX")))
+ (unless (and (gethash lisp-name generics) (attribute-p method))
+ (setf (gethash lisp-name generics) name))))
Wed Mar 10 17:38:58 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Improve missing to-lisp-translator error message.
hunk ./src/objects/stack.lisp 115
- (cerror "Return the pointer"
- "Do not know how to convert the type ~A to Lisp." type))))
+ (cerror "Return the pointer"
+ "Missing type translator to convert the type ~A to Lisp."
+ type))))
Sat Feb 20 21:56:27 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Allow passing integers as enum arguments.
hunk ./src/overload-resolution.lisp 372
-(defun coerce-enum (enum)
+(defun coerce-from-enum (enum)
hunk ./src/overload-resolution.lisp 381
+(defun coerce-to-enum (number)
+ ;; we can skip the enum type because it is not checked at this
+ ;; point.
+ (make-instance 'enum :value number))
+
hunk ./src/overload-resolution.lisp 394
- (make-match 'promotion 'coerce-enum)))
+ (make-match 'promotion 'coerce-from-enum)))
hunk ./src/overload-resolution.lisp 396
- (make-match 'promotion 'coerce-enum)))
+ (make-match 'promotion 'coerce-from-enum)))
hunk ./src/overload-resolution.lisp 400
- (make-match 'promotion 'coerce-double-float)))))
+ (make-match 'promotion 'coerce-double-float)))
+ (12 (when (object.typep '(integer 0))
+ (make-match 'promotion 'coerce-to-enum)))))
Sat Feb 20 19:01:21 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix overload resolution exact match for long and ulong.
hunk ./src/overload-resolution.lisp 343
- (8 (object.typep '(c-integer :long)))
- (9 (object.typep '(c-integer :unsigned-long)))
+ (8 (object.typep '(and (c-integer :long)
+ (not (c-integer :int)))))
+ (9 (object.typep '(and (c-integer :unsigned-long)
+ (not (c-integer :unsigned-int)))))
Sat Feb 20 18:56:48 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Faster no overload resolution method lookup.
hunk ./src/libsmoke/smoke.cpp 198
- *m = get_smoke(smoke)->findMethod(class_name, method_name);
+ Smoke::ModuleIndex id_class(get_smoke(smoke), class_index);
+
+ Smoke::ModuleIndex id_method_name = get_smoke(smoke)->findMethodName(class_name, method_name);
+ *m = get_smoke(smoke)->findMethod(id_class, id_method_name);
Sat Feb 20 18:24:36 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Cache overload resolution on sbcl
hunk ./src/clos.lisp 464
- (find-best-viable-function (constructor-name class)
- arguments
- class)
+ (#-sbcl find-best-viable-function
+ #+sbcl find-best-viable-function-cached
+ (constructor-name class)
+ arguments
+ class nil)
hunk ./src/objects/type.lisp 122
+ (declare (optimize (speed 3)))
hunk ./src/objects/type.lisp 124
- (foreign-slot-pointer [_$_]
- (mem-aref (smoke-array-pointer
- (smoke-module-types (smoke type)))
- 'smoke-type
- (the smoke-index (id type)))
- 'smoke-type 'name)
- :pointer)))
+ (foreign-slot-pointer [_$_]
+ (mem-aref (smoke-array-pointer
+ (smoke-module-types (smoke type)))
+ 'smoke-type
+ (the smoke-index (id type)))
+ 'smoke-type 'name)
+ :pointer)))
hunk ./src/overload-resolution.lisp 198
-(eval-when (:compile-toplevel :load-toplevel :execute)
- (defun conversion-function (name &optional arg)
- (if arg
- `(if (using-typep)
- `(,,name
- (find-class ',(class-name ,arg)))
- #'(lambda (object)
- (funcall (fdefinition ,name)
- object ,arg)))
- `(if (using-typep)
- ,name
- (fdefinition ,name)))))
-
hunk ./src/overload-resolution.lisp 200
- `(,(symbolicate 'make- (eval type))
- :function-name ,(conversion-function name argument)
- ,@args))
+ (flet ((conversion-function (name &optional arg)
+ (if arg
+ `(if (using-typep)
+ `(,,name
+ ,(if (typep ,arg 'class)
+ `(find-class ',(class-name ,arg))
+ `(find-smoke-method (find-class ,(class-name
+ (find-smoke-class
+ (get-class ,arg))))
+ ,(name ,arg))))
+ #'(lambda (object)
+ (funcall (fdefinition ,name)
+ object ,arg)))
+ `(if (using-typep)
+ ,name
+ (fdefinition ,name)))))
+ `(,(symbolicate 'make- (eval type))
+ :function-name ,(conversion-function name argument)
+ ,@args)))
hunk ./src/overload-resolution.lisp 310
- (subtypep type ',lisp-type)
+ (multiple-value-bind (value valid-p)
+ (subtypep type ',lisp-type)
+ (unless valid-p
+ (throw 'unspecific-type type))
+ value)
hunk ./src/overload-resolution.lisp 347
- (12 (and (object.typep 'enum) ;; FIXME enum-type using type
- (smoke-type= type (enum-type object))))
+ (12 (when (object.typep 'enum)
+ (when (using-typep)
+ (throw 'unspecific-type object))
+ (smoke-type= type (enum-type object))))
hunk ./src/overload-resolution.lisp 530
- (find-best-viable-function name
- arguments
- (smoke-class-of object-or-class)
- (when (typep object-or-class
- 'smoke-standard-object)
- (const-p object-or-class)))
+ (#-sbcl find-best-viable-function
+ #+sbcl find-best-viable-function-cached
+ name
+ arguments
+ (smoke-class-of object-or-class)
+ (when (typep object-or-class
+ 'smoke-standard-object)
+ (const-p object-or-class)))
hunk ./src/overload-resolution.lisp 543
- (if (static-p method)
- (apply #'call-sequence method (null-pointer) sequence arguments)
- (apply #'call-sequence method (cast object-or-class (get-class method)) [_$_]
- sequence arguments))))
+ (apply #'call-sequence method
+ (if (static-p method)
+ (null-pointer)
+ (cast object-or-class (get-class method)))
+ sequence arguments)))
hunk ./src/sb-optimize.lisp 95
-;;; cache ==================================================================
+;;; Cache overload resolution / method lookup
+
+;;; FIXME the cached lookup should be faster
hunk ./src/sb-optimize.lisp 99
-;;; we could replace the call to #'find-best-viable-function in
-;;; #'call-using-args with a call to
-;;; #'find-best-viable-function-cached, but it is only doubles speed.
+;;; cache return value conversion
+;;;
+;;; Using the gf symbol instead of the method name would be better,
+;;; althoug we would have to invent one for constructors.
+;;;
+;;; Since the -using-types stuff was intended for for compile time
+;;; expansion it is not that well suited for this. i.e. passing
+;;; closures would be better than the actual syntax.
+;;;
+;;; For qt.tests the uncached calls make up 30 % of all calls.
+;;; qt.examples:colliding-mice (run for ~1 min) gets 20 % uncached
+;;; calls and qt.examples:class-browser get 10 %. (20 February 2010)
hunk ./src/sb-optimize.lisp 112
-(sb-int:defun-cached (find-best-viable-function-using-types-cached
+(sb-int:defun-cached (find-best-viable-function-using-layouts-cached
hunk ./src/sb-optimize.lisp 117
- (class class)
+ (sb-c::layout class)
hunk ./src/sb-optimize.lisp 122
- (sxhash arguments)
+ (the fixnum
+ (reduce [_$_]
+ #'logxor
+ (mapcar #'sb-c::layout-clos-hash
+ arguments)))
hunk ./src/sb-optimize.lisp 135
- (find-best-viable-function-using-types name arguments class const-p)
+ (find-best-viable-function-using-types
+ name (mapcar #'sb-pcl::wrapper-class* arguments)
+ class const-p)
hunk ./src/sb-optimize.lisp 142
+ (declare (optimize (speed 3)))
hunk ./src/sb-optimize.lisp 145
- (second s)))))
+ (eval (second s))))))
hunk ./src/sb-optimize.lisp 147
- [_$_]
+
hunk ./src/sb-optimize.lisp 154
- (find-best-viable-function-using-types-cached
+ (find-best-viable-function-using-layouts-cached
hunk ./src/sb-optimize.lisp 156
- (mapcar #'(lambda (o) (class-of o)) arguments)
+ (mapcar #'(lambda (o) (sb-c::layout-of o)) arguments)
Fri Feb 19 22:22:50 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* cleanup #'delete-object & optimize #'constructor-name.
hunk ./src/clos.lisp 455
- (let ((name-start (search "::" (name class) :from-end t)))
+ (declare (optimize (speed 3)))
+ (let* ((name (the simple-string (name class)))
+ (name-start (search "::" name :from-end t)))
hunk ./src/clos.lisp 459
- (subseq (name class) (+ name-start 2))
- (name class))))
+ (subseq name (+ name-start 2))
+ name)))
hunk ./src/smoke.lisp 76
- (let ((method-name (concatenate 'string "~" (name (class-of object)))))
- (s-call
- (make-smoke-method-from-name (class-of object) method-name)
- (pointer object)))
+ (delete-pointer (pointer object) (class-of object))
Fri Feb 19 22:10:24 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* No need to construct a SmokeBinding per Smoke module.
hunk ./src/bindings.lisp 8
-
hunk ./src/bindings.lisp 10
- (binding (null-pointer) :type foreign-pointer)
- (no-dispatch-binding (null-pointer) :type foreign-pointer)
hunk ./src/clos.lisp 340
- ((binding :pointer)
- (method smoke-index)
+ ((method smoke-index)
hunk ./src/clos.lisp 351
- :smoke (gethash (pointer-address
- (smoke-get-smoke binding))
- *smoke-modules*)
+ :smoke (smoke (class-of object))
hunk ./src/libsmoke/smoke.cpp 15
-/** Returns the Smoke module of a Smoke binding.
- * @related cl_smoke::Binding
- * @param binding the Binding
- *
- * @return the Smoke module
- */
-CL_SMOKE_EXPORT void*
-cl_smoke_get_smoke(smoke_binding binding)
-{
- return static_cast<NoDispatchBinding*>(binding)->get_smoke();
-}
-
hunk ./src/libsmoke/smoke.cpp 28
-cl_smoke_construct_binding(void* smoke, void* destruct, void* dispatch)
+cl_smoke_construct_binding(void* destruct, void* dispatch)
hunk ./src/libsmoke/smoke.cpp 31
- return new NoDispatchBinding(static_cast<Smoke*>(smoke),
- reinterpret_cast<NoDispatchBinding::destructed>(destruct));
+ return new NoDispatchBinding(reinterpret_cast<NoDispatchBinding::destructed>(destruct));
hunk ./src/libsmoke/smoke.cpp 33
- return new Binding(static_cast<Smoke*>(smoke),
- reinterpret_cast<NoDispatchBinding::destructed>(destruct),
+ return new Binding(reinterpret_cast<NoDispatchBinding::destructed>(destruct),
hunk ./src/libsmoke/smoke.cpp 187
- * @param smoke the smoke binding
+ * @param smoke the smoke module
hunk ./src/libsmoke/smoke.lisp 41
- (smoke :pointer)
hunk ./src/libsmoke/smoke.lisp 53
-(declaim (inline smoke-get-smoke))
-(defcfun (smoke-get-smoke "cl_smoke_get_smoke") :pointer
- (smoke-binding smoke-binding))
-
hunk ./src/libsmoke/smokebinding.cpp 26
- * @param smoke the Smoke module
hunk ./src/libsmoke/smokebinding.cpp 28
-NoDispatchBinding::NoDispatchBinding(Smoke *smoke, destructed destruct)
- : SmokeBinding(smoke),
+NoDispatchBinding::NoDispatchBinding(destructed destruct)
+ : SmokeBinding(NULL),
hunk ./src/libsmoke/smokebinding.cpp 57
- Q_ASSERT(classId >= 0 && classId <= smoke->numClasses);
- return const_cast<char*>(smoke->classes[classId].className);
+ qFatal("className() Not implemented");
hunk ./src/libsmoke/smokebinding.cpp 83
- * @param smoke the Smoke module
hunk ./src/libsmoke/smokebinding.cpp 86
-Binding::Binding(Smoke *smoke, destructed destruct,
- dispatch_method dispatch)
- : NoDispatchBinding(smoke, destruct),
+Binding::Binding(destructed destruct, dispatch_method dispatch)
+ : NoDispatchBinding(destruct),
hunk ./src/libsmoke/smokebinding.cpp 99
- int ret = dispatch(this, method, object, stack, abstract);
+ int ret = dispatch(method, object, stack, abstract);
hunk ./src/libsmoke/smokebinding.h 14
- NoDispatchBinding(Smoke *smoke, destructed destruct);
+ NoDispatchBinding(destructed destruct);
hunk ./src/libsmoke/smokebinding.h 26
- Smoke*
- get_smoke() const
- { return smoke; }
-
hunk ./src/libsmoke/smokebinding.h 33
- typedef int (*dispatch_method)(Binding* binding, Smoke::Index method,
+ typedef int (*dispatch_method)(Smoke::Index method,
hunk ./src/libsmoke/smokebinding.h 36
- Binding(Smoke *smoke, destructed destruct, dispatch_method dispatch);
+ Binding(destructed destruct, dispatch_method dispatch);
hunk ./src/smoke.lisp 82
+(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))))
+
hunk ./src/smoke.lisp 98
- (smoke-module-binding (smoke class))
- (smoke-module-no-dispatch-binding (smoke class))))
+ *binding*
+ *no-dispatch-binding*))
hunk ./src/smoke.lisp 112
- (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)
Thu Feb 18 20:57:00 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Don't dispatch virtual methods for builtin classes (reduces overhead).
hunk ./src/bindings.lisp 12
+ (no-dispatch-binding (null-pointer) :type foreign-pointer)
hunk ./src/clos.lisp 350
- (when (and object (typep (class-of object) 'cxx:class))
- ;; Do not allow overwriting methods of classes the users has
- ;; not derived from (like in C++), to reduce overhead.
+ (unless (null object)
hunk ./src/libsmoke/cl_smoke.h 37
-/** Casts the void pointer smoke_binding to the Binding class.
- * @param smoke the smoke binding
- *
- * @return pointer to the Binding instance
- */
-static inline
-Binding*
-get_smoke_binding(smoke_binding binding)
-{
- return static_cast<Binding*>(binding);
-}
-
hunk ./src/libsmoke/class.lisp 8
+ (:namespace #x08)
hunk ./src/libsmoke/class.lisp 25
+(declaim (inline smoke-class-id))
hunk ./src/libsmoke/smoke.cpp 24
- return get_smoke_binding(binding)->get_smoke();
+ return static_cast<NoDispatchBinding*>(binding)->get_smoke();
hunk ./src/libsmoke/smoke.cpp 29
+ * When method dispatching is not needed, a null pointer can be passed for @a dispatch.
hunk ./src/libsmoke/smoke.cpp 31
+ * @related cl_smoke::NoDispatchBinding
+ * @related cl_smoke_destruct_binding
hunk ./src/libsmoke/smoke.cpp 40
-cl_smoke_init(void* smoke, void* destruct, void* dispatch)
+cl_smoke_construct_binding(void* smoke, void* destruct, void* dispatch)
hunk ./src/libsmoke/smoke.cpp 42
- return new Binding(static_cast<Smoke*>(smoke),
- reinterpret_cast<Binding::destructed>(destruct),
- reinterpret_cast<Binding::dispatch_method>(dispatch));
+ if (NULL == dispatch)
+ return new NoDispatchBinding(static_cast<Smoke*>(smoke),
+ reinterpret_cast<NoDispatchBinding::destructed>(destruct));
+ else
+ return new Binding(static_cast<Smoke*>(smoke),
+ reinterpret_cast<NoDispatchBinding::destructed>(destruct),
+ reinterpret_cast<Binding::dispatch_method>(dispatch));
hunk ./src/libsmoke/smoke.cpp 51
-/** Deletes the smoke binding.
- * @related cl_smoke::Binding
+/** Deletes the Smoke binding.
+ * @related cl_smoke_construct_binding
hunk ./src/libsmoke/smoke.cpp 55
-cl_smoke_destruct(smoke_binding binding)
+cl_smoke_destruct_binding(smoke_binding binding)
hunk ./src/libsmoke/smoke.cpp 57
- delete get_smoke_binding(binding)->get_smoke();
- delete get_smoke_binding(binding);
+ // Destructor is virtual; thus we can do this.
+ delete static_cast<SmokeBinding*>(binding);
hunk ./src/libsmoke/smoke.cpp 61
-/** Gets a Smoke modules name.
+/** Gets a Smoke module name.
hunk ./src/libsmoke/smoke.cpp 209
- *m = get_smoke(smoke)->findMethod(get_smoke(smoke)->className(class_index),
- method_name);
+ Q_ASSERT(class_index >= 0 && class_index <= get_smoke(smoke)->numClasses);
+
+ const char* class_name = get_smoke(smoke)->className(class_index);
+ *m = get_smoke(smoke)->findMethod(class_name, method_name);
+
hunk ./src/libsmoke/smoke.cpp 236
- * @param object the objec
+ * @param object the object
hunk ./src/libsmoke/smoke.lisp 40
-(defcfun (smoke-init "cl_smoke_init") smoke-binding
+(defcfun (smoke-construct-binding "cl_smoke_construct_binding") smoke-binding
hunk ./src/libsmoke/smoke.lisp 45
-(defcfun (smoke-destruct "cl_smoke_destruct") :void
+(defcfun (smoke-destruct-destruct "cl_smoke_destruct_binding") :void
hunk ./src/libsmoke/smokebinding.cpp 9
-/** @class Binding
- * @brief The Smoke binding.
+/** @class NoDispatchBinding
+ * @brief The Smoke binding for classes we need no dispatching.
+ * This saves some overhead, since it does not call into Lisp.
+ * Idea stolen from CommonQt ;)
+ *
+ * Dispatches for non extended classes (not of class CXX:CLASS) are between
+ * 20% - 40% (for qt.examples:colliding-mice - qt.examples:class-browser). (18 February 2010)
hunk ./src/libsmoke/smokebinding.cpp 18
-
-/** @typedef Binding::destructed
+/** @typedef NoDispatchBinding::destructed
hunk ./src/libsmoke/smokebinding.cpp 25
+/** Constructor.
+ * @param smoke the Smoke module
+ * @param destruct destruct callback
+ */
+NoDispatchBinding::NoDispatchBinding(Smoke *smoke, destructed destruct)
+ : SmokeBinding(smoke),
+ destruct(destruct)
+{
+ Q_ASSERT(destruct);
+}
+
+/** Invoked when a Smoke object is destructed. */
+void
+NoDispatchBinding::deleted(Smoke::Index, void *object)
+{
+ destruct(object);
+}
+
+/** Invoked when a Smoke method gets called. */
+bool
+NoDispatchBinding::callMethod(Smoke::Index method, void* object,
+ Smoke::Stack stack, bool abstract)
+{
+ Q_ASSERT(!abstract);
+ return false;
+}
+
+/**
+ * @todo Returning a const char* would be better
+ */
+char*
+NoDispatchBinding::className(Smoke::Index classId)
+{
+ Q_ASSERT(classId >= 0 && classId <= smoke->numClasses);
+ return const_cast<char*>(smoke->classes[classId].className);
+}
+
+/** @function NoDispatchBinding::get_smoke()
+ * Gets the Smoke instance associated with the binding.
+ * @return a pointer to the Smoke instance
+ */
+
+/** @class Binding
+ * @brief The Smoke binding.
+ */
hunk ./src/libsmoke/smokebinding.cpp 91
- : SmokeBinding(smoke),
- destruct(destruct),
+ : NoDispatchBinding(smoke, destruct),
hunk ./src/libsmoke/smokebinding.cpp 94
- Q_ASSERT(smoke);
- Q_ASSERT(destruct);
hunk ./src/libsmoke/smokebinding.cpp 97
-/** Invoked when a Smoke object is destructed. */
-void
-Binding::deleted(Smoke::Index, void *object)
-{
- destruct(object);
-}
hunk ./src/libsmoke/smokebinding.cpp 109
-/**
- * @todo Returning a const char* would be better
- */
-char*
-Binding::className(Smoke::Index classId)
-{
- return const_cast<char*>(smoke->classes[classId].className);
-}
-
-/** Gets the Smoke instance associated with the binding.
- * @return a pointer to the Smoke instance
- */
-Smoke*
-Binding::get_smoke() const
-{
- return smoke;
-}
-
hunk ./src/libsmoke/smokebinding.h 9
-class Binding : public SmokeBinding
+class NoDispatchBinding : public SmokeBinding
hunk ./src/libsmoke/smokebinding.h 14
- typedef int (*dispatch_method)(Binding* binding, Smoke::Index method,
- void* object, Smoke::Stack args, int abstract);
-
- Binding(Smoke *smoke, destructed destruct, dispatch_method dispatch);
+ NoDispatchBinding(Smoke *smoke, destructed destruct);
hunk ./src/libsmoke/smokebinding.h 27
- get_smoke() const;
+ get_smoke() const
+ { return smoke; }
hunk ./src/libsmoke/smokebinding.h 32
+};
+
+class Binding : public NoDispatchBinding
+{
+ public:
+ typedef int (*dispatch_method)(Binding* binding, Smoke::Index method,
+ void* object, Smoke::Stack args, int abstract);
+
+ Binding(Smoke *smoke, destructed destruct, dispatch_method dispatch);
+
+
+ virtual bool
+ callMethod(Smoke::Index method, void* object,
+ Smoke::Stack stack, bool abstract);
+
+
+ private:
hunk ./src/smoke.lisp 85
- (with-foreign-object (stack 'smoke-stack-item 2)
- (setf (foreign-slot-value (mem-aref stack 'smoke-stack-item 1)
- 'smoke-stack-item 'voidp)
- (smoke-module-binding (smoke (class-of object))))
- (foreign-funcall-pointer [_$_]
- (foreign-slot-value (smoke-class-pointer (class-of object))
- 'smoke-class 'class-function)
- ()
- smoke-index 0 ;; set binding method index
- :pointer (pointer object)
- smoke-stack stack
- :void)))
+ (let ((class (class-of object)))
+ (with-foreign-object (stack 'smoke-stack-item 2)
+ (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))))
+ (foreign-funcall-pointer [_$_]
+ (foreign-slot-value (smoke-class-pointer class)
+ 'smoke-class 'class-function)
+ ()
+ smoke-index 0 ;; set binding method index
+ :pointer (pointer object)
+ smoke-stack stack
+ :void))))
hunk ./src/smoke.lisp 104
- (let* ((binding (smoke-init smoke (callback destructed)
- (callback dispatch-method))))
+ (let ((no-dispatch-binding
+ (smoke-construct-binding smoke (callback destructed) (null-pointer)))
+ (binding (smoke-construct-binding smoke (callback destructed)
+ (callback dispatch-method))))
hunk ./src/smoke.lisp 109
+ (smoke-module-no-dispatch-binding module) no-dispatch-binding
Thu Feb 18 19:31:47 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix casting across Smoke modules.
hunk ./src/clos.lisp 434
- (id (class-of object)) (id class)))
+ (id (class-of object))
+ (smoke-class-id (smoke-module-pointer (smoke (class-of object)))
+ (name-pointer class))))
hunk ./src/objects/class.lisp 33
+(defun name-pointer (class)
+ (mem-ref (foreign-slot-pointer (smoke-class-pointer class)
+ 'smoke-class 'name)
+ :pointer))
+
Wed Feb 17 18:05:35 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Remove underlinking of libclsmoke and add a darwin case to the library definitons.
Thanks to Elliott Slaughter
hunk ./src/libsmoke/CMakeLists.txt 11
+
+# FIXME look for smoke.h
+find_library(smokeqtcore_LIB smokeqtcore)
+if (smokeqtcore_LIB)
+ set(smokeqtcore_FOUND TRUE)
+endif (smokeqtcore_LIB)
+
+if (smokeqtcore_FOUND)
+ message(STATUS "Found smokeqtcore: ${smokeqtcore}")
+else (smokeqtcore_FOUND)
+ message(FATAL_ERROR "Could not find smokeqtcore")
+endif (smokeqtcore_FOUND)
+
+
hunk ./src/libsmoke/CMakeLists.txt 27
+target_link_libraries(clsmoke ${QT_LIBRARIES} ${smokeqtcore_LIB})
hunk ./src/libsmoke/CMakeLists.txt 39
-install(TARGETS clsmoke clsmokeutil
- LIBRARY DESTINATION lib)
+install(TARGETS clsmoke clsmokeutil DESTINATION lib)
hunk ./src/libsmoke/smoke.lisp 3
-;; Load the qt smoke binding to prevent undefined aliens.
hunk ./src/libsmoke/smoke.lisp 4
- (define-foreign-library libsmokeqtcore
- (:unix "libsmokeqtcore.so.3")
- (t (:default "libsmokeqtcore")))
hunk ./src/libsmoke/smoke.lisp 5
+ (:darwin "libclsmoke.dylib")
hunk ./src/libsmoke/smoke.lisp 9
+ (:darwin "libclsmokeutil.dylib")
hunk ./src/libsmoke/smoke.lisp 12
- (use-foreign-library libsmokeqtcore)
hunk ./src/libsmoke/smoke.lisp 14
-
hunk ./src/smoke.lisp 175
+ (:darwin ,(format nil "~(~A~).3.dylib" library))
Tue Feb 16 22:56:19 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Load libsmokeqtcore instead of qt in the default case of cffi:define-foreign-library.
hunk ./src/libsmoke/smoke.lisp 5
- (define-foreign-library libsmokeqt
+ (define-foreign-library libsmokeqtcore
hunk ./src/libsmoke/smoke.lisp 7
- (t (:default "libsmokeqt")))
+ (t (:default "libsmokeqtcore")))
hunk ./src/libsmoke/smoke.lisp 14
- (use-foreign-library libsmokeqt)
+ (use-foreign-library libsmokeqtcore)
Tue Feb 16 22:52:02 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix derived-p for classes that are external in every module.
hunk ./src/objects/class.lisp 110
- (handler-case (make-smoke-class (name class))
- (undefined-class () class))
+ (make-smoke-class (name class))
hunk ./src/objects/class.lisp 119
-;(defun smoke-subclassp (class base-class) TODO
hunk ./src/objects/class.lisp 121
- (values
- (derived-real-p (real-class class) (real-class base-class))
- T))
+ (handler-case (derived-real-p (real-class class) (real-class base-class))
+ ;; The class is external in every module => no derived.
+ (undefined-class () nil)))
Mon Feb 15 16:31:33 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Build a shared library not a module.
Fixes on build error on OS X as reported by Elliott Slaughter.
hunk ./src/libsmoke/CMakeLists.txt 12
-add_library(clsmoke MODULE ${SMOKE_C_SOURCES})
+add_library(clsmoke SHARED ${SMOKE_C_SOURCES})
hunk ./src/libsmoke/CMakeLists.txt 18
-add_library(clsmokeutil MODULE smoke_util.cpp)
+add_library(clsmokeutil SHARED smoke_util.cpp)
Mon Feb 8 18:14:54 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* sbcl-bundle requires posix & unix
hunk ./cl-smoke.smoke.asd 10
- #+sbcl :sb-posix)
+ #+(and sbcl unix) :sb-posix)
hunk ./cl-smoke.smoke.asd 48
- #+sbcl (:file "sbcl-bundle")
+ #+(and sbcl unix) (:file "sbcl-bundle")
Thu Feb 4 16:11:29 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Test building libclsmoke.
hunk ./test.lisp 2
+cmake ./ || exit 1
+make || exit 1
Wed Feb 3 17:20:56 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix compiling libclsmoke with asserts enabled.
smoke_get_class was not declared in this scope
Reported by:
Elliott Slaughter
hunk ./src/libsmoke/smoke.cpp 181
- Q_ASSERT(!smoke_get_class(smoke, class_index)->external);
- Q_ASSERT(!smoke_get_class(smoke_base, base_index)->external);
+ Q_ASSERT(!cl_smoke_get_class(smoke, class_index)->external);
+ Q_ASSERT(!cl_smoke_get_class(smoke_base, base_index)->external);
Wed Feb 3 07:44:09 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Add missing :sb-posix dependency.
hunk ./cl-smoke.smoke.asd 9
- (:cffi :closer-mop :alexandria :trivial-garbage :bordeaux-threads)
+ (:cffi :closer-mop :alexandria :trivial-garbage :bordeaux-threads
+ #+sbcl :sb-posix)
Sat Jan 30 15:40:08 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Do not warn on missing parent class.
hunk ./src/clos.lisp 201
- (if real-class
- (push (class-name real-class) class-symbols)
- (warn "The class ~A could not be found in any module."
- (name class))))
+ (when real-class
+ (push (class-name real-class) class-symbols)))
Tue Jan 26 17:26:09 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix for r1077826. Not instantiable parent classes are external. (QAbstractPrintDialog)
hunk ./src/clos.lisp 196
-(defun smoke-class-symbol (smoke-class)
- "Returns the Lisp class-name of SMOKE-CLASS:"
- (if (external-p smoke-class)
- (class-name (find-smoke-class smoke-class))
- (lispify (name smoke-class))))
+(defun smoke-class-symbols (classes)
+ (let ((class-symbols))
+ (dolist (class classes class-symbols)
+ (if (external-p class)
+ (let ((real-class (find-smoke-class class nil)))
+ (if real-class
+ (push (class-name real-class) class-symbols)
+ (warn "The class ~A could not be found in any module."
+ (name class))))
+ (push (lispify (name class)) class-symbols)))))
hunk ./src/clos.lisp 227
- (mapcar #'smoke-class-symbol
- (smoke-class-direct-superclasses class))
+ (smoke-class-symbols
+ (smoke-class-direct-superclasses class))
Mon Jan 25 19:47:00 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Check enum type on overload resolution
hunk ./src/overload-resolution.lisp 340
- (12 (object.typep 'enum)) ;; FIXME enum-type
+ (12 (and (object.typep 'enum) ;; FIXME enum-type using type
+ (smoke-type= type (enum-type object))))
Mon Jan 25 19:46:41 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* single-float conversion
hunk ./src/overload-resolution.lisp 366
+(defun coerce-single-float (number)
+ (float number 0f0))
+
hunk ./src/overload-resolution.lisp 380
+ (10 (when (object.typep 'real)
+ (make-match 'promotion 'coerce-single-float)))
Mon Jan 25 19:41:22 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Add :arg3 for make-instance SMOKE-CLASS.
hunk ./src/clos.lisp 478
+ (arg3 nil arg3p)
hunk ./src/clos.lisp 493
+ (arg3p (list arg0 arg1 arg2 arg3))
Sat Jan 23 20:45:41 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* class & type size (and some more exports)
hunk ./src/objects/class.lisp 33
+(defun class-size (smoke-class)
+ (class-slot-value smoke-class 'size))
+
hunk ./src/objects/class.lisp 62
+(defun copy-constructor-p (class)
+ (/= 0 (get-class-flag class :copy-constructor)))
+
hunk ./src/objects/stack.lisp 114
- (error "Do not know how to convert the type ~A to Lisp." type)))
+ (prog1 (foreign-slot-value stack-item 'smoke-stack-item 'voidp)
+ (cerror "Return the pointer"
+ "Do not know how to convert the type ~A to Lisp." type))))
hunk ./src/objects/type.lisp 142
+;; Return the cffi keyword for the type
+(defun type-foreign-keyword (smoke-type)
+ (intern (nsubstitute #\- #\ (nstring-upcase (name smoke-type)))
+ :keyword))
+
+(defun type-size (smoke-type)
+ (if (class-p smoke-type)
+ (class-size (get-class smoke-type))
+ (foreign-type-size (type-foreign-keyword smoke-type))))
+
hunk ./src/package.lisp 16
- (:export #:init
- #:get-smoke-variable-for-pointer
+ (:export #:call
+ #:c-integer
hunk ./src/package.lisp 19
- #:make-smoke-classes
- #:eval-startup
- [_$_]
- #:delete-object
- #:smoke-call
- #:call
-
- #:name
+ #:class-p
+ #:class-size
+ #:const-p
hunk ./src/package.lisp 23
- #:smoke-type=
+ #:name
+ #:pointer
+ #:pointer-p
+ #:size
+ #:smoke
+ #:stack-p
+ #:type-foreign-keyword
+ #:type-id
+ #:type-size
+ #:virtual-destructor-p
hunk ./src/package.lisp 34
+ #:convert-argument
hunk ./src/package.lisp 39
+ #:*to-lisp-translations*
+
hunk ./src/package.lisp 42
- #:make-cleanup-pointer
+ #:define-smoke-module
+
+ #:define-takes-ownership
+ #:delete-object
+ #:remove-object
+
+ #:eval-startup
+
+ #:get-smoke-variable-for-pointer
+ #:init
+ #:object-to-lisp
+
hunk ./src/package.lisp 55
+ #:make-cleanup-pointer
hunk ./src/package.lisp 57
- #:const-p
- #:pointer
- #:define-smoke-module
- #:define-takes-ownership
+ #:make-smoke-classes
+ #:make-smoke-type
+ #:no-applicable-cxx-method
+ #:smoke-call
+ #:upcast
+
+ #:smoke-standard-object
+ #:smoke-type
+ #:smoke-type=
hunk ./src/smoke-to-clos.lisp 169
- ;; FIXME when loading the Lisp image we no longer need to
- ;; call #'ensure-class, but the class-map needs still
+ ;; FIXME when loading the Lisp image we no longer need
+ ;; to call #'ensure-class, but the class-map needs still
Sun Jan 17 22:04:08 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix class-map image loading and use the new static smoke methods.
indClass() and isDerivedFrom() are now static (r1076132 and also in KDE 4.4).
hunk ./src/class-map.lisp 11
- (assert value ()
- "Unknown smoke module ~A ~A."
- smoke (smoke-get-module-name (smoke-module-pointer smoke)))
+ (assert value () "Unknown smoke module ~A." smoke)
hunk ./src/libsmoke/class.lisp 22
- (smoke :pointer)
hunk ./src/libsmoke/smoke.cpp 133
- * @param smoke the smoke module
hunk ./src/libsmoke/smoke.cpp 136
-cl_smoke_find_class(Smoke::ModuleIndex* c, void* smoke, const char* name)
+cl_smoke_find_class(Smoke::ModuleIndex* c, const char* name)
hunk ./src/libsmoke/smoke.cpp 138
- *c = get_smoke(smoke)->findClass(name);
+ *c = Smoke::findClass(name);
hunk ./src/libsmoke/smoke.cpp 184
- return get_smoke(smoke)->isDerivedFrom(get_smoke(smoke), class_index,
+ return Smoke::isDerivedFrom(get_smoke(smoke), class_index,
hunk ./src/objects/class.lisp 64
- ((smoke-name :initarg :smoke-name
- :initform nil
- :documentation "The name of the Smoke module"))
+ ()
hunk ./src/objects/class.lisp 66
- (format stream "No Smoke class named ~S in the Smoke module ~S."
- (cell-error-name condition)
- (slot-value condition 'smoke-name))))
+ (format stream "No Smoke class named ~S."
+ (cell-error-name condition))))
hunk ./src/objects/class.lisp 76
-(defun make-smoke-class (smoke name)
- "Returns the class named NAME of the smoke module SMOKE.
+(defun make-smoke-class (name)
+ "Returns the class named NAME.
hunk ./src/objects/class.lisp 81
- (smoke-find-class c (smoke-module-pointer smoke) name)
+ (smoke-find-class c name)
hunk ./src/objects/class.lisp 84
- (error (make-condition 'undefined-class :name name :smoke-name (smoke-get-module-name (smoke-module-pointer smoke))))
+ (error (make-condition 'undefined-class :name name))
hunk ./src/objects/class.lisp 104
- (handler-case (make-smoke-class (smoke class) (name class))
+ (handler-case (make-smoke-class (name class))
hunk ./src/objects/method.lisp 20
- (call-next-method)
+ (print-unreadable-object (smoke-method stream :type t)
+ (princ "no method" stream))
hunk ./src/objects/method.lisp 140
- (format nil "~A~:[~; static~]" (access method) (static-p method)))
+ (format nil "~:[~;virtual ~]~A~:[~; static~]" [_$_]
+ (virtual-p method) (access method) (static-p method)))
hunk ./src/objects/method.lisp 214
+(defun virtual-p (method)
+ "Returns T when METHOD is internal and NIL otherwise."
+ (/= 0 (get-method-flag method :virtual)))
+
hunk ./src/smoke-to-clos.lisp 168
+ (eval-startup (:compile-toplevel :load-toplevel :execute)
+ ;; FIXME when loading the Lisp image we no longer need to
+ ;; call #'ensure-class, but the class-map needs still
+ ;; to be populated by #'add-id-class-map and #'add-id;
+ ;; For now we ignore the negligible overhead.
+ (make-smoke-classes ,package ,smoke))
hunk ./src/smoke-to-clos.lisp 175
- (make-smoke-classes ,package ,smoke)
hunk ./src/smoke.lisp 55
-(defun static-call (smoke class-name method-name &rest args)
- (s-call (make-smoke-method-from-name (make-smoke-class smoke class-name)
- method-name)
- (null-pointer) args))
-
Sun Jan 10 18:31:42 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Fix overload resolution when a lisp smoke module is not loaded.
hunk ./cl-smoke.smoke.asd 57
-(defmethod operation-done-p ((o test-op) (c (eql (find-system :cl-smoke.smoke))))
- nil)
-
hunk ./src/objects/class.lisp 73
+(define-condition lisp-module-not-loaded (error)
+ ((class-name :initarg :class-name))
+ (:report (lambda (condition stream)
+ (format stream "The Lisp smoke module of the class ~A is not loaded."
+ (slot-value condition 'class-name)))))
+
hunk ./src/objects/class.lisp 93
- (make-instance 'smoke-class
- :id (foreign-slot-value c 'smoke-module-index 'index)
- :smoke (gethash (pointer-address (foreign-slot-value c 'smoke-module-index 'smoke)) *smoke-modules*))))
+ (let ((class (make-instance
+ 'smoke-class
+ :id (foreign-slot-value c 'smoke-module-index 'index)
+ :smoke (gethash (pointer-address (foreign-slot-value
+ c 'smoke-module-index
+ 'smoke))
+ *smoke-modules*))))
+ (unless (smoke class)
+ (error (make-condition 'lisp-module-not-loaded :class-name name)))
+ class)))
hunk ./src/overload-resolution.lisp 466
- (let ((to-class (find-smoke-class (get-class type) nil)))
- (when (and to-class
- (call-using-types find-best-viable-function2
- (if (using-typep)
- #'standard-conversion-sequence-using-types
- #'standard-conversion-sequence)
- (constructor-name (get-class type))
- (list object) to-class))
- (make-match 'user-conversion
- 'coerce-to-class
- to-class)))))
+ (handler-case
+ (let ((to-class (find-smoke-class (get-class type) nil)))
+ (when (and to-class
+ (call-using-types find-best-viable-function2
+ (if (using-typep)
+ #'standard-conversion-sequence-using-types
+ #'standard-conversion-sequence)
+ (constructor-name (get-class type))
+ (list object) to-class))
+ (make-match 'user-conversion
+ 'coerce-to-class
+ to-class)))
+ ;; When the correspoinding Lisp module is not loaded, we ignore
+ ;; the overload.
+ (lisp-module-not-loaded ()))))
Sun Jan 10 18:30:48 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* Auto-recompile when the smoke module has changed.
hunk ./src/smoke-to-clos.lisp 90
- "Raises an error when the fasl of the DEFINE-METHOS was not compiled against
-the current smoke module."
- `(eval-when (:load-toplevel :execute)
- (unless (sizes= (,smoke)
- smoke-module-methods
- smoke-module-method-names
- smoke-module-method-maps
- smoke-module-classes
- smoke-module-types)
- (error "The smoke module ~A changed, you need to recompile the lisp file."
- (smoke-get-module-name (smoke-module-pointer ,smoke))))))
+ "Raises an error or tries to recompile when the fasl of the define-classes-and-gfs
+was not compiled against the current smoke module."
+ (with-unique-names (restart)
+ `(eval-when (:load-toplevel :execute)
+ (unless (sizes= (,smoke)
+ smoke-module-methods
+ smoke-module-method-names
+ smoke-module-method-maps
+ smoke-module-classes
+ smoke-module-types)
+ (let ((,restart (find-restart 'asdf:try-recompiling)))
+ (if ,restart
+ (invoke-restart ,restart)
+ (error "The smoke module ~A changed, you need to recompile the lisp file."
+ (smoke-get-module-name (smoke-module-pointer ,smoke)))))))))