Skip to content

Commit 560ef32

Browse files
committed
Add base for Scala Port.
1 parent 1284105 commit 560ef32

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* MetaCall Scala Port by Parra Studios
3+
* A complete infrastructure for supporting multiple language bindings in MetaCall.
4+
*
5+
* Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
package metacall
22+
23+
import com.sun.jna._
24+
25+
trait MetaCall extends Library {
26+
def metacall_initialize(): Int
27+
def metacall_load_from_file(runtime: String, paths: Array[String]): Int
28+
def metacallv_s(name: String, args: Array[Pointer], size Long): Pointer
29+
30+
// TODO: Implement value methods
31+
32+
def metacall_destroy(): Int
33+
}
34+
35+
object MetaCall {
36+
private var metacall : MetaCall = null;
37+
38+
// Initialization block
39+
{
40+
if (metacall == null) {
41+
metacall = Native.load("metacall", classOf[MetaCall].asInstanceOf[MetaCall])
42+
}
43+
44+
if (metacall.metacall_initialize() != 0) {
45+
throw new RuntimeException("MetaCall could not initialize")
46+
}
47+
}
48+
}

source/ports/scala_port/test.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* MetaCall Scala Port by Parra Studios
3+
* A complete infrastructure for supporting multiple language bindings in MetaCall.
4+
*
5+
* Copyright (C) 2016 - 2021 Vicente Eduardo Ferrer Garcia <[email protected]>
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*
19+
*/
20+
21+
// TODO
22+
23+
/*
24+
mc.metacall_load_from_file("node", Array("./main.js"))
25+
val r = mc.metacall("hello", "1")
26+
27+
println(r)
28+
*/

0 commit comments

Comments
 (0)