//TH-Header //***************************************************************************************** // Copyright (c) 2014 KURANT Project // All rights reserved. // // $FileName : dfcbldr.pkg // $ProjectName : The Hammer 2.0 // $Authors : Magnus Bergh // $Created : 01.25.2014 01:08 // $Type : LGPL // // Contents: // Wrapper package for dfcbldr for Hammer // // Note: // Will create the dfc file and register the class. // // Maybe there should be an option to only registering a class (using an existing .dfc file) // w/o creating the .dfc file. But the whole point by using dfcbldr is not having to manually // creating the dfc file. // // This version does not get settings from an existing .dfc file. In a future version I would like // to get options (dfc properties) from an existing .dfc file. // Maybe also an option to edit existing class properties // w/o reading the class definition and maybe adding new properties not found in class // // Magnus Bergh // //***************************************************************************************** //TH-RevisionStart //TH-RevisionEnd // Class and methods for source code handling use cReadsrc.pkg use mVdftools.pkg // This is just a wrapper object around all dfcbldr stuff // Good for two reasons: a) Everything encapsualted here // and b) Less for me to rewrite from stand-alone dfcbldr Object oDfcbldr Is A Container // Following properties are accessed from support objects by using delegation // makes my life easier but maybe not the cleanest method, but hey I'm not perfect :-) // // Which VDF version are we using? property string psVdfVersion '' // Which workspace? property string psCurrentWkspc public // Where should we register class? 0=Global, 1=Current workspace property integer piDFCLocation 1 // Package file for class definition property string psCurrentFileName '' // Include packages. Note there are dependencies between objects. // Not very good but I don't want to change it right now. And it does work! // Package to read source code, extract class name(s) and properties // Could have put all code inside this object but I prefer to split it into separate packages // easier to read and code can be used outside Hammer as well use readsrc.bp // Setup properties for .dfc file, create dfc file and register it! use setclass.dg // Select which class to create dfc file for if several classes in source use selclass.dg // Do all our stuff for creating and register a class. This is a private method and intended // to be called from IDERegisterClass only Procedure pDoRegisterIdeClass string sVersion string sWkspc string sFileName integer hoArrayId string sVal integer iRet set psVdfVersion to sVersion set psCurrentWkspc to sWkspc set psCurrentFilename to sFileName // Step 1: Scan source code. Return value returns number of classes in source get fReadSourceArray of (oReadSource(self)) hoArrayId to iRet // Oops, no class definition found. Something must be wrong (don't blame me) if not iRet Begin // Don't know if you would prefer an ordinary error message (I usuallly do) send stop_box 'No class definition in source!' procedure_return End // Step 2: Select which class to use // Step 3: Show dialog to set properties // Step 4: Create dfc file and register. // More than one class found in definition. // Shouldn't happen when reading an array which holds only one class, but you never know... // Let the user select which class(es) to use if (iRet> 1) Begin // This will let the use select which class to use. May select more than one class // This object will call oSetupClass directly send pShowSelectClass to (oSelectClass(self)) End else Begin // There is only one class. Show dialog to select properties before creating and registering the class get fgetClassName of (oClass_Array(self)) 0 to sVal send pShowSetClass to (oSetupClass(self)) sVal End End_Procedure End_Object // Public interface for creating and registering a dfcfile Procedure IDERegisterClass For Desktop String sVersion String sCurWrkSpc String sFileName Integer hoArrayID send pDoRegisterIdeClass to (oDfcbldr(oClientArea(oMain(self)))) sVersion sCurWrkspc sFileName hoArrayId end_procedure