On Apr 10, 2005, at 11:40 AM, has wrote:

Just a quick heads-up on my latest venture into the wild and wonderful world of the Open Scripting Architecture, MacPythonOSA:
..
I will definitely need expert advice on the finer points of OSA component implementation in order to complete it, so if someone can help me out there it would be hugely appreciated.

In the implementation, you do this:

#define MAX_CSTRING_PATH_SIZE 32768 /* Because 32KB should be enough for anyone... */

32KB is *way* oversized and could actually cause a problem because the default stack size on Mac OS X is rather small. The right way is to just use MAXPATHLEN. MAXPATHLEN is defined in <sys/param.h>, but you're already including python.h -- which should guarantee that it is defined (even on platforms that don't on their own).

You #include <MacPythonOSA.h> -- which should actually be #include "MacPythonOSA.h" -- because it's not a system header. Though obviously it doesn't make a difference in this case.

The style you use for C code is totally whack, especially the indentation. It would be a lot more readable if you wrote it in a standard style, the obvious choice would be PEP 7 <http://python.org/peps/pep-0007.html>.

You should refactor this so that it doesn't link to Python.framework directly, and instead loads up all of the symbols at runtime based upon a configurable Python library. The biggest reason for this is: if the process is already linked to Python, and you link in a different one by virtue of this component being loaded into the process (not even initialized), it could very well crash. The py2app plugin template doesn't currently look for an existing linked interpreter, but it will at some point soon because I have to refactor it anyway. If you detect an interpreter other than the one you expected, it should probably prevent the component from being initialized -- since you need the aem extension to be present.

-bob

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to