Thursday, March 21, 2013


I did some more checks to find the causes for the crashes and one of the things I checked was the way the instances were created and deleted:
- there are no Dtor calls on instances that weren't created before
- there is not more than one Dtor call for the same instance
- for the program crashes during a Dtor call, the instance hand't been deleted before

There were situations when I drew as much as possible without the application becoming too slow, and there were no crashes.

I built the dlls in Release mode (I installed Qt version 4.7.3 from here: qt-win-opensource-4.7.3-vs2008.exe and fixed some wrong settings in the NaroOccCore project file) and created the installer for this version of Naro. The resulting file is slightly smaller than the one built with the old wrappers. Enter Sketch doesn't work on the installed Naro, I'll fix the bug and start testing the new wrapper functionality in the installed version, as well. The good news is that the dlls are built correctly and there are no calls to VS2008-dependent dlls as it was when we previously built Naro with these wrappers.

I also tried to improve the way 'const' in being handled in the generation code - I kept the other fixes and changed only the const keyword, but there were crashes after drawing one circle. I will continue investigating this.

Tuesday, March 19, 2013

Improvements to the new wrappers

This week I started working on fixing the new wrappers crashes in Naro.

The things I checked were:
- base class destructor calls - made some changes to NativeInstance.cs and updated some of the destructors to have try/catch blocks.
- base class destructors in .cpp - changed StandardTransient.cpp and MMgtTShared.cpp destructor methods to cast the passed instance to the base class instead of the Handle_ class
- checked that the OCC classes implemented the correct base classes
- updated some methods and constructors and added the const keyword

These changes caused the crashes to appear much later and in other methods (I've enabled debugging in the .cpp files) and it's now possible to draw many shapes:

I will continue investigating the reasons for the crashes and find a way to automate the manual changes I've done to the code over the past two days.

Friday, March 15, 2013

Update and new DLLs

Today I managed to build the NaroHost solution without errors, so now I have both new DLLs in the Debug version: NaroOccCore.dll is 887 KB and NaroCppCore.dll is 1,85 MB.
I've started testing Naro with these files (using the 3242 changeset) and it crashes after some shapes are drawn. I've tested Sketch creation and drawing circles, lines, rectangles and arcs. Next week I'll work on finding and fixing the cause of the crashes.

The last steps for making NaroOccCore.dll build were:
- improved the Generator to handle the string return type and convert it to Standard_CString and convert IntPtr to void*
- improved the IsHandle method to process other classes correctly
- fixed the .api template for empty constructors
- added handling for some strange cases in Open Cascade when setters and getters were returning different types

After generating the new .api file and running ApiWrappers for it, the generated files were correct and there were no errors, but when trying to build NaroHost again, using those files (to generate NaroOccWrappers.dll) there were several errors. The fixes for these were:
- commenting some variables in Extrema_FuncExtPS.hxx and Extrema_PCFOfEPCOfExtPC.hxx (they aren't used by the code, but we get 'error C2248: cannot access private member declared in class 'TColStd_SequenceOfReal'' if we build with them uncommented).
- adding the IsSameTransient method - this isn't part of the OpenCascade Standard package, so it isn't generated - I've added the code from source control, changeset 3242
- adding casts in 3 files where the proper overload couldn't be resolved

Friday, March 1, 2013

Xml file generation almost done

This week I improved the XML generation code (the resulting files are .api - the same as the old OccWrapper.api file) and the conversion program to:
* have better output for the templates
* convert types
* merge all generated files per package (will merge into one file eventually, but it's easier to check everything if they're split)
* add IsRef attributes
* parse methods and transform them into properties, with the corresponding XML attributes and children
* handle static methods and properties

With these changes, the NaroHost program doesn't need any changes - the .api file that it receives as input is correctly formatted and it can generate all the files as before. I've also created a little program that compares the files NaroHost generates using the old and new .api files (for now only the resulting .cs files) - since the new .api files cover all OpenCASCADE methods and classes, we have extra methods and new files and a regular line by line comparison wouldn't work. My tool splits the file in methods and DllImports and compares these, and for the .gp package, the results are good, with only two types of differences:
* the old code generated only getters or setters for some properties and the new one sometimes generates both. I will need to refine the code to cover these cases, as well
* empty Constructors were added when the old .xml file didn't have any parameterless constructors. If the new one adds constructors with no parameters, those aren't added anymore

The time needed run OCWrappersExt, the conversion program and NaroHost is under 10 minutes.

On Monday I will continue checking the .cpp and .h files and check the other packages.