-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial source code generator for attribute
Converted projects to .NET 8.0
- Loading branch information
1 parent
09eb5f1
commit 524be8a
Showing
86 changed files
with
1,220 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,104 @@ | ||
using static go.main_package; | ||
namespace go; | ||
|
||
namespace go | ||
{ | ||
using fmt = fmt_package; | ||
using sort = sort_package; | ||
using static builtin; | ||
|
||
public static partial class main_package { | ||
|
||
public partial struct Person | ||
{ | ||
public @string Name; | ||
public nint Age; | ||
public float ShoeSize; | ||
} | ||
|
||
public partial struct PeopleByShoeSize : ISlice<Person> | ||
{ | ||
} | ||
|
||
public partial struct PeopleByAge : ISlice<Person> | ||
{ | ||
} | ||
|
||
public static nint Len(this PeopleByShoeSize p) | ||
{ | ||
return len(p); | ||
} | ||
|
||
public static void Swap(this PeopleByShoeSize p, nint i, nint j) | ||
{ | ||
(p[i], p[j]) = (p[j], p[i]); | ||
} | ||
|
||
public static bool Less(this PeopleByShoeSize p, nint i, nint j) | ||
{ | ||
return (p[i].ShoeSize < p[j].ShoeSize); | ||
} | ||
|
||
public static nint Len(this PeopleByAge p) | ||
{ | ||
return len(p); | ||
} | ||
|
||
public static void Swap(this PeopleByAge p, nint i, nint j) | ||
{ | ||
(p[i], p[j]) = (p[j], p[i]); | ||
} | ||
|
||
public static bool Less(this PeopleByAge p, nint i, nint j) | ||
{ | ||
return (p[i].Age < p[j].Age); | ||
} | ||
|
||
private static void Main() | ||
{ | ||
var people = new Person[] { | ||
new() { | ||
Name = "Person1"u8, | ||
Age = 26, | ||
ShoeSize = 8, | ||
}, | ||
new() { | ||
Name = "Person2"u8, | ||
Age = 21, | ||
ShoeSize = 4, | ||
}, | ||
new() { | ||
Name = "Person3"u8, | ||
Age = 15, | ||
ShoeSize = 9, | ||
}, | ||
new() { | ||
Name = "Person4"u8, | ||
Age = 45, | ||
ShoeSize = 15, | ||
}, | ||
new() { | ||
Name = "Person5"u8, | ||
Age = 25, | ||
ShoeSize = 8.50F, | ||
}}.slice(); | ||
|
||
fmt.Println(people); | ||
|
||
sort.Sort(new PeopleByShoeSize(people)); | ||
fmt.Println(people); | ||
|
||
sort.Sort(new PeopleByAge(people)); | ||
fmt.Println(people); | ||
} | ||
[type("struct")] | ||
public partial struct Person | ||
{ | ||
public @string Name; | ||
public nint Age; | ||
public float32 ShoeSize; | ||
} | ||
|
||
[type("[]Person")] | ||
public partial struct PeopleByShoeSize : ISlice<Person> | ||
{ | ||
} | ||
|
||
public partial struct PeopleByAge : ISlice<Person> | ||
{ | ||
} | ||
|
||
public static nint Len(this PeopleByShoeSize p) | ||
{ | ||
return len(p); | ||
} | ||
|
||
public static void Swap(this PeopleByShoeSize p, nint i, nint j) | ||
{ | ||
(p[i], p[j]) = (p[j], p[i]); | ||
} | ||
|
||
public static bool Less(this PeopleByShoeSize p, nint i, nint j) | ||
{ | ||
return (p[i].ShoeSize < p[j].ShoeSize); | ||
} | ||
|
||
public static nint Len(this PeopleByAge p) | ||
{ | ||
return len(p); | ||
} | ||
|
||
public static void Swap(this PeopleByAge p, nint i, nint j) | ||
{ | ||
(p[i], p[j]) = (p[j], p[i]); | ||
} | ||
|
||
public static bool Less(this PeopleByAge p, nint i, nint j) | ||
{ | ||
return (p[i].Age < p[j].Age); | ||
} | ||
|
||
private static void Main() | ||
{ | ||
var people = new Person[] { | ||
//new( | ||
// Name: "Person1"u8, | ||
// Age: 26, | ||
// ShoeSize: 8 | ||
//), | ||
//new( | ||
// Name: "Person2"u8, | ||
// Age: 21, | ||
// ShoeSize: 4 | ||
//), | ||
//new( | ||
// Name: "Person3"u8, | ||
// Age: 15, | ||
// ShoeSize: 9 | ||
//), | ||
//new( | ||
// Name: "Person4"u8, | ||
// Age: 45, | ||
// ShoeSize: 15 | ||
//), | ||
//new( | ||
// Name: "Person5"u8, | ||
// Age: 25, | ||
// ShoeSize: 8.50F | ||
//) | ||
}.slice(); | ||
|
||
var test = new Person[] | ||
{ | ||
new() { Name = "Person1"u8, Age = 26, ShoeSize = 8 }, | ||
new() { Name = "Person2"u8, Age = 21, ShoeSize = 4 }, | ||
new() { Name = "Person3"u8, Age = 15, ShoeSize = 9 }, | ||
new() { Name = "Person4"u8, Age = 45, ShoeSize = 15 }, | ||
new() { Name = "Person5"u8, Age = 25, ShoeSize = 8.50F } | ||
}; | ||
|
||
fmt.Println(people); | ||
|
||
sort.Sort(new PeopleByShoeSize(people)); | ||
fmt.Println(people); | ||
|
||
sort.Sort(new PeopleByAge(people)); | ||
fmt.Println(people); | ||
} | ||
|
||
} // end main_package | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.