Software Tool Development Through the Visual Age for C++ Extension API:S
Total Page:16
File Type:pdf, Size:1020Kb
Software Tool Development through the Visual Age for C++ Extension API:s by MINWEI WEI A thesis submitted to the Department of Electrical and Cornputer Engineering in confonnity with the requirements for the degree of Master of Science (Engineering) Queen's University Kingston, Ontario, Canada Dec, 2000 copyright O Minwei Wei, 2000 National Library Bibliothèque nationale 1*1 of Canada du Canada Acquisitions and Acquisitions et Bibliographic Services services bibliographiques 395 Wellington Street 395, nie Wellington Ottawa ON KIA ON4 Ottawa ON KI A ON4 Canada Canada The author has granted a non- L'auteur a accordé une licence non exclusive licence allowing the exclusive permettant a àa National Library of Canada to Bibliothèque nationale du Canada de reproduce, loan, distribute or sell reproduire' prêter, distribuer ou copies of this thesis in microform, vendre des copies de cette thèse sous paper or electronic formais. la forme de microfiche/fïh, de reproduction sur papier ou sur fomat électronique. The author retains ownership of the L'auteur conserve la propriété du copyright in this thesis. Neither the droit d'auteur qui protège cette thèse. thesis nor substantid extracts fiom it Ni la thèse ni des extraits substantiels may be printed or otherwise de celle-ci ne doivent être imprimés reproduced without the author's ou autrement reproduits sans son permission. autorisation. Glossary API - Application Program Interface. GUI - Graphic User Interface. IDE - Integrated Development Environment. incremental build - A compiling and linking process that depends on smaller language element than fde, for example, function, class and variable. This technique aUow fast rebuild after first build with minor change to a huge project since it only rebuild the Ianguage elements that are depends on the changed one(s). J2CPP - A Ci+ to Java wrapper generator developed by IBM. It takes Ci-+ header file as input and generate the wrapper fde for the definition in the header file to enable Java program directly use Ci+ classes. parser - Also known as a recognizer. A parser scans a Stream of input tokens or lexemes that constitute a source file or program. The parser can build a symbol table and a parse tree, but it does not generate the object code that constitutes the compiled program. parsing - The process of finding a parse tree for a given string of input tokens. Parsing is actually a two-part process consisting of breaking a sequence of characters into tokens (scanning) and building a symbol table and parse tree from the resulting sequence of tokens. token - The minimal lexical unit of input for a parser. A scanner groups appropriate sequences of characters into strings (or delimiters) classified as input tokens. translation - The process of converting a source language (for example C, C*, and Java) into a destination language (machine code, byte codes, or possibly another language like Pascal). OEten called compilation. UI. - User Interface, the interface between the human users and the computer prograrns- VAC - VisualAge for Cu, a integrated development environment developed by IBM that provide many utilities for building Ci+ language projects. visual GUI builder - A programming environment or a set of programming tools that enables rapid-graphic user interface construction by mostly mouse based operation. Abstract: Many software-engineering tasks require parsing source code. Typically, this has been accomplished by either independently developing the required parsing hinctionality or by rnodifying existing parsers. Both techniques, however, involve considerable effort and generally result in code with much less generality and sophistication than a parser included in a commercial availabIe compiler. In contrast, the IBM Visual Age C++ product wraps its interna1 CH- parser to offer a unique API (Application Programming Interface) set that provides aimost all the hinctionality of a Ctt parser. In this thesis, we wish to explore new directions for the application of this fimctionality in the areas of GUI integration, cross-language implementations and software reuse. The results of Our work shows that using this API will greatly simpliq both the tool development process and the resulting tool. In one of our exarnple, the tool rewntten with this API has only 1/30 lines of code of the original tool. This result cari be extended to many other applications designed, for example, to simpliS the construction of GUI'S, to display general information about a program, and to port between different languages. Glossary ....................,........................................................................................................ 1 Abstract: ............................................................................................................................ ILI -1 Introduction .......,....................................................................................................... 1 -1.1 Background and Motivation ............................................................................... I -1-2 Contributions of the Thesis .................................. ... I 1.2.1 Tool intemation and scalability .................................................................. I 1.2.2 GUI intemation ........................................................................................... 2 -1.2.3 Software reuse and cross-Ianguage. implementation ................................... 3 -1.3 Introduction to the APL ....................................................................................... 4 1.3.1 Cornmon Features ....................................................................................... 5 1.3.2 Stores........................................................................................................... 6 1.3.3 Downcasterss .............................................................................................. 6 1.3.4 Classifiers .................................................................................................... 7 -1.3-5 Iterators ........................ .... ............................................................................ 8 -2 Tools development and scalable IDE ......................................................................... 9 -2.1 VAC++ IDE Extensions ........................................ ................... 9 2.2 - Graphmrt Example. ............ .... ............................................................................9 -2.3 Filter exarn~le................... ... .....................................~.................................... 15 3 GUI intemtion ..................... .... ................................................................................ 21 - . -3.1 Graphical User Interface ................................................................................. 22 -3.2 htejgating GUI construction with the IDE ......................................................22 3.2.1 VACtt IDE introduction - Obiect fiow .................................................. 22 3.2.2 Intemtion-A sample study .................................................................... 23 3.2.3 Conclusion ................................................................................................ 29 -4 Cross-lanmaae- Irnplementation and Software Reuse .............................................. 3 1 -4.1 Introduction ..........................,,......................................................................... 3 1 -4.2 Introduction to Software Reuse ........................................................................ 3 1 4.3 Cross-lanmage and software reuse ............................................ ...33 -5 Rewriting the J2CPP Tooi ........................................................................................ 35 -5.1 JNI introduction ................................................................................................ 36 -5.2 API Re-implementation for the J2CPP tool .................. .. ...........................-42 5.2.1 TvDe conversion....................................................................................... 42 5.2.2 Method Wra~~inp;........................ ... ................................................... 63 -5 2.3 VariabIe wra~~ine;.................................................................................... 78 5.2.4 COIIS~UC~OXSWrapping .................... ....... .............................................. 85 -5.2.5 Destmctors and delete0 method ............................................................. 90 -5.2.6 Meritance .................................... ... ............................................---.-..92 -5.3 Resdt and Conclusion ..................................................................................-... 95 6 Siimmary and Conclusion ...................................................................................... 97 Reference: ....................... ...,.. ......................................................................................... 99 mA............................................................................................................................... 102 1 Introduction 1.1 Background and Motivation This thesis explores the unique features of the IBM Vis;ual Age CH- prodt ~ctin several areas of software engineering tool development. Unlike most existing software tools that parse C/C++ source code, the IBM product provides a simple and user-friendly Application Progamming Interface (AH) set that enables direct and immediate