-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Clonkk/devel
Devel
- Loading branch information
Showing
16 changed files
with
267 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import nimjl | ||
|
||
proc common() = | ||
discard Julia.helloWorld1() | ||
discard Julia.helloWorld2() | ||
|
||
block: | ||
let res = Julia.meanAB(12, 16) | ||
echo res | ||
|
||
block: | ||
let res = Julia.squareDiv(9.3, 8.0) | ||
echo res | ||
|
||
# All methods accomplish the same result | ||
# main_3 is the cleanest (subjective option) so it should be preferred | ||
|
||
proc main_2() = | ||
# Manual embedding; must be done before init | ||
jlEmbedDir("jlassets/") | ||
jlEmbedFile("localasset.jl") | ||
|
||
Julia.init() | ||
defer: Julia.exit() | ||
|
||
common() | ||
|
||
proc main_1() = | ||
# Idiomatic way to embed Julia ressources and call them during after VM Init | ||
Julia.init: | ||
# Install package at init | ||
Pkg: | ||
add("LinearAlgebra") | ||
Embed: | ||
dir("jlassets/") | ||
file("localasset.jl") | ||
defer: Julia.exit() | ||
|
||
common() | ||
|
||
when isMainModule: | ||
main_1() |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function helloWorld1() | ||
println("HelloWorld1 from assets1") | ||
end | ||
|
||
function meanAB(a::Int, b::Int) | ||
println("meanAB from assets1") | ||
return (a+b)/2 | ||
end |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
function helloWorld2() | ||
println("HelloWorld1 from localasset") | ||
end | ||
|
||
function squareDiv(a::Float64, b::Float64) | ||
println("squareDiv from localasset") | ||
return (a*a)/(b*b) | ||
end |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function testMe2() | ||
println(">> Julia says... embedded function testMe2 exists !") | ||
return true | ||
end |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
function testMe() | ||
println(">> Julia says... embedded function testMe exists !") | ||
return true | ||
end |
Oops, something went wrong.