Skip to content

Possibility of implementing the TODO: CTA_QUAL ? #9

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

Open
folays opened this issue Feb 13, 2023 · 2 comments
Open

Possibility of implementing the TODO: CTA_QUAL ? #9

folays opened this issue Feb 13, 2023 · 2 comments

Comments

@folays
Copy link

folays commented Feb 13, 2023

Hello, I'm encountering the following

ffi.cdef[[ struct ImVec4 { float x,y,z,w; }; ]]

reflect.typeof(ffi.typeof("      struct ImVec4")) -- okay
reflect.typeof(ffi.typeof("const struct ImVec4")) -- complains due to some TODO

error :

./reflect.lua:208: TODO: CTA_QUAL
stack traceback:
	[C]: in function 'error'
	./reflect.lua:208: in function 'CTA'
	./reflect.lua:281: in function 'typeof'

which is into those lines belonging to reflect.lua :

-- Logic for merging an attribute CType onto the annotated CType.
local CTAs = {[0] =
  function(a, refct) error("TODO: CTA_NONE") end,
  function(a, refct) error("TODO: CTA_QUAL") end,          <<< ERROR THERE
  function(a, refct)
    a = 2^a.value
    refct.alignment = a
    refct.attributes.align = a
  end,
  function(a, refct)
    refct.transparent = true
    refct.attributes.subtype = refct.typeid
  end,
  function(a, refct) refct.sym_name = a.name end,
  function(a, refct) error("TODO: CTA_BAD") end,
}

The "types" that I get in input are not under my control, I get those const ImVec4 from a 3rd party : https://github.com/cimgui/cimgui/blob/docking_inter/generator/output/definitions.lua

Of course I could also workaround my problem by tricking my code into stripping the const problematics to reflect.typeof()

Would you have time... to do... this TODO: CTA_QUAL ? :)

Thanks,

Kind Regards

@sonoro1234
Copy link

sonoro1234 commented Dec 25, 2024

I have achieved const and volatile attributes as:

  function(a, refct, info) 
    print("CTA_QUAL",info)
    local const = (bit.band(info, 0x02000000) ~= 0) and true or nil
    local volatile = (bit.band(info, 0x01000000) ~= 0) and true or nil
    refct.const = const
    refct.volatile = volatile
    refct.attributes = nil
    a.typeid = refct.typeid
end, --error("TODO: CTA_QUAL") end,

where info is getted as bit.bor(ctype.info,ctype.size)
@corsix does it make sense?

as for CTA_NONE it should be function(a, refct) end, because CTA_NONE does not appear in the whole luajit codebase except for its definition where it says /* Ignored attribute. Must be zero. */

@sonoro1234
Copy link

I have made PR #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants