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

Revert use of Cstring to Ptr{UInt8} #260

Closed
wants to merge 1 commit into from
Closed
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
32 changes: 0 additions & 32 deletions scripts/generate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ context = create_context(
)
build!(context)

function replace_line_cstring(line, signature)
changes = getindex.(
signature,
findall(r"char(\s*?\*| [a-z0-9]+?\[\])", signature),
)
last_index = 1
outputs = String[]
for (change, range) in zip(changes, findall("Ptr{UInt8}", line))
push!(outputs, line[last_index:(first(range)-1)])
if endswith(change, "*")
push!(outputs, "Cstring")
else
push!(outputs, line[range])
end
last_index = last(range) + 1
end
push!(outputs, line[last_index:end])
return join(outputs)
end

function postprocess(filename)
contents = read(filename, String);
# Remove the deprecated if-else blocks
Expand Down Expand Up @@ -98,18 +78,6 @@ function postprocess(filename)
println(io, "# Function does not exist in v33")
end
end
if occursin("Ptr{UInt8}", line)
# Replace Ptr{Cchar} with Cstring for backward compatibility
# with older versions of Xpress.jl
#
# We need to replace char* with Ptr{UInt8} and char[] with
# Cstring.
map = Dict("char*" => "Cstring", "char" => "Ptr{UInt8}")
m = match(r"ccall\(\(:(XPRS.+?)\,", line)
@assert m !== nothing
signature = xprs_signatures[m.captures[1]]
line = replace_line_cstring(line, signature)
end
if !(isempty(line) && isempty(last_line))
println(io, line)
end
Expand Down
Loading
Loading