Skip to content

Commit ce51471

Browse files
authored
Regenerate libknitro.jl with KNITRO v14.1 (#306)
1 parent 2750930 commit ce51471

File tree

7 files changed

+1395
-303
lines changed

7 files changed

+1395
-303
lines changed

Diff for: gen/Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[deps]
22
Clang = "40e3b903-d033-50b4-a0cc-940c62c95e31"
3+
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"

Diff for: gen/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ julia --project -e "using Pkg ; Pkg.instantiate()"
1010

1111
Once the project installed, you can regenerate the C wrapper directly with:
1212
```julia
13-
using Clang
1413
include("generate_wrapper.jl")
15-
1614
```
1715
This takes as input the header file `knitro.h` in the `KNITRODIR`
1816
directory and generates automatically all the Julia bindings with Clang.jl.
19-

Diff for: gen/generate_wrapper.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using Clang
12
using Clang.Generators
3+
using JuliaFormatter
24

35
cd(@__DIR__)
46

@@ -13,3 +15,6 @@ push!(args, "-I$HEADER_BASE")
1315

1416
ctx = create_context(headers, args, options)
1517
build!(ctx)
18+
19+
path = options["general"]["output_file_path"]
20+
format_file(path)

Diff for: gen/generator.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ prologue_file_path = "./prologue.jl"
77

88
[codegen]
99
opaque_as_mutable_struct = false
10+
use_ccall_macro = true
1011

1112
[codegen.macro]
1213
macro_mode = "basic"

Diff for: gen/prologue.jl

+5
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
# Copyright (c) 2016: Ng Yee Sian, Miles Lubin, other contributors
2+
#
3+
# Use of this source code is governed by an MIT-style license that can be found
4+
# in the LICENSE.md file or at https://opensource.org/licenses/MIT.
5+
16
const DBL_MAX = Float64(0x1.fffffffffffffp+1023)

Diff for: src/KNITRO.jl

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ function __init__()
3434
end
3535

3636
function knitro_version()
37-
buffer = zeros(Cchar, 15)
38-
ccall((:KTR_get_release, libknitro), Cint, (Cint, Ptr{Cchar}), 15, buffer)
39-
version_string = GC.@preserve(buffer, unsafe_string(pointer(buffer)))
37+
length = 15
38+
release = zeros(Cchar, length)
39+
KN_get_release(length, release)
40+
version_string = GC.@preserve(release, unsafe_string(pointer(release)))
4041
return VersionNumber(split(version_string, " ")[2])
4142
end
4243

0 commit comments

Comments
 (0)