Re: Third draft (was Re: defs files)



From: Havoc Pennington <hp@redhat.com>


[i really do not like to quote large parts of text
but I don't want to cut anything here since all the
information can be relevant to my post]
+
[here are some late-in-the-night ideas. Please do
not ask me too much :)]

> ===
>
> (type
>  (alias some-unique-identifier)
>  (in-module module-name)   ;; optional, gchar* is not in a module

    well... I think glib can be the module of the
    basic glib types (just as gint and gpointer)

>  (gtk-type-id gtk-type-system-id) ;; optional, absent if this is not
>                                   ;; in the type system
>  (in-c-name name-of-symbol-in-C)
>  (out-c-name name-of-symbol-in-C)
>  (inout-c-name name-of-symbol-in-C))

Should prefer to have a :
(defined-type
    (alias a)
    (in-module m)
    (gtk-type-id id))

and:
(used-type
    (use-defined-type t) ; probably not so useful
    (alias a)
    (c-name name-of-symbol-in-C))

This should be probably clearer and more flexible
than the in, inout and out attributes.

>
> Ex: (type
>      (alias string)
>      (gtk-type-id GTK_TYPE_STRING)
>      (in-c-name const-gchar*)
>      (out-c-name gchar**)      ;; actually I'm not sure how strings work
out/inout
>      (inout-c-name gchar*))
>

Ex:
    (defined-type
        (alias string)
        (in-module glib))

    (used-type
        (use-defined-type string)
        (alias string-in)
        (c-name const-gchar*))

    (used-type
        (use-defined-type string)
        (alias string-out)
        (c-name gchar**))

    (used-type
        (use-defined-type string)
        (alias string-inout)
        (c-name gchar*))

The implied definitions for objects/boxed types should
be changed accordingly.

> The alias field is used to refer to the type later on.

[note this, please :)]

> ===
>
> (function function-name
>   (in-module module-name-list) ;; "static methods" go in their
>                                ;;  object's module
>   (is-constructor-of object-type-alias) ;; optional, marks a constructor
>   (c-name function-name)
>   (return-type return-value-type) ;; defaults to void
>   (caller-owns-return boolean-value) ;; defaults to #f
>   (parameter in-or-out-or-inout
>       (type-and-name parameter-type-alias parameter-name)
>       (c-declaration "c-type-and-name")) ;; c-declaration only required
>                                          ;; if the type alias is "native"
>   (varargs #t) ;; has varargs at the end
> )

This would turn into
(function f-name
    (in-module m)
    (is-constructor-of-object a)
    (return-type used-type-alias)
    (caller-owns-return bool)
    (parameter-list
        (used-type-alias parameter-name)
        (varargs bool)))

We do not need the c-declaration at all since we provide the
declaration in the (used-type) def.
The (function) definition is now simpler and easier to understand.

> ===
> (method method-name
>   (of-object object-name module-name)
>   ;; retval/arg attributes as for (function), but with first parameter
>   ;; omitted for non-constructors
>    )
> ===
> (signal signal-name
>   (of-object object-we-are-a-signal-of optional-objects-module)
>   ;; return value and parameters as for a function, omitting the object
>   ;; and user data parameters
>
>   ;; what other properties matter for a signal?
> )

Again, this have to be changed accordingly to the new def (the same thing
is applicable to a lot of other (def) structures.

Hope my brain is not damaged by the current time (6 AM ! I have not slept
for more than 30 hours :)

Emmanuel




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]