[svn] r6670: nemerle/trunk: lib/narray.n macros/Util.n
VladD2
svnadmin at nemerle.org
Thu Sep 21 03:04:48 CEST 2006
Log:
Some changes in library.
Author: VladD2
Date: Thu Sep 21 03:04:46 2006
New Revision: 6670
Modified:
nemerle/trunk/lib/narray.n
nemerle/trunk/macros/Util.n
Modified: nemerle/trunk/lib/narray.n
==============================================================================
--- nemerle/trunk/lib/narray.n (original)
+++ nemerle/trunk/lib/narray.n Thu Sep 21 03:04:46 2006
@@ -99,15 +99,20 @@
*/
public MapToArray[From, To] (this source : SCG.ICollection[From], f : From -> To) : array [To]
{
- if (source == null)
- array (0)
- else
+ match (source)
+ {
+ | null => array (0);
+ | ary is array[From] => ary.Map (f);
+ | _ => MapCollectionToArray (source, f);
+ }
+ }
+
+ private MapCollectionToArray[From, To] (source : SCG.ICollection[From], f : From -> To) : array [To]
{
def tmp = array (source.Count);
source.CopyTo (tmp, 0);
tmp.Map (f)
}
- }
/**
* Convert collection of one type to array of another type. (Alias for MapToArray)
@@ -124,8 +129,9 @@
{
match (source)
{
- | coll is SCG.ICollection[From] => coll.MapToArray (f);
| null => array (0);
+ | ary is array[From] => ary.Map (f);
+ | coll is SCG.ICollection[From] => MapCollectionToArray (coll, f);
| _ =>
def dest = SCG.List();
@@ -257,6 +263,10 @@
public Map [From, To] (this from : array [From], f : From -> To) : array [To]
{
+ if (from == null)
+ array(0)
+ else
+ {
def result = array (from.Length);
for (mutable i = 0; i < from.Length; ++i)
@@ -264,6 +274,7 @@
result
}
+ }
/**
* Convert array of one type to other. (This is a alias for Map().)
Modified: nemerle/trunk/macros/Util.n
==============================================================================
--- nemerle/trunk/macros/Util.n (original)
+++ nemerle/trunk/macros/Util.n Thu Sep 21 03:04:46 2006
@@ -49,6 +49,12 @@
namespace Nemerle.Utility
{
+ /// Adds property accessor for field.
+ /// By default adds only getter.
+ /// You can specify the following flags:
+ /// WantSetter, Setter, Internal, Protected, Override, Virtual.
+ /// Also you can specify the property name manualy (by default the name
+ /// is generated from the field name).
[Nemerle.MacroUsage (Nemerle.MacroPhase.BeforeInheritance,
Nemerle.MacroTargets.Field,
Inherited = false, AllowMultiple = true)]
@@ -103,6 +109,7 @@
| <[ $e1 | $e2 ]> =>
parse_opts (e1);
parse_opts (e2);
+
| e =>
Message.FatalError ($ "bad accessor option, $e");
}
More information about the svn
mailing list