mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
add some undercooked collection support. needs more work.
This commit is contained in:
parent
6a40909662
commit
aa8cf2f8c0
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--
|
<!--
|
||||||
|
|
||||||
This file is
|
This file is
|
||||||
@ -8,9 +8,9 @@
|
|||||||
-->
|
-->
|
||||||
<Interface 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">
|
<Interface 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>java.util.Collection</Import>
|
<Import>CS2JNet.System.Collections.Generic.ICollectionSupport</Import>
|
||||||
</Imports>
|
</Imports>
|
||||||
<Java>Collection*[${T}]*</Java>
|
<Java>ICollectionSupport*[${T}]*</Java>
|
||||||
<Name>System.Collections.Generic.ICollection</Name>
|
<Name>System.Collections.Generic.ICollection</Name>
|
||||||
<TypeParams>
|
<TypeParams>
|
||||||
<Name>T</Name>
|
<Name>T</Name>
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
This file is
|
||||||
|
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
-->
|
||||||
|
<Interface 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>
|
||||||
|
<Import>java.lang.Iterable</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>Iterable*[${E}]*</Java>
|
||||||
|
<Name>System.Collections.Generic.IEnumerable</Name>
|
||||||
|
<TypeParams>
|
||||||
|
<Name>E</Name>
|
||||||
|
</TypeParams>
|
||||||
|
<Iterable>
|
||||||
|
<ElementType>E</ElementType>
|
||||||
|
<Java>${expr}</Java>
|
||||||
|
</Iterable>
|
||||||
|
<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>jEYi0rdl/kMLr7uBNG0M9LMlbCQ=</DigestValue></Reference></SignedInfo><SignatureValue>C/hbBQnMGlWnPvwE61XrMusMlyKT+K792pEYR7D7CnpO7Td1gFgCCfkSdFVZ1axk+sLzebWIQKH8+NFRC6+hlNpViODt46v/300e+fi2Yx8BWhpq5e51zfNAhHIdaUemMqHMHNG5BMOngpFx1yrO/zxHvj7HPJqGBwJV7w8yPtU=</SignatureValue></Signature></Interface>
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
This file is
|
||||||
|
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
-->
|
||||||
|
<Interface 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>
|
||||||
|
<Import>CS2JNet.System.Collections.Generic.IEnumeratorSupport</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>IEnumeratorSupport*[${E}]*</Java>
|
||||||
|
<Name>System.Collections.Generic.IEnumerator</Name>
|
||||||
|
<TypeParams>
|
||||||
|
<Name>E</Name>
|
||||||
|
</TypeParams>
|
||||||
|
<Iterable>
|
||||||
|
<ElementType>E</ElementType>
|
||||||
|
<Java>${expr}</Java>
|
||||||
|
</Iterable>
|
||||||
|
<Properties>
|
||||||
|
<Type>E</Type>
|
||||||
|
<Name>Current></Name>
|
||||||
|
<Get>${this:16}.getcurrent()</Get>
|
||||||
|
</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>jEYi0rdl/kMLr7uBNG0M9LMlbCQ=</DigestValue></Reference></SignedInfo><SignatureValue>C/hbBQnMGlWnPvwE61XrMusMlyKT+K792pEYR7D7CnpO7Td1gFgCCfkSdFVZ1axk+sLzebWIQKH8+NFRC6+hlNpViODt46v/300e+fi2Yx8BWhpq5e51zfNAhHIdaUemMqHMHNG5BMOngpFx1yrO/zxHvj7HPJqGBwJV7w8yPtU=</SignatureValue></Signature></Interface>
|
@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
|
||||||
|
This file is
|
||||||
|
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
-->
|
||||||
|
<Interface 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>
|
||||||
|
<Import>java.util.LinkedList</Import>
|
||||||
|
</Imports>
|
||||||
|
<Java>LinkedList*[${E}]*</Java>
|
||||||
|
<Name>System.Collections.Generic.Queue</Name>
|
||||||
|
<TypeParams>
|
||||||
|
<Name>E</Name>
|
||||||
|
</TypeParams>
|
||||||
|
<Inherits/>
|
||||||
|
<Constructors>
|
||||||
|
<Constructor>
|
||||||
|
<Params />
|
||||||
|
<Java>new LinkedList*[${E}]*()</Java>
|
||||||
|
</Constructor>
|
||||||
|
</Constructors>
|
||||||
|
<Methods>
|
||||||
|
<Method>
|
||||||
|
<Params>
|
||||||
|
<Param>
|
||||||
|
<Type>E</Type>
|
||||||
|
<Name>item</Name>
|
||||||
|
</Param>
|
||||||
|
</Params>
|
||||||
|
<Name>Enqueue</Name>
|
||||||
|
<Returns>System.Void</Returns>
|
||||||
|
<Java>${this:16}.add(${item})</Java>
|
||||||
|
</Method>
|
||||||
|
<Method>
|
||||||
|
<Params>
|
||||||
|
</Params>
|
||||||
|
<Name>Dequeue</Name>
|
||||||
|
<Returns>E</Returns>
|
||||||
|
<Java>${this:16}.removeLast(${item})</Java>
|
||||||
|
</Method>
|
||||||
|
</Methods>
|
||||||
|
<Properties>
|
||||||
|
<Property>
|
||||||
|
<Type>System.Int</Type>
|
||||||
|
<Name>Count</Name>
|
||||||
|
<Get>${this}.size()</Get>
|
||||||
|
</Property>
|
||||||
|
</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>jEYi0rdl/kMLr7uBNG0M9LMlbCQ=</DigestValue></Reference></SignedInfo><SignatureValue>C/hbBQnMGlWnPvwE61XrMusMlyKT+K792pEYR7D7CnpO7Td1gFgCCfkSdFVZ1axk+sLzebWIQKH8+NFRC6+hlNpViODt46v/300e+fi2Yx8BWhpq5e51zfNAhHIdaUemMqHMHNG5BMOngpFx1yrO/zxHvj7HPJqGBwJV7w8yPtU=</SignatureValue></Signature></Interface>
|
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2007,2008,2009,2010 Rustici Software, LLC
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Author(s):
|
||||||
|
|
||||||
|
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
*/
|
||||||
|
package CS2JNet.JavaSupport.Collections.Generic;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import CS2JNet.JavaSupport.CS2JRunTimeException;
|
||||||
|
import CS2JNet.System.Collections.Generic.IEnumeratorSupport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A concrete implementation of .Net's Enumerator that wraps an Iterator
|
||||||
|
*
|
||||||
|
* @author keving
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public class EnumeratorSupport<T> implements IEnumeratorSupport<T> {
|
||||||
|
|
||||||
|
private Iterator<T> myIterator = null;
|
||||||
|
private T myCurrent = null;
|
||||||
|
|
||||||
|
public EnumeratorSupport(Iterator<T> it) {
|
||||||
|
myIterator = it;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getCurrent() throws Exception {
|
||||||
|
return myCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean MoveNext() throws Exception {
|
||||||
|
boolean hasNext = myIterator.hasNext();
|
||||||
|
if (hasNext) {
|
||||||
|
myCurrent = myIterator.next();
|
||||||
|
}
|
||||||
|
return hasNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Reset() throws Exception {
|
||||||
|
throw new CS2JRunTimeException("CS2J: IEnumerator does not yet support Reset() operation");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterator<T> iterator() {
|
||||||
|
return myIterator;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -35,7 +35,7 @@ public class EventCollection<T> implements IEventCollection<T> {
|
|||||||
public void Invoke(Object cause, EventArgs e) throws CS2JRunTimeException {
|
public void Invoke(Object cause, EventArgs e) throws CS2JRunTimeException {
|
||||||
if (listeners != null) {
|
if (listeners != null) {
|
||||||
// do something here
|
// do something here
|
||||||
throw new CS2JRunTimeException("Events are not yet implemented");
|
throw new CS2JRunTimeException("CS2J: Events are not yet implemented");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Author(s):
|
||||||
|
|
||||||
|
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package CS2JNet.System.Collections.Generic;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevin.glynn@twigletsoftware.com
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ICollectionSupport<T> extends Iterable<T> {
|
||||||
|
|
||||||
|
|
||||||
|
public boolean Contains(T x) throws Exception;
|
||||||
|
|
||||||
|
public void Add(T x) throws Exception;
|
||||||
|
|
||||||
|
public boolean Remove(T x) throws Exception;
|
||||||
|
|
||||||
|
public void Clear() throws Exception;
|
||||||
|
|
||||||
|
public IEnumeratorSupport<T> GetEnumerator() throws Exception;
|
||||||
|
|
||||||
|
public void CopyTo(T[] arr, int i) throws Exception;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2010,2011 Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
Author(s):
|
||||||
|
|
||||||
|
Kevin Glynn (kevin.glynn@twigletsoftware.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
package CS2JNet.System.Collections.Generic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mimics Net's IEnumerator interface
|
||||||
|
*
|
||||||
|
* @author keving
|
||||||
|
*
|
||||||
|
* @param <T>
|
||||||
|
*/
|
||||||
|
public interface IEnumeratorSupport<T> extends Iterable<T>{
|
||||||
|
|
||||||
|
T getCurrent() throws Exception;
|
||||||
|
|
||||||
|
boolean MoveNext() throws Exception;
|
||||||
|
|
||||||
|
void Reset() throws Exception;
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user