mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Merge branch 'master' of github.com:twiglet/cs2j
This commit is contained in:
commit
084501fc03
@ -118,8 +118,10 @@
|
|||||||
<Return>System.Void</Return>
|
<Return>System.Void</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports />
|
<Imports>
|
||||||
<Java>${this:16}.reverse()</Java>
|
<Import>java.util.Collections</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>Collections.reverse(${this:16})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
</Params>
|
</Params>
|
||||||
<Name>Reverse</Name>
|
<Name>Reverse</Name>
|
||||||
@ -171,7 +173,7 @@
|
|||||||
</Params>
|
</Params>
|
||||||
<Type>System.Object</Type>
|
<Type>System.Object</Type>
|
||||||
<Get>${this:16}.get(${i})</Get>
|
<Get>${this:16}.get(${i})</Get>
|
||||||
<Set>${this:16}.add(${i}, ${value})</Set>
|
<Set>${this:16}.set(${i}, ${value})</Set>
|
||||||
</Indexer>
|
</Indexer>
|
||||||
</Indexers>
|
</Indexers>
|
||||||
<Constructors>
|
<Constructors>
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
<Java>${expr}</Java>
|
<Java>${expr}</Java>
|
||||||
</Iterable>
|
</Iterable>
|
||||||
<Properties>
|
<Properties>
|
||||||
|
<Property>
|
||||||
|
<Imports />
|
||||||
|
<Java>${this:16}.size()</Java>
|
||||||
|
<Type>System.Int32</Type>
|
||||||
|
<Name>Count</Name>
|
||||||
|
<Get>${this:16}.size()</Get>
|
||||||
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Methods>
|
<Methods>
|
||||||
<Method>
|
<Method>
|
||||||
|
@ -99,5 +99,12 @@
|
|||||||
<Name>Values</Name>
|
<Name>Values</Name>
|
||||||
<Get>${this:16}.values()</Get>
|
<Get>${this:16}.values()</Get>
|
||||||
</Property>
|
</Property>
|
||||||
|
<Property>
|
||||||
|
<Imports />
|
||||||
|
<Java>${this:16}.size()</Java>
|
||||||
|
<Type>System.Int32</Type>
|
||||||
|
<Name>Count</Name>
|
||||||
|
<Get>${this:16}.size()</Get>
|
||||||
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>BBHaGzWIzkVajkMtIotxcu6p5VY=</DigestValue></Reference></SignedInfo><SignatureValue>WOOzmkxA0yBm1tFVetTcQxQc7SztNyQygCPbn5vaHLtHI/MoQMuTuytu5BrGb4UJ7KG68galgfmWUlUD99Txs44X+XdHA7wY0XcAUwXHV+/uti6FicyhHw7mDr9Bj4+Rjq4RIA2I0gS5P25V9nMEIEQCD3/jjc+wc4Lt5AHw/b4=</SignatureValue></Signature></Interface>
|
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" /></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" /><DigestValue>BBHaGzWIzkVajkMtIotxcu6p5VY=</DigestValue></Reference></SignedInfo><SignatureValue>WOOzmkxA0yBm1tFVetTcQxQc7SztNyQygCPbn5vaHLtHI/MoQMuTuytu5BrGb4UJ7KG68galgfmWUlUD99Txs44X+XdHA7wY0XcAUwXHV+/uti6FicyhHw7mDr9Bj4+Rjq4RIA2I0gS5P25V9nMEIEQCD3/jjc+wc4Lt5AHw/b4=</SignatureValue></Signature></Interface>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file is
|
This file is
|
||||||
@ -125,7 +125,7 @@
|
|||||||
<Return>System.Void</Return>
|
<Return>System.Void</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Java>${this:16}.toArray(new ${T}[${this}.size()])</Java>
|
<Java>((${T}[]) ${this:16}.toArray())</Java>
|
||||||
<Params>
|
<Params>
|
||||||
</Params>
|
</Params>
|
||||||
<Name>ToArray</Name>
|
<Name>ToArray</Name>
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
-->
|
-->
|
||||||
<Class xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
<Class xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:www.twigletsoftware.com:schemas:txtemplate:1:0">
|
||||||
<Imports>
|
<Imports>
|
||||||
<Import>javax.mail.internet.InternetAddress</Import>
|
<Import>CS2JNet.System.Net.Mail.MailAddress</Import>
|
||||||
</Imports>
|
</Imports>
|
||||||
<Java>InternetAddress</Java>
|
<Java>MailAddress</Java>
|
||||||
<Name>System.Net.Mail.MailAddress</Name>
|
<Name>System.Net.Mail.MailAddress</Name>
|
||||||
<Uses />
|
<Uses />
|
||||||
<Inherits>
|
<Inherits>
|
||||||
@ -24,9 +24,9 @@
|
|||||||
<Constructors>
|
<Constructors>
|
||||||
<Constructor>
|
<Constructor>
|
||||||
<Imports>
|
<Imports>
|
||||||
<Import>javax.mail.internet.InternetAddress</Import>
|
<Import>CS2JNet.System.Net.Mail.MailAddress</Import>
|
||||||
</Imports>
|
</Imports>
|
||||||
<Java>new InternetAddress(${address})</Java>
|
<Java>new MailAddress(${address})</Java>
|
||||||
<Params>
|
<Params>
|
||||||
<Param>
|
<Param>
|
||||||
<Type>System.String</Type>
|
<Type>System.String</Type>
|
||||||
|
@ -26,6 +26,15 @@
|
|||||||
</Params>
|
</Params>
|
||||||
<Name>Equals</Name>
|
<Name>Equals</Name>
|
||||||
<Return>System.Boolean</Return>
|
<Return>System.Boolean</Return>
|
||||||
|
</Method>
|
||||||
|
<!-- added for Array.clone support, but since in java this is on Object, should be at System.Object level in
|
||||||
|
translation for those .net objects which have Clone().-->
|
||||||
|
<Method>
|
||||||
|
<Imports />
|
||||||
|
<Java>${this:16}.clone(${obj})</Java>
|
||||||
|
<Params />
|
||||||
|
<Name>Clone</Name>
|
||||||
|
<Return>System.Object</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports />
|
<Imports />
|
||||||
@ -60,6 +69,24 @@
|
|||||||
<Name>GetHashCode</Name>
|
<Name>GetHashCode</Name>
|
||||||
<Return>System.Int</Return>
|
<Return>System.Int</Return>
|
||||||
</Method>
|
</Method>
|
||||||
|
<Method>
|
||||||
|
<Imports>
|
||||||
|
<Import>CS2JNet.System.ObjectSupport</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>ObjectSupport.Equals(${obj1}, ${obj2})</Java>
|
||||||
|
<Params>
|
||||||
|
<Param>
|
||||||
|
<Type>System.Object</Type>
|
||||||
|
<Name>obj1</Name>
|
||||||
|
</Param>
|
||||||
|
<Param>
|
||||||
|
<Type>System.Object</Type>
|
||||||
|
<Name>obj2</Name>
|
||||||
|
</Param>
|
||||||
|
</Params>
|
||||||
|
<Name>Equals</Name>
|
||||||
|
<Return>System.Boolean</Return>
|
||||||
|
</Method>
|
||||||
</Methods>
|
</Methods>
|
||||||
<Properties />
|
<Properties />
|
||||||
<Events />
|
<Events />
|
||||||
|
@ -40,10 +40,7 @@
|
|||||||
<Return>System.Int32</Return>
|
<Return>System.Int32</Return>
|
||||||
</Method>
|
</Method>
|
||||||
<Method>
|
<Method>
|
||||||
<Imports>
|
<Java>${this:16}.compareTo(${arg1})</Java>
|
||||||
<Import>CS2JNet.System.StringSupport</Import>
|
|
||||||
</Imports>
|
|
||||||
<Java>StringSupport.Compare(${arg1}, ${this})</Java>
|
|
||||||
<Params>
|
<Params>
|
||||||
<Param>
|
<Param>
|
||||||
<Type>System.String</Type>
|
<Type>System.String</Type>
|
||||||
@ -68,7 +65,7 @@
|
|||||||
<Name>arg2</Name>
|
<Name>arg2</Name>
|
||||||
</Param>
|
</Param>
|
||||||
<Param>
|
<Param>
|
||||||
<Type>System.Bool</Type>
|
<Type>System.Boolean</Type>
|
||||||
<Name>isCaseSensitive</Name>
|
<Name>isCaseSensitive</Name>
|
||||||
</Param>
|
</Param>
|
||||||
</Params>
|
</Params>
|
||||||
|
@ -115,6 +115,17 @@
|
|||||||
<Name>GetTypeCode</Name>
|
<Name>GetTypeCode</Name>
|
||||||
<Return>System.TypeCode</Return>
|
<Return>System.TypeCode</Return>
|
||||||
</Method>
|
</Method>
|
||||||
|
<Method>
|
||||||
|
<Return>System.Boolean</Return>
|
||||||
|
<Name>IsAssignableFrom</Name>
|
||||||
|
<Params>
|
||||||
|
<Param>
|
||||||
|
<Name>arg1</Name>
|
||||||
|
<Type>System.Type</Type>
|
||||||
|
</Param>
|
||||||
|
</Params>
|
||||||
|
<Java>${this:16}.isAssignableFrom(${arg1})</Java>
|
||||||
|
</Method>
|
||||||
</Methods>
|
</Methods>
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property>
|
<Property>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||||
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -33,7 +33,7 @@ import CS2JNet.JavaSupport.util.LocaleSupport;
|
|||||||
public class DateTimeSupport {
|
public class DateTimeSupport {
|
||||||
|
|
||||||
public static String ToString(Date d, String format, Locale loc) {
|
public static String ToString(Date d, String format, Locale loc) {
|
||||||
|
|
||||||
SimpleDateFormat formatter = null;
|
SimpleDateFormat formatter = null;
|
||||||
if (format.equals("s")) {
|
if (format.equals("s")) {
|
||||||
//TODO: Is this really a db-friendly sortable format?
|
//TODO: Is this really a db-friendly sortable format?
|
||||||
@ -43,14 +43,22 @@ public class DateTimeSupport {
|
|||||||
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'", loc);
|
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'", loc);
|
||||||
} else if (format.equals("yyyy-MM-ddTHH:mm:ss.ffZ")) {
|
} else if (format.equals("yyyy-MM-ddTHH:mm:ss.ffZ")) {
|
||||||
formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'", loc);
|
formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'", loc);
|
||||||
} else {
|
} else if (format.equals("yyyy-MM-ddTHH:mm:ss.fffZ")) {
|
||||||
formatter = new SimpleDateFormat(format, loc);
|
formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", loc);
|
||||||
|
} else if (format.equals("ddd',' dd MMM yyyy HH':'mm':'ss'.'fff GMT")) {
|
||||||
|
formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss.SSS 'GMT'");
|
||||||
|
} else {
|
||||||
|
formatter = new SimpleDateFormat(format, loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (formatter.toPattern().contains("'Z'") || formatter.toPattern().contains("'GMT'")){
|
||||||
|
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d instanceof DateTZ) {
|
if (d instanceof DateTZ) {
|
||||||
formatter.setTimeZone(((DateTZ)d).getTimeZone());
|
formatter.setTimeZone(((DateTZ)d).getTimeZone());
|
||||||
}
|
}
|
||||||
|
|
||||||
return formatter.format(d);
|
return formatter.format(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,10 +83,14 @@ public class DateTimeSupport {
|
|||||||
private static final String[] DATE_FORMATS = new String[] {
|
private static final String[] DATE_FORMATS = new String[] {
|
||||||
"E MMM d HH:mm:ss Z yyyy",
|
"E MMM d HH:mm:ss Z yyyy",
|
||||||
"MM/dd/yyyy HH:mm:ss a",
|
"MM/dd/yyyy HH:mm:ss a",
|
||||||
"yyyy-MM-dd HH:mm:ss'Z'",
|
"yyyy-MM-dd'T'HH:mm:ss.SSSZ",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ssZ",
|
||||||
|
"yyyy-MM-dd'T'HH:mm:ss'Z'",
|
||||||
"yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",
|
"yyyy-MM-dd'T'HH:mm:ss'.'SSSZ",
|
||||||
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",
|
||||||
"yyyy-MM-dd'T'HH:mm:ss",
|
"yyyy-MM-dd'T'HH:mm:ss",
|
||||||
|
"yyyy-MM-dd HH:mm:ss'Z'",
|
||||||
"yyyy-MM-dd"};
|
"yyyy-MM-dd"};
|
||||||
|
|
||||||
public static Date parse(String s) throws ParseException
|
public static Date parse(String s) throws ParseException
|
||||||
@ -92,21 +104,21 @@ public class DateTimeSupport {
|
|||||||
return parse(val, DATE_FORMATS, Locale.getDefault(), utc);
|
return parse(val, DATE_FORMATS, Locale.getDefault(), utc);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static String trimMilliSecondsToThreeDigits(String dateString){
|
protected static String trimMilliSecondsToThreeDigits(String dateString){
|
||||||
String val = dateString;
|
String val = dateString;
|
||||||
if(val != null){
|
if(val != null){
|
||||||
int milliStart = val.lastIndexOf(".");
|
int milliStart = val.lastIndexOf(".");
|
||||||
if(milliStart != -1){
|
if(milliStart != -1){
|
||||||
milliStart = milliStart + 1;
|
milliStart = milliStart + 1;
|
||||||
int milliEnd = val.lastIndexOf("Z");
|
int milliEnd = Math.max(val.lastIndexOf("+"), val.lastIndexOf("Z"));
|
||||||
milliEnd = (milliEnd == -1) ? val.length() : milliEnd;
|
milliEnd = (milliEnd == -1) ? val.length() : milliEnd;
|
||||||
if((milliEnd - milliStart) > 3){
|
if((milliEnd - milliStart) > 3){
|
||||||
String newMillis = val.substring(milliStart).substring(0, 3);
|
String newMillis = val.substring(milliStart).substring(0, 3);
|
||||||
val = val.substring(0, milliStart) + newMillis + val.substring(milliEnd, val.length());
|
val = val.substring(0, milliStart) + newMillis + val.substring(milliEnd, val.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Date parse(String s, String f) throws ParseException
|
public static Date parse(String s, String f) throws ParseException
|
||||||
@ -132,7 +144,7 @@ public class DateTimeSupport {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat(f);
|
SimpleDateFormat sdf = new SimpleDateFormat(f);
|
||||||
if(utc){
|
if(utc || f.contains("Z")){
|
||||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
}
|
}
|
||||||
Date d = sdf.parse(s);
|
Date d = sdf.parse(s);
|
||||||
@ -167,7 +179,7 @@ public class DateTimeSupport {
|
|||||||
cal.add(field, amount);
|
cal.add(field, amount);
|
||||||
return cal.getTime();
|
return cal.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean equals(Date d1, Date d2) {
|
public static boolean equals(Date d1, Date d2) {
|
||||||
return d1 == d2 || (d1 != null && d2 != null && d1.getTime() == d2.getTime());
|
return d1 == d2 || (d1 != null && d2 != null && d1.getTime() == d2.getTime());
|
||||||
}
|
}
|
||||||
|
11
CS2JLibrary/src/CS2JNet/System/ObjectSupport.java
Normal file
11
CS2JLibrary/src/CS2JNet/System/ObjectSupport.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package CS2JNet.System;
|
||||||
|
|
||||||
|
public class ObjectSupport {
|
||||||
|
public static boolean Equals(Object obj1, Object obj2) {
|
||||||
|
if (obj1 == null) {
|
||||||
|
return obj2 == null;
|
||||||
|
} else {
|
||||||
|
return obj1.equals(obj2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -239,18 +239,10 @@ default_template() ::= <<
|
|||||||
default:
|
default:
|
||||||
>>
|
>>
|
||||||
|
|
||||||
lock(comments,exp,block, indent) ::= <<
|
synchstat(comments,exp,stat) ::= <<
|
||||||
<comments; separator=""\n"">
|
|
||||||
lock(<exp>)
|
|
||||||
<block(statements = block, indent = indent)>
|
|
||||||
>>
|
|
||||||
|
|
||||||
synchstat(comments,exp,stats) ::= <<
|
|
||||||
<comments; separator=""\n"">
|
<comments; separator=""\n"">
|
||||||
synchronized (<exp>)
|
synchronized (<exp>)
|
||||||
{
|
<block(statements = stat, indent = indent)>
|
||||||
<stats>
|
|
||||||
}
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
yield(comments,exp) ::= <<
|
yield(comments,exp) ::= <<
|
||||||
|
@ -2050,8 +2050,13 @@ checked_statement:
|
|||||||
'checked' block ;
|
'checked' block ;
|
||||||
unchecked_statement:
|
unchecked_statement:
|
||||||
'unchecked' block -> ^(UNCHECKED block);
|
'unchecked' block -> ^(UNCHECKED block);
|
||||||
lock_statement:
|
lock_statement
|
||||||
'lock' '(' expression ')' embedded_statement[/* isStatementListCtxt */ false] ;
|
@init {
|
||||||
|
CommonTree statAsBlock = null;
|
||||||
|
}:
|
||||||
|
l='lock' '(' expression p=')' embedded_statement[/* isStatementListCtxt */ false]
|
||||||
|
{ statAsBlock = dupTree(embeddedStatementToBlock($p.token, $embedded_statement.tree)); }
|
||||||
|
-> ^(SYNCHRONIZED[$l.token, "synchronized"] expression { statAsBlock });
|
||||||
// TODO: Can we avoid surrounding this with braces if not needed?
|
// TODO: Can we avoid surrounding this with braces if not needed?
|
||||||
using_statement[bool isStatementListCtxt]
|
using_statement[bool isStatementListCtxt]
|
||||||
@init {
|
@init {
|
||||||
|
@ -1580,7 +1580,6 @@ embedded_statement returns [bool isSemi, bool isIf, bool indent]
|
|||||||
| checked_statement -> { $checked_statement.st }
|
| checked_statement -> { $checked_statement.st }
|
||||||
| unchecked_statement -> { $unchecked_statement.st }
|
| unchecked_statement -> { $unchecked_statement.st }
|
||||||
| synchronized_statement -> { $synchronized_statement.st }
|
| synchronized_statement -> { $synchronized_statement.st }
|
||||||
| lock_statement -> { $lock_statement.st }
|
|
||||||
| yield_statement -> { $yield_statement.st }
|
| yield_statement -> { $yield_statement.st }
|
||||||
| ^('unsafe' { preComments = CollectedComments; } block { someText = %op(); %{someText}.op="unsafe"; %{someText}.post = $block.st; })
|
| ^('unsafe' { preComments = CollectedComments; } block { someText = %op(); %{someText}.op="unsafe"; %{someText}.post = $block.st; })
|
||||||
-> unsupported(comments = { preComments }, reason = {"unsafe blocks are not supported"}, text = { someText } )
|
-> unsupported(comments = { preComments }, reason = {"unsafe blocks are not supported"}, text = { someText } )
|
||||||
@ -1681,7 +1680,7 @@ finally_clause:
|
|||||||
^('finally' block) -> fin(block = {$block.st}, blockindent = { $block.isSemi });
|
^('finally' block) -> fin(block = {$block.st}, blockindent = { $block.isSemi });
|
||||||
|
|
||||||
synchronized_statement:
|
synchronized_statement:
|
||||||
^(SYNCHRONIZED expression '{' s+=statement* '}') -> synchstat(exp={ $expression.st }, stats = { $s });
|
^(SYNCHRONIZED expression embedded_statement) -> synchstat(exp={ $expression.st }, stat = { $embedded_statement.st }, indent = { $embedded_statement.indent });
|
||||||
|
|
||||||
checked_statement
|
checked_statement
|
||||||
@init {
|
@init {
|
||||||
@ -1703,16 +1702,6 @@ unchecked_statement
|
|||||||
%{someText}.block = $block.st;
|
%{someText}.block = $block.st;
|
||||||
%{someText}.indent = $block.isSemi; } -> unsupported(reason = {"checked statements are not supported"}, text = { someText } )
|
%{someText}.indent = $block.isSemi; } -> unsupported(reason = {"checked statements are not supported"}, text = { someText } )
|
||||||
;
|
;
|
||||||
lock_statement
|
|
||||||
@init {
|
|
||||||
StringTemplate someText = null;
|
|
||||||
}:
|
|
||||||
'lock' '(' expression ')' embedded_statement
|
|
||||||
{ someText = %lock();
|
|
||||||
%{someText}.exp = $expression.st;
|
|
||||||
%{someText}.block = $embedded_statement.st;
|
|
||||||
%{someText}.indent = $embedded_statement.indent; } -> unsupported(reason = {"lock() statements are not supported"}, text = { someText } )
|
|
||||||
;
|
|
||||||
yield_statement
|
yield_statement
|
||||||
@init {
|
@init {
|
||||||
StringTemplate someText = null;
|
StringTemplate someText = null;
|
||||||
|
@ -1132,6 +1132,14 @@ scope MkNonGeneric {
|
|||||||
|
|
||||||
$ForceUnsharedType::fresh = false;
|
$ForceUnsharedType::fresh = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void AddNSToSearchPath(List<string> search, string ns) {
|
||||||
|
int idx = 0;
|
||||||
|
while (ns.IndexOf('.', idx) > 0) {
|
||||||
|
idx = ns.IndexOf('.', idx)+1;
|
||||||
|
search.Add(ns.Substring(0,idx-1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public compilation_unit
|
public compilation_unit
|
||||||
@ -1155,7 +1163,7 @@ scope NSContext, PrimitiveRep, MkNonGeneric, ForceUnsharedType;
|
|||||||
$ForceUnsharedType::fresh = false;
|
$ForceUnsharedType::fresh = false;
|
||||||
|
|
||||||
}:
|
}:
|
||||||
^(pkg=PACKAGE ns=PAYLOAD { $NSContext::currentNS = $ns.text; } dec=type_declaration )
|
^(pkg=PACKAGE ns=PAYLOAD { $NSContext::currentNS = $ns.text; AddNSToSearchPath($NSContext::globalNamespaces, $ns.text);} dec=type_declaration )
|
||||||
-> ^($pkg $ns { mkImports() } $dec);
|
-> ^($pkg $ns { mkImports() } $dec);
|
||||||
|
|
||||||
type_declaration:
|
type_declaration:
|
||||||
@ -3125,8 +3133,7 @@ embedded_statement[bool isStatementListCtxt]
|
|||||||
| ^('try' block catch_clauses? finally_clause?)
|
| ^('try' block catch_clauses? finally_clause?)
|
||||||
| checked_statement
|
| checked_statement
|
||||||
| unchecked_statement
|
| unchecked_statement
|
||||||
| synchronized_statement // Java: synchronized(obj) {}
|
| synchronized_statement
|
||||||
| lock_statement
|
|
||||||
| yield_statement
|
| yield_statement
|
||||||
| ^('unsafe' block)
|
| ^('unsafe' block)
|
||||||
| fixed_statement
|
| fixed_statement
|
||||||
@ -3426,10 +3433,7 @@ unchecked_statement:
|
|||||||
^(UNCHECKED block) ;
|
^(UNCHECKED block) ;
|
||||||
|
|
||||||
synchronized_statement:
|
synchronized_statement:
|
||||||
^(SYNCHRONIZED expression[ObjectType] '{' statement_list '}') ;
|
^(SYNCHRONIZED expression[ObjectType] embedded_statement[/* isStatementListCtxt */ false]) ;
|
||||||
|
|
||||||
lock_statement:
|
|
||||||
'lock' '(' expression[ObjectType] ')' embedded_statement[/* isStatementListCtxt */ false] ;
|
|
||||||
|
|
||||||
yield_statement:
|
yield_statement:
|
||||||
^(YIELD_RETURN expression[ObjectType])
|
^(YIELD_RETURN expression[ObjectType])
|
||||||
|
22
CSharpTranslator/tests/Tester/Misc/Namespaces/child.cs
Executable file
22
CSharpTranslator/tests/Tester/Misc/Namespaces/child.cs
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Parent.Child
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ChildClass
|
||||||
|
{
|
||||||
|
|
||||||
|
private ParentClass myp = null;
|
||||||
|
|
||||||
|
|
||||||
|
public ChildClass(int val)
|
||||||
|
{
|
||||||
|
myp = new ParentClass(val);
|
||||||
|
int tmp = myp.GetHashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
CSharpTranslator/tests/Tester/Misc/Namespaces/parent.cs
Executable file
41
CSharpTranslator/tests/Tester/Misc/Namespaces/parent.cs
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Parent
|
||||||
|
{
|
||||||
|
|
||||||
|
public class ParentClass {
|
||||||
|
|
||||||
|
private int loc = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public ParentClass(int val)
|
||||||
|
{
|
||||||
|
loc = val;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetLoc()
|
||||||
|
{
|
||||||
|
return loc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode(){
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ChildOne {
|
||||||
|
public int COloc = 0;
|
||||||
|
private class ChildChildOne
|
||||||
|
{
|
||||||
|
public ChildChildOne() { }
|
||||||
|
|
||||||
|
public ChildOne p = new ChildOne();
|
||||||
|
public ParentClass gp = new ParentClass(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
31
CSharpTranslator/tests/Tester/Misc/locker.cs
Executable file
31
CSharpTranslator/tests/Tester/Misc/locker.cs
Executable file
@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
// Test translation for lock statements
|
||||||
|
|
||||||
|
namespace Tester.Locker
|
||||||
|
{
|
||||||
|
class B {
|
||||||
|
public virtual void foo() {
|
||||||
|
lock(this)
|
||||||
|
Console.WriteLine("summat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class D : B {
|
||||||
|
public new void foo() {
|
||||||
|
lock (new String[5])
|
||||||
|
{
|
||||||
|
Console.WriteLine("and");
|
||||||
|
Console.WriteLine("nuttin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Test5 {
|
||||||
|
public static void T5Main(){
|
||||||
|
B b = new D();
|
||||||
|
b.foo();
|
||||||
|
Console.WriteLine("Done");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
@ -45,6 +45,9 @@
|
|||||||
<Compile Include="Enums\PacketTester.cs" />
|
<Compile Include="Enums\PacketTester.cs" />
|
||||||
<Compile Include="Enums\Consts.cs" />
|
<Compile Include="Enums\Consts.cs" />
|
||||||
<Compile Include="Generics\Generics.cs" />
|
<Compile Include="Generics\Generics.cs" />
|
||||||
|
<Compile Include="Misc\locker.cs" />
|
||||||
|
<Compile Include="Misc\Namespaces\child.cs" />
|
||||||
|
<Compile Include="Misc\Namespaces\parent.cs" />
|
||||||
<Compile Include="Partial\PartialUserTwo.cs" />
|
<Compile Include="Partial\PartialUserTwo.cs" />
|
||||||
<Compile Include="Partial\PartialInner.cs" />
|
<Compile Include="Partial\PartialInner.cs" />
|
||||||
<Compile Include="Partial\PartialOuterPartialInner.cs" />
|
<Compile Include="Partial\PartialOuterPartialInner.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user