Generated file name is too longΒΆ

Generated file name is too long

There are use cases, when Py++ generated file name is too long. In some cases the code generation process even fails because of this.

This is just a symptom of the problem. This happens when you expose template instantiated classes and you did not specify the class alias. Py++ uses a class alias as a basis for the file name.

Let me explain.

template < class T>
struct holder{ ... };

As you know, a class name in Python has few constraints and Py++ is aware of them. “holder< int >” is illegal class name, so Py++ will generate another one - “holder_less_int_greater_”. Pretty ugly and even long, but at least it is legal one.

It is pretty simple to change the alias of the class, or any other declaration:

from pyplusplus import module_builder

mb = module_builder_t( ... )
holder = mb.class_( 'holder< int >' )
holder.alias = 'IntHolder'
#the following line has same effect as the previous one:
holder.rename( 'IntHolder' )

Another solution to the problem, is to use different strategy to split the generated code to files. You can read more about splitting files here.