Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP:example for #31 #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/csharp/dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description "Wrap existing D code for use in C#."
authors "Adam Wilson"
license "BSD 3-clause"
copyright "Copyright © 2018, Symmetry Investments LP"

versions "PaperOverBug"
dependency "autowrap:csharp" path="../../"

configuration "buildSharedLib" {
Expand Down
44 changes: 35 additions & 9 deletions examples/csharp/source/csharp/library.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module csharp.library;


export int freeFunction (int value) {
return value;
}
Expand Down Expand Up @@ -29,17 +30,42 @@ export string testErrorMessage(bool throwError) {
return "No Error Thrown";
}

struct s1 {
public float value;
export auto makeS1Float(float value, s2 nestedStruct)
{
return S1(value,nestedStruct);
}

version(PaperOverBug)
{
alias S1 = s1;
struct s1 {
public float value;
public s2 nestedStruct;

public auto getValue() {
return value;
}

public void setNestedStruct(s2 nested) {
nestedStruct = nested;
}
}
}
else
{
alias S1=s1!float;
struct s1(T) {
public T value;
public s2 nestedStruct;

public float getValue() {
public auto getValue() {
return value;
}

public void setNestedStruct(s2 nested) {
nestedStruct = nested;
}
}
}

struct s2 {
Expand Down Expand Up @@ -71,10 +97,10 @@ class c1 {
public string stringMember;
public wstring wstringMember;
public dstring dstringMember;
public s1 valueMember;
public S1 valueMember;
public c1 refMember;
public c1[] refArray;
public s1[] structArray;
public S1[] structArray;

//Property test cases
private s2 _structProperty;
Expand Down Expand Up @@ -133,11 +159,11 @@ class c1 {
return _dstringSliceProperty = value;
}

private s1[] _structSliceProperty;
public @property s1[] structSliceProperty() {
private S1[] _structSliceProperty;
public @property S1[] structSliceProperty() {
return _structSliceProperty;
}
public @property s1[] structSliceProperty(s1[] value) {
public @property S1[] structSliceProperty(S1[] value) {
return _structSliceProperty = value;
}

Expand All @@ -149,7 +175,7 @@ class c1 {
return _refSliceProperty = value;
}

public string testMemberFunc(string test, s1 value){
public string testMemberFunc(string test, S1 value){
return test;
}
}