So I was going through the vulcan spec to try to create a better D bindings for it. (pointer /len pairs to arrays adhering to D naming conventions and prettying up the *Create functions functions like vkResult *Create( arg ,&arg, retptr) to a fancy throw on misuse struct with constructors and that kind of stuff.)

 the structure of the registry is as follows.


struct KHR_registry
{

string comment; // Not as xml comment but a <comment> ... </comment>

    struct vendorid
    {
        string @Tag name;
        string @Tag id;
        string @Tag comment;
    }
    vendorid[] vendorids;

    struct tag
    {
        string @Tag name;
        string @Tag author;
        string @Tag contact;
    }
    tag[] tags;

struct validity_type // does not appear at this level but is common to commands and types
    {
        struct usage_type
        {
            string content;
        }
        usage_type[] usage;
    }
    struct type
    {
string name; // inconsistanly in tag and content
        string requires;
        string parent;
        string content;
        enum category_tpye
        {
            include,
            define,
            basetype,
            bitmask,
            handle,
            enum_,
            funcpointer,
            struct_,

        }
        category_tpye category;
        bool returnedonly;

        validity_type validity;
        struct member
        {
string typename; //name of the members type variable tag type
            string name;            //name of the member variable
string len; //companion member length variable for array pointers bool optional; //should generate as a default value
            bool noautovalidity;

        }
enums* enum; //pointer to corresponding type enum definition
        struct params
        {
type* paramType; //for some reason any pointer qualifiactions occur after e.g. // <type> void </type> * see coment below
            string name;
size_t inderections; // number of pointer inderections before reaching the type pointed to
                                                // by paramType
// functions taking no args will have parameters == []
            string content;

        }
        params[] parameters;
    }
    type[] types;

    struct enums
    {
        string name,comment, type, expand;
          // expand is the C enum's Prefix e.g. VK_QUERY_TYPE
        struct enum_
        {
            string value, name, comment;
        }
    }

    struct command
    {
        string successcodes;
        string errorcodes;
        string content;
        struct proto_type
        {
            string content;
            type* returnType;
            string name;


        }
        proto_type proto;
        struct pram
        {
            string content;
            bool optional;
            string externsync;
            string len;
            size_t inderections;
            immutable invalidLen = "null-terminated";
            // if len is this then it is not an array
            // although this is inconsistant. sometimes as a len
            // others in the validity
        }
        validity_type validity;
        string queues, renderpass, cmdbufferlevel;
    }

    command[] commands;
    struct feature
    {
        string api, name, number;

        /*
         <require comment="API version">
         <type name="VK_API_VERSION"/>
         <enum name="VK_VERSION_MAJOR"/>
         <command name="VK_VERSION_MINOR"/>
         <type name="VK_VERSION_PATCH"/>
         </require>*/
        struct require

        {
            string comment;
string metaType; // type enum command see above variable tag type
            string name;
        }
        require[] requires;
    }
    struct extension
    {
        string name, number, supported;
        struct require
        {
            struct elem
            {
                string name, content;
                string metaType; //variable tag type
                string offset, extends;
            }
        }
    }
    extension[] extensions;
}

where "string content" is the string between the tags (does this have a name?) and thing with @Tag are always in the tag (although it is also inconsistent). I tried looking at the docs for std.xml but they were not very helpful.

To further complicate things not all of the fields are present in all cases also I need to keep track of the number of '*' (see fields named indirections) after a tag has closed for pointer type declarations in function signatures and structs.

Also is there a way to do sane cross referencing without having internal pointers everywhere.

I'm sure there should be a very elegant way to do this by recursing down through the sub-structs

Many thanks
Nic
  • vk.xml Nicholas Wilson via Digitalmars-d-learn
    • Re: vk.xml ZombineDev via Digitalmars-d-learn
      • Re: vk.xml Nicholas Wilson via Digitalmars-d-learn
        • Re: vk.xml Nicholas Wilson via Digitalmars-d-learn
      • Re: vk.xml Nicholas Wilson via Digitalmars-d-learn
        • Re: vk.xml Mike Parker via Digitalmars-d-learn
          • Re: vk.xml Steven Schveighoffer via Digitalmars-d-learn

Reply via email to