Skip to content

Commit 0be9a42

Browse files
Version 4.1
1 parent 22a5d23 commit 0be9a42

File tree

153 files changed

+7545
-135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

153 files changed

+7545
-135
lines changed

JuliadotNET.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JuliadotNET", "JuliadotNET\
44
EndProject
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Sandbox\Sandbox.csproj", "{D2E7F1D3-BAC1-453D-A88C-06250415B832}"
66
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JuliadotNETTest", "JuliadotNETTest\JuliadotNETTest.csproj", "{9B099638-725B-441B-91EC-85BFE93A2ECD}"
8+
EndProject
79
Global
810
GlobalSection(SolutionConfigurationPlatforms) = preSolution
911
Debug|Any CPU = Debug|Any CPU
@@ -18,5 +20,9 @@ Global
1820
{D2E7F1D3-BAC1-453D-A88C-06250415B832}.Debug|Any CPU.Build.0 = Debug|Any CPU
1921
{D2E7F1D3-BAC1-453D-A88C-06250415B832}.Release|Any CPU.ActiveCfg = Release|Any CPU
2022
{D2E7F1D3-BAC1-453D-A88C-06250415B832}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{9B099638-725B-441B-91EC-85BFE93A2ECD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{9B099638-725B-441B-91EC-85BFE93A2ECD}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{9B099638-725B-441B-91EC-85BFE93A2ECD}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{9B099638-725B-441B-91EC-85BFE93A2ECD}.Release|Any CPU.Build.0 = Release|Any CPU
2127
EndGlobalSection
2228
EndGlobal

JuliadotNET.sln.DotSettings.user

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/Environment/AssemblyExplorer/XmlDocument/@EntryValue">&lt;AssemblyExplorer&gt;&#xD;
33
&lt;Assembly Path="C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\System.Runtime.dll" /&gt;&#xD;
4-
&lt;/AssemblyExplorer&gt;</s:String></wpf:ResourceDictionary>
4+
&lt;/AssemblyExplorer&gt;</s:String>
5+
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=d7e47783_002D591f_002D4951_002D853a_002Dd4d47f18c9de/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from &amp;lt;JuliadotNETTest&amp;gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
6+
&lt;Project Location="C:\Users\JohnB\Desktop\HyperProjects\HExcel\JULIAdotNET\JuliadotNETTest" Presentation="&amp;lt;JuliadotNETTest&amp;gt;" /&gt;&#xD;
7+
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>
6 KB
Binary file not shown.
2.82 KB
Binary file not shown.

JuliadotNET/generated/csharp/Core/JPrimitive.gen.cs

Lines changed: 79 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
namespace JULIAdotNET{
66
public static partial class JPrimitive {
7-
public static Any BaseM, CoreM, MainM;
8-
public static JType ModuleT, TypeT, FunctionT, MethodT, UnionT;
9-
public static Any sprintF, showerrorF, catch_backtraceF, stringF, getpropertyF, setpropertyNotF, namesF, makearrayF, writeSharpArrayF, maketupleF, ievalF, getindexF, setindexNotF, lengthF, iterateF, EqualityF, InequalityF, GreaterThanF, LessThanF, GreaterThanOrEqualF, LessThanOrEqualF, NotF, OnesComplementF, ExclusiveOrF, BitwiseAndF, BitwiseOrF, ModulusF, MultiplyF, AdditionF, SubtractionF, DivisionF, RightShiftF, LeftShiftF, typeofF, hashF, ismutableF, isabstracttypeF, isimmutableF, isprimitivetypeF, sizeofF, parentmoduleF, nameofF, fieldcountF, fieldnameF, fieldoffsetF, fieldtypeF;
7+
public static JModule BaseM, CoreM, MainM;
8+
public static JType ModuleT, TypeT, FunctionT, MethodT, UnionT, IntegerT, AbstractFloatT, StringT, PtrT;
9+
public static JType BoolT, CharT, Float64T, Float32T, Float16T, Int64T, Int32T, Int16T, Int8T, UInt64T, UInt32T, UInt16T, UInt8T, ArrayT;
10+
public static Any sprintF, showerrorF, catch_backtraceF, stringF, getpropertyF, setpropertyNotF, namesF, makentupleF, writeSharpArrayF, maketupleF, ievalF, getindexF, setindexNotF, lengthF, iterateF, EqualityF, InequalityF, GreaterThanF, LessThanF, GreaterThanOrEqualF, LessThanOrEqualF, NotF, OnesComplementF, ExclusiveOrF, BitwiseAndF, BitwiseOrF, ModulusF, MultiplyF, AdditionF, SubtractionF, DivisionF, RightShiftF, LeftShiftF, typeofF, hashF, ismutableF, isabstracttypeF, isimmutableF, isprimitivetypeF, sizeofF, parentmoduleF, nameofF, fieldcountF, fieldnameF, fieldoffsetF, fieldtypeF;
1011

1112
internal static unsafe void primitive_init() {
1213

1314
Julia.Eval(@"module SharpModule begin
14-
export makearray, maketuple, writeSharpArray, maketuple, ieval
15+
export makearray, maketuple, writeSharpArray, maketuple, ieval, union_types, makentuple
1516
function method_argnames(m::Method)
1617
argnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), m.slot_syms)
1718
isempty(argnames) && return argnames
@@ -20,13 +21,15 @@ function method_argnames(m::Method)
2021
ieval(mod::Module, ex) = begin
2122
Core.eval(mod, Meta.parse(ex))
2223
end
23-
makearray(T::Type, dims::Ptr{Cvoid}, len::Int32) = begin
24-
ptr = convert(Ptr{Int32}, dims)
25-
Array{T}(undef, [unsafe_load(ptr, i) for i = 1:len]...)
26-
end
2724
maketuple(vals...) = begin
2825
tuple(vals...)
2926
end
27+
(makentuple(::Type{T}, n, p::Ptr{Cvoid}) where T) = begin
28+
p2 = convert(Ptr{T}, p)
29+
return ntuple((i->begin
30+
unsafe_load(p2, i)
31+
end), n)
32+
end
3033
linedEvaluation(s::String, file::String, m::Module) = begin
3134
Core.eval(m, Meta.parseall(s, filename = file))
3235
end
@@ -37,12 +40,11 @@ function writeSharpArray(p, arr)
3740
end
3841
end
3942
end end; using .SharpModule");
40-
43+
4144
var writeSharpArray = Julia.Eval("writeSharpArray");
42-
fixed (Any* values = new Any[54]) {
43-
var syms = Julia.Eval("[Base,Core,Main,sprint,showerror,catch_backtrace,string,getproperty,setproperty!,names,makearray,writeSharpArray,maketuple,ieval,getindex,setindex!,length,iterate,Module,Type,Function,Method,Union,==,!=,>,<,>=,<=,!,~,^,&,|,rem,*,+,-,/,>>,<<,typeof,hash,ismutable,isabstracttype,isimmutable,isprimitivetype,sizeof,parentmodule,nameof,fieldcount,fieldname,fieldoffset,fieldtype]");
45+
fixed (Any* values = new Any[72]) {
46+
var syms = Julia.Eval("[Base,Core,Main,sprint,showerror,catch_backtrace,string,getproperty,setproperty!,names,makentuple,writeSharpArray,maketuple,ieval,getindex,setindex!,length,iterate,Module,Type,Function,Method,Union,Integer,AbstractFloat,String,Ptr,==,!=,>,<,>=,<=,!,~,^,&,|,rem,*,+,-,/,>>,<<,typeof,hash,ismutable,isabstracttype,isimmutable,isprimitivetype,sizeof,parentmodule,nameof,fieldcount,fieldname,fieldoffset,fieldtype,Bool,Char,Float64,Float32,Float16,Int64,Int32,Int16,Int8,UInt64,UInt32,UInt16,UInt8,Array]");
4447
writeSharpArray.Invoke(new Any(values), syms);
45-
4648
BaseM = values[0];
4749
CoreM = values[1];
4850
MainM = values[2];
@@ -51,52 +53,85 @@ function writeSharpArray(p, arr)
5153
FunctionT = values[20];
5254
MethodT = values[21];
5355
UnionT = values[22];
56+
IntegerT = values[23];
57+
AbstractFloatT = values[24];
58+
StringT = values[25];
59+
PtrT = values[26];
5460
sprintF = values[3];
5561
showerrorF = values[4];
5662
catch_backtraceF = values[5];
5763
stringF = values[6];
5864
getpropertyF = values[7];
5965
setpropertyNotF = values[8];
6066
namesF = values[9];
61-
makearrayF = values[10];
67+
makentupleF = values[10];
6268
writeSharpArrayF = values[11];
6369
maketupleF = values[12];
6470
ievalF = values[13];
6571
getindexF = values[14];
6672
setindexNotF = values[15];
6773
lengthF = values[16];
6874
iterateF = values[17];
69-
EqualityF = values[23];
70-
InequalityF = values[24];
71-
GreaterThanF = values[25];
72-
LessThanF = values[26];
73-
GreaterThanOrEqualF = values[27];
74-
LessThanOrEqualF = values[28];
75-
NotF = values[29];
76-
OnesComplementF = values[30];
77-
ExclusiveOrF = values[31];
78-
BitwiseAndF = values[32];
79-
BitwiseOrF = values[33];
80-
ModulusF = values[34];
81-
MultiplyF = values[35];
82-
AdditionF = values[36];
83-
SubtractionF = values[37];
84-
DivisionF = values[38];
85-
RightShiftF = values[39];
86-
LeftShiftF = values[40];
87-
typeofF = values[41];
88-
hashF = values[42];
89-
ismutableF = values[43];
90-
isabstracttypeF = values[44];
91-
isimmutableF = values[45];
92-
isprimitivetypeF = values[46];
93-
sizeofF = values[47];
94-
parentmoduleF = values[48];
95-
nameofF = values[49];
96-
fieldcountF = values[50];
97-
fieldnameF = values[51];
98-
fieldoffsetF = values[52];
99-
fieldtypeF = values[53];
75+
EqualityF = values[27];
76+
InequalityF = values[28];
77+
GreaterThanF = values[29];
78+
LessThanF = values[30];
79+
GreaterThanOrEqualF = values[31];
80+
LessThanOrEqualF = values[32];
81+
NotF = values[33];
82+
OnesComplementF = values[34];
83+
ExclusiveOrF = values[35];
84+
BitwiseAndF = values[36];
85+
BitwiseOrF = values[37];
86+
ModulusF = values[38];
87+
MultiplyF = values[39];
88+
AdditionF = values[40];
89+
SubtractionF = values[41];
90+
DivisionF = values[42];
91+
RightShiftF = values[43];
92+
LeftShiftF = values[44];
93+
typeofF = values[45];
94+
hashF = values[46];
95+
ismutableF = values[47];
96+
isabstracttypeF = values[48];
97+
isimmutableF = values[49];
98+
isprimitivetypeF = values[50];
99+
sizeofF = values[51];
100+
parentmoduleF = values[52];
101+
nameofF = values[53];
102+
fieldcountF = values[54];
103+
fieldnameF = values[55];
104+
fieldoffsetF = values[56];
105+
fieldtypeF = values[57];
106+
BoolT = values[58];
107+
CharT = values[59];
108+
Float64T = values[60];
109+
Float32T = values[61];
110+
Float16T = values[62];
111+
Int64T = values[63];
112+
Int32T = values[64];
113+
Int16T = values[65];
114+
Int8T = values[66];
115+
UInt64T = values[67];
116+
UInt32T = values[68];
117+
UInt16T = values[69];
118+
UInt8T = values[70];
119+
ArrayT = values[71];
120+
121+
RegisterPrimitive(typeof(bool), BoolT);
122+
RegisterPrimitive(typeof(char), CharT);
123+
RegisterPrimitive(typeof(double), Float64T);
124+
RegisterPrimitive(typeof(float), Float32T);
125+
RegisterPrimitive(typeof(Half), Float16T);
126+
RegisterPrimitive(typeof(long), Int64T);
127+
RegisterPrimitive(typeof(int), Int32T);
128+
RegisterPrimitive(typeof(short), Int16T);
129+
RegisterPrimitive(typeof(sbyte), Int8T);
130+
RegisterPrimitive(typeof(ulong), UInt64T);
131+
RegisterPrimitive(typeof(uint), UInt32T);
132+
RegisterPrimitive(typeof(ushort), UInt16T);
133+
RegisterPrimitive(typeof(byte), UInt8T);
134+
RegisterPrimitive(typeof(Array), ArrayT);
100135
}
101136
}
102137
}

JuliadotNET/generators/csharp/Core/JPrimitive.jl

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Used for Parser Validation
22
SharpModule = quote
3-
export makearray, maketuple, writeSharpArray, maketuple, ieval
3+
export makearray, maketuple, writeSharpArray, maketuple, ieval, union_types, makentuple
44

55
function method_argnames(m::Method)
66
argnames = ccall(:jl_uncompress_argnames, Vector{Symbol}, (Any,), m.slot_syms)
@@ -9,9 +9,10 @@ SharpModule = quote
99
end
1010

1111
ieval(mod::Module, ex) = Core.eval(mod, Meta.parse(ex))
12-
makearray(T::Type, dims::Ptr{Cvoid}, len::Int32) = (ptr = convert(Ptr{Int32}, dims); Array{T}(undef, [unsafe_load(ptr, i) for i in 1:len]...))
1312
maketuple(vals...) = tuple(vals...)
13+
makentuple(::Type{T}, n, p::Ptr{Cvoid}) where T = (p2 = convert(Ptr{T}, p); return ntuple(i -> unsafe_load(p2, i), n))
1414
linedEvaluation(s::String, file::String, m::Module) = Core.eval(m, Meta.parseall(s, filename=file))
15+
1516
function writeSharpArray(p, arr)
1617
ptr = convert(Ptr{Any}, p)
1718
for i in eachindex(arr)
@@ -25,13 +26,32 @@ eval(SharpModule)
2526
symbols = [Base, Core, Main,
2627
sprint, showerror, catch_backtrace, string,
2728
getproperty, setproperty!, names,
28-
makearray, writeSharpArray, maketuple, ieval,
29+
makentuple, writeSharpArray, maketuple, ieval,
2930
getindex, setindex!, length, iterate,
30-
Module, Type, Function, Method, Union,
31+
Module, Type, Function, Method, Union, Integer, AbstractFloat, String, Ptr,
3132
==, !=, >, <, >=, <=, !, ~, ^, &, |, %, *, +, -, /, >>, <<,
3233
typeof, hash,
3334
ismutable, isabstracttype, isimmutable, isprimitivetype, sizeof, parentmodule, nameof,
3435
fieldcount, fieldname, fieldoffset, fieldtype]
36+
37+
primitiveTypeConversions = [
38+
Bool => "bool",
39+
Char => "char",
40+
41+
Float64 => "double",
42+
Float32 => "float",
43+
Float16 => "Half",
44+
45+
Int64 => "long",
46+
Int32 => "int",
47+
Int16 => "short",
48+
Int8 => "sbyte",
49+
UInt64 => "ulong",
50+
UInt32 => "uint",
51+
UInt16 => "ushort",
52+
UInt8 => "byte",
53+
Array => "Array"
54+
]
3555

3656
function generate_primitives(project_root, src_root, gen_root)
3757

@@ -84,29 +104,39 @@ function generate_primitives(project_root, src_root, gen_root)
84104
count += 1
85105
end
86106

107+
count += 1
108+
for v in primitiveTypeConversions
109+
push!(symbols, v[1])
110+
end
111+
112+
write_lines(kernel, array) = join(["$(kernel(m));" for m in array], "\n\t\t\t\t")
113+
87114
open("$gen_root/JPrimitive.gen.cs", "w") do io
88115
write(io, """using System;
89116
using System.Collections.Generic;
90117
using Base;
91118
92119
namespace JULIAdotNET{
93120
public static partial class JPrimitive {
94-
public static Any $(join(["$(m[1])M" for m in modules], ", "));
121+
public static JModule $(join(["$(m[1])M" for m in modules], ", "));
95122
public static JType $(join(["$(t[1])T" for t in types], ", "));
123+
public static JType $(join(["$(t)T" for t in symbols[count:end]], ", "));
96124
public static Any $(join(["$(fix_name(f[1]))F" for f in functions], ", "));
97125
98126
internal static unsafe void primitive_init() {
99127
100128
Julia.Eval(@"module SharpModule $(write_expression(SharpModule)) end; using .SharpModule");
101129
102130
var writeSharpArray = Julia.Eval(\"writeSharpArray\");
103-
fixed (Any* values = new Any[$count]) {
131+
fixed (Any* values = new Any[$(length(symbols))]) {
104132
var syms = Julia.Eval(\"[$(join(symbols, ","))]\");
105133
writeSharpArray.Invoke(new Any(values), syms);
106-
107-
$(join(["$(m[1])M = values[$(m[2])];" for m in modules], "\n\t\t\t\t"))
108-
$(join(["$(t[1])T = values[$(t[2])];" for t in types], "\n\t\t\t\t"))
109-
$(join(["$(fix_name(f[1]))F = values[$(f[2])];" for f in functions], "\n\t\t\t\t"))
134+
$(write_lines(m -> "$(m[1])M = values[$(m[2])]", modules))
135+
$(write_lines(t -> "$(t[1])T = values[$(t[2])]", types))
136+
$(write_lines(f -> "$(fix_name(f[1]))F = values[$(f[2])]", functions))
137+
$(write_lines(i -> "$(symbols[i])T = values[$(i-1)]", count:length(symbols)))
138+
139+
$(write_lines(t -> "RegisterPrimitive(typeof($(t[2])), $(t[1])T)", primitiveTypeConversions))
110140
}
111141
}
112142
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8f184346a170cc6d6cce6b5e01e2d59d9359b3de
1+
66b35ae081f7fc8cd1c57fe8437a9690c4b8d0be
6 KB
Binary file not shown.
2.82 KB
Binary file not shown.
1.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)