Skip to content

Commit

Permalink
[Docs] Update /noclipcall to also generate add the ClipperCallingConv…
Browse files Browse the repository at this point in the history
…ention attribute
  • Loading branch information
RobertvanderHulst committed Jun 1, 2022
1 parent a3853a5 commit 712b5c2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions XSharp/docs/XSHelp.hmxp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<task-config-group name="settings">
<task-config-value name="outputfile">..\artifacts\Help\XSharp.chm</task-config-value>
<task-config-value name="skin">XSharp.hmskin</task-config-value>
<task-config-value name="deletetemp">1</task-config-value>
<task-config-value name="deletetemp">0</task-config-value>
<task-config-value name="make0include">CHM</task-config-value>
<task-config-value name="make0status">*</task-config-value>
</task-config-group>
Expand Down Expand Up @@ -673,7 +673,7 @@
<config-value name="htmlpopup">3</config-value>
<config-value name="skin">XSharp.hmskin</config-value>
<config-value name="outputfile">..\artifacts\Help\XSharp.chm</config-value>
<config-value name="deletetemp">1</config-value>
<config-value name="deletetemp">0</config-value>
<config-value name="usesecondarywindows">0</config-value>
</config-group>
<config-group name="mshc">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ public override void ExitXbasedecl([NotNull] XP.XbasedeclContext context)
{
exp = GenerateMemVarPut(context, varname, initializer);

var stmt = GenerateExpressionStatement(exp,memvar);
var stmt = GenerateExpressionStatement(exp, memvar);
memvar.Put(stmt);
stmts.Add(stmt);

Expand Down Expand Up @@ -1506,7 +1506,7 @@ public override ConstructorDeclarationSyntax GenerateDefaultCtor(SyntaxToken id,
ArgumentListSyntax args = MakeArgumentList(arg);

// add using statements
if (elements != null )
if (elements != null)
{
foreach (var element in elements)
{
Expand Down Expand Up @@ -2186,7 +2186,7 @@ public override void ExitSeqStmt([NotNull] XP.SeqStmtContext context)
stmts.Add(innerTry);
tryBlock = MakeBlock(stmts);
stmts.Clear();
CatchClauseSyntax catchClause ;
CatchClauseSyntax catchClause;
FinallyClauseSyntax finallyClause = null;
if (context.RecoverBlock != null)
{
Expand Down Expand Up @@ -2227,7 +2227,7 @@ public CatchClauseSyntax generateRecoverBlock(XSharpParserRuleContext context, B
var condition1 = _syntaxFactory.BinaryExpression(SyntaxKind.IsExpression, objName,
SyntaxFactory.MakeToken(SyntaxKind.IsKeyword), GenerateQualifiedName(_wrappedExceptionType));

var unwrapException = MakeSimpleMemberAccess( MakeCastTo(GenerateQualifiedName(_wrappedExceptionType), objName),
var unwrapException = MakeSimpleMemberAccess(MakeCastTo(GenerateQualifiedName(_wrappedExceptionType), objName),
GenerateSimpleName("Value"));

var callRtError = GenerateMethodCall(ReservedNames.SequenceError, MakeArgumentList(MakeArgument(objName)), true);
Expand Down Expand Up @@ -3411,7 +3411,6 @@ private void implementNoClipCall(XP.IMemberContext context, ref ParameterListSyn
var defExpr = _syntaxFactory.EqualsValueClause(
SyntaxFactory.MakeToken(SyntaxKind.EqualsToken),
MakeDefault(_usualType));

var @params = new List<ParameterSyntax>();
for (int i = 0; i < parameters.Parameters.Count; i++)
{
Expand Down Expand Up @@ -3461,6 +3460,28 @@ protected override void ImplementClipperAndPSZ(XP.IMemberWithBodyContext context
body = MakeBlock(stmts);
context.Data.UsesPSZ = false;
}
if (context.Data.HasClipperCallingConvention)
{
// Create the ClipperCallingConventionAttribute for the method/function
// using the names from the paramNames list
// [ClipperCallingConvention(new string[] { "a", "b" })]
// make sure that existing attributes are not removed!
var names = new List<ExpressionSyntax>();
if (parameters.Parameters.Count > 0)
{
for (int i = 0; i < parameters.Parameters.Count; i++)
{
var parm = parameters.Parameters[i];
names.Add(GenerateLiteral(parm.Identifier.Text));
}
}
var attrs = _pool.Allocate<AttributeListSyntax>();
attrs.AddRange(attributes); // Copy existing attributes
attrs.Add(MakeClipperCallingConventionAttribute(names));
attributes = attrs.ToList();
_pool.Free(attrs);
}

if (context.Data.HasClipperCallingConvention || context.Data.UsesPSZ || context.Data.HasMemVars || _options.HasOption(CompilerOption.UndeclaredMemVars, prc, PragmaOptions))
{
var stmts = _pool.Allocate<StatementSyntax>();
Expand All @@ -3470,18 +3491,11 @@ protected override void ImplementClipperAndPSZ(XP.IMemberWithBodyContext context
implementNoClipCall(context, ref parameters, ref dataType);
context.Data.HasClipperCallingConvention = false;
}

if (context.Data.HasClipperCallingConvention && !_options.NoClipCall)
{

// Assuming the parameters are called oPar1 and oPar2 then the following code is generated
// LOCAL oPar1 := iif(Xs$Args:Length > 0, Xs$Args[0], NIL) as USUAL
// LOCAL oPar2 := iif(Xs$Args:Length > 1, Xs$Args[1], NIL) as USUAL
// Create the ClipperCallingConventionAttribute for the method/function
// using the names from the paramNames list
// [ClipperCallingConvention(new string[] { "a", "b" })]
// make sure that existing attributes are not removed!

if (context.Data.HasParametersStmt || context.Data.HasLParametersStmt)
{
foreach (var field in context.Data.Fields.Values)
Expand All @@ -3501,18 +3515,6 @@ protected override void ImplementClipperAndPSZ(XP.IMemberWithBodyContext context
parameternames.Add(name);
}
}
// we create clipper calling convention attributes for methods
// we declared parameters, a parameters statement or a lparameters statement
var attrs = _pool.Allocate<AttributeListSyntax>();
attrs.AddRange(attributes); // Copy existing attributes
var names = new List<ExpressionSyntax>();
foreach (var name in parameternames)
{
names.Add(GenerateLiteral(name));
}
attrs.Add(MakeClipperCallingConventionAttribute(names));
attributes = attrs;
_pool.Free(attrs);

// create PCount variable
var clipperArgs = GenerateSimpleName(XSharpSpecialNames.ClipperArgs);
Expand Down Expand Up @@ -3591,7 +3593,7 @@ protected override void ImplementClipperAndPSZ(XP.IMemberWithBodyContext context
stmts.Add(decl);
var arg = MakeArgument(GenerateSimpleName(XSharpSpecialNames.PrivatesLevel));
expr = GenerateMethodCall(XSharpQualifiedFunctionNames.MemVarRelease, MakeArgumentList(arg), true);
finallystmts.Add(GenerateExpressionStatement(expr, (XSharpParserRuleContext) context, true));
finallystmts.Add(GenerateExpressionStatement(expr, (XSharpParserRuleContext)context, true));
context.Data.HasMemVarLevel = true;
}
if (finallystmts.Count > 0)
Expand Down
4 changes: 2 additions & 2 deletions XSharp/src/Compiler/xsc/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"profiles": {
"xsc": {
"commandName": "Project",
"commandLineArgs": "@app.rsp",
"workingDirectory": "c:\\XSharp\\Dev\\tests",
"commandLineArgs": "@LastXSharpResponseFile.Rsp /parallel-",
"workingDirectory": "c:\\XSharp\\DevRt\\Runtime\\VOSDK\\Source\\VOSDK\\GUI_Classes_SDK",
"nativeDebugging": false
}
}
Expand Down

0 comments on commit 712b5c2

Please sign in to comment.