|
| 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 | +} |
0 commit comments