Giter VIP home page Giter VIP logo

Comments (8)

giordano avatar giordano commented on May 27, 2024 1

I guess the question is "what do you want to do with bufdata?". In julia v1.11+ IOBuffer(::Vector{UInt8}) doesn't wrap directly the vector passed as input, and looking at the docstring it doesn't look like it promised to do that. Much simpler demonstration:
julia v1.10:

julia> bufdata = UInt8[]
UInt8[]

julia> iobuf = IOBuffer(bufdata, read = true, write = true)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> println(iobuf, "hello")

julia> iobuf.data
6-element Vector{UInt8}:
 0x68
 0x65
 0x6c
 0x6c
 0x6f
 0x0a

julia> bufdata
6-element Vector{UInt8}:
 0x68
 0x65
 0x6c
 0x6c
 0x6f
 0x0a

julia> bufdata === iobuf.data
true

julia master:

julia> bufdata = UInt8[]
UInt8[]

julia> iobuf = IOBuffer(bufdata, read = true, write = true)
IOBuffer(data=UInt8[...], readable=true, writable=true, seekable=true, append=false, size=0, maxsize=Inf, ptr=1, mark=-1)

julia> println(iobuf, "hello")

julia> iobuf.data
8-element Memory{UInt8}:
 0x68
 0x65
 0x6c
 0x6c
 0x6f
 0x0a
 0x00
 0x00

julia> bufdata
UInt8[]

julia> bufdata === iobuf.data
false

from julia.

oscardssmith avatar oscardssmith commented on May 27, 2024 1

the issue here is that figuring out what to change it to is pretty hard. This code seems to be built extensively on the assumption that if you give a Vector to an IOBuffer, at some unspecified later point in time, after you have done a lot of things with that IOBuffer, the Vector you passed in to the IOBuffer at the beginning will have all the bytes that were read into the IOBuffer. I think the correct change, might be to remove the bufferdata field entirely, and replace the uses of String(copy(buffer.bufferdata)) with

seekstart(buffer.buffer)
read(buffer.buffer)

That said, given the API that this package exposes, I think this would likely be a breaking change for the package.

from julia.

oscardssmith avatar oscardssmith commented on May 27, 2024

there have been some changes to iobuffer recently. Is Luxor accessing the internals of it?

from julia.

cormullion avatar cormullion commented on May 27, 2024

I don't think it's doing much of that.

Starting at:

bufdata = UInt8[]
iobuf = IOBuffer(bufdata, read = true, write = true)

there's

Cairo.CairoSVGSurface(iobuf, w, h)

which is the stream for this (Cairo.jl):

function CairoSVGSurface(stream::T, w::Real, h::Real) where {T<:IO}
    callback = get_stream_callback(T)
    surf = CairoSurface(C_NULL, w, h, stream)
    GC.@preserve surf begin
        surf.ptr = ccall((:cairo_svg_surface_create_for_stream,libcairo), Ptr{Nothing},
                         (Ptr{Nothing}, Ptr{Nothing}, Float64, Float64), callback,
                         get_stream_ptr(surf), w, h)
    end
    return surf
end

from julia.

cormullion avatar cormullion commented on May 27, 2024

Thanks, Mosรจ! I think I vaguely understand.

Do you think the behaviour of this on master is likely to change, or will I have to change my code somehow?

from julia.

oscardssmith avatar oscardssmith commented on May 27, 2024

We aren't currently planning on reverting the change, but we perhaps should ask triage on this one. In theory the change only affected internals, but it has broken a lot of people's code that was (intentionally or not) depending on internals.

from julia.

cormullion avatar cormullion commented on May 27, 2024

I'm happy to change my code - if you tell me what to change it to! ๐Ÿ˜€

from julia.

cormullion avatar cormullion commented on May 27, 2024

Thanks, Oscar. I think I see what's going on.

I'm not able to rebuild this area of the code at the moment, so I'll close this issue for now.

from julia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.