From 49bd8a8651e480fe7caa2185947ab828b6738cb6 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 18 Oct 2000 14:49:20 +0000 Subject: [PATCH] Clean up formatting to conform to coding convention. [SVN r8000] --- extclass.cpp | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/extclass.cpp b/extclass.cpp index e246b973..c654afa3 100644 --- a/extclass.cpp +++ b/extclass.cpp @@ -218,28 +218,26 @@ ExtensionClassBase::ExtensionClassBase(const char* name) { } -/* - This function is used in from_python() to convert wrapped classes that are - related by inheritance. The problem is this: although C++ provides all necessary - conversion operators, source and target of a conversion must be known at compile - time. However, in Python we want to convert classes at runtime. The solution is to - generate conversion functions at compile time, register them within the appropriate - class objects and call them when a particular runtime conversion is required. - - If functions for any possible conversion have to be stored, their number will grow - qudratically. To reduce this number, we actually store only conversion functions - between adjacent levels in the inheritance tree. By traversing the tree recursively, - we can build any allowed conversion as a concatenation of simple conversions. This - traversal is done in the functions try_base_class_conversions() and - try_derived_class_conversions(). If a particular conversion is impossible, all - conversion functions will return a NULL pointer. - - The function extract_object_from_holder() attempts to actually extract the pointer - to the contained object from an InstanceHolderBase (a wrapper class). A conversion - of the held object to 'T *' is allowed when the conversion - 'dynamic_cast *>(an_instance_holder_base)' succeeds. -*/ -void * ExtensionClassBase::try_class_conversions(InstanceHolderBase* object) const +// This function is used in from_python() to convert wrapped classes that are +// related by inheritance. The problem is this: although C++ provides all necessary +// conversion operators, source and target of a conversion must be known at compile +// time. However, in Python we want to convert classes at runtime. The solution is to +// generate conversion functions at compile time, register them within the appropriate +// class objects and call them when a particular runtime conversion is required. + +// If functions for any possible conversion have to be stored, their number will grow +// qudratically. To reduce this number, we actually store only conversion functions +// between adjacent levels in the inheritance tree. By traversing the tree recursively, +// we can build any allowed conversion as a concatenation of simple conversions. This +// traversal is done in the functions try_base_class_conversions() and +// try_derived_class_conversions(). If a particular conversion is impossible, all +// conversion functions will return a NULL pointer. + +// The function extract_object_from_holder() attempts to actually extract the pointer +// to the contained object from an InstanceHolderBase (a wrapper class). A conversion +// of the held object to 'T *' is allowed when the conversion +// 'dynamic_cast *>(an_instance_holder_base)' succeeds. +void* ExtensionClassBase::try_class_conversions(InstanceHolderBase* object) const { void* result = try_derived_class_conversions(object); if(result)