...
The extension tag below will engage extension code in gmPL_GlobalStubs.dll located in the C:\Dev\gmGlobalStubs\bin\Debug\ folder.
Code Block |
---|
|
<GlobalStubs DllName="C:\Dev\gmGlobalStubs\bin\Debug\gmPL_GlobalStubs.dll">
...
</GlobalStubs>
NOTE: The DllName value will typically be specified as a relative path or a path using a gmPL script variable (e.g. %UserFolder%). |
gmPL extensions assemblies and classes must have the following conventions:
Code Block |
---|
|
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml*** gmPL_GlobalStubs.dll *** <-- recommended name is gmPL_<ExtensionName>.dll
namespace gmBasic <-- namespace must be gmBasic
{
public class gmPL_GlobalStubs <-- class name must be gmPL_<ExtensionName>
{
XeqStatement(string record); <-- extension command handler |
...
The script template below contains the <Search> command that triggers execution of gmPL_Search.
Code Block |
---|
|
<gmBasic>
<Select Target="%UserFolder%"/>
<Select CodeSize="500000"/>
<Select VirtualRoot="%VirtualRoot%"/>
<Select DeployLocation="%VirtualRoot%\..\SrcPrep"/>
%AuditMode%
<Storage action="Open" identifier="%InfoFile%" />
<Output Status="New" Filename="%RptPath%" StripTrail="on" %Syntax% />
<Search>
<%InfoType% %Project% />
</Search>
<Storage Action="Close" />
</gmBasic> |
...
gmSharedFile.dll is single statement gmPL extension library that executes the "SharedFile" command.
Code Block |
---|
|
<gmBasic>
<Storage Action="Create" Identifier="SharedFile" />
<Load project="%VirtualRoot%\A.vbp" SourceCode="On" />
<Load project="%VirtualRoot%\B.vbp" SourceCode="On" />
...
<Output Status="New" Filename="%BndPath%" />
<SharedFile RegistryFile="..\usr\Registry_SharedFile" >
<VbiFile identifier="A.vbi" />
<VbiFile identifier="B.vbi" />
...
</SharedFile>
<Storage Action="Close" />
</gmBasic> |
...
The gmCodeStyle.dll is an event handler gmPL extension that assists with generating "CodeStyle" translations. In order to engage this dll, the translation script must contain a <CodeStyle> statement. For example:
Code Block |
---|
|
<CodeStyle Configuration="..\usr\CodeStyle.std.xml" /> |
This statement triggers loading the gmPL_CodeStyle.dll and configuring it with the specified CodeStyle rules. It also registers the DLL to extend the handling of Analyse and Author events when they occur during the translation process.
This integration is done in the DLL code.
Code Block |
---|
|
Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yamlnamespace gmBasic {
public class gmPL_CodeStyle {
...
public static int XeqStatement(string record)
{
string scriptTag = null;
string configuration = null;
int returnCode = 0;
bool ending = false;
scriptTag = Script.GetTag(record,out ending);
if(String.Equals("CodeStyle", scriptTag, StringComparison.OrdinalIgnoreCase))
{
configuration = Script.GetAttribute("Configuration",record);
if(configuration == null) returnCode = 0;
else
{
Configuration.Startup(configuration);
returnCode = Script.HasEventHandlers;
}
}
else if(String.Equals("Compile", scriptTag, StringComparison.OrdinalIgnoreCase))
{
returnCode = Execute.gmPL(record); // no special processing during Compile
}
else if(String.Equals("Analyse", scriptTag, StringComparison.OrdinalIgnoreCase))
{
returnCode = Execute.gmPL(record);
if (returnCode == 0)
{
ScanCode(); // CodeStyle Analyser post-processing
}
}
else if(String.Equals("Author", scriptTag, StringComparison.OrdinalIgnoreCase))
{
record = record.Replace("<Author", "<Author Finish='off' ");
returnCode = Execute.gmPL(record); // Partial Authoring
if (returnCode == 0)
{
if (Configuration.TargetCode)
{
Parser.SetReserved(Dialects.xml);
Runtime.EditTarget editor = new Runtime.EditTarget(TargetCode.Edit);
Runtime.TargetCodeScan(editor); // CodeStyle Author post-processing
}
VerticalList.TargetCode(); // CodeStyle Author post-processing
Runtime.FinishTranslation(); // Final Authoring and Publishing
}
}
else
{
returnCode = Script.UndefinedNestedStatement;
}
return returnCode;
} |
...
gmPL_GlobalStubs.dll is a single statement gmPL extension that executes the "GlobalStubs" command. With this library loaded gmBasic is able to execute the GlobalStubs statement using C# code. The extension dll handles loading all of the VBI files for a system then generates the GlobalStubs bundle. This command will typically be placed at the bottom of a gmBasic script that references the external IDFs used by the VBIs. See Incremental Scope Analysis using gmStudio
Code Block |
---|
|
<GlobalStubs>
<Load id="A.vbi" />
<Load id="B.vbi" />
...
</GlobalStubs> |
...