[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: general c++ question
From: |
John W. Eaton |
Subject: |
Re: general c++ question |
Date: |
Thu, 06 Sep 2007 17:41:36 -0400 |
On 31-Aug-2007, Shai Ayal wrote:
| On 8/31/07, John W. Eaton <address@hidden> wrote:
| > On 29-Aug-2007, John W. Eaton wrote:
| >
| > | On 29-Aug-2007, Shai Ayal wrote:
| > |
| > | | This way you will loose the easiness of having them automatically
| > | | generated in the macro. But it is better and more consistent.
| > |
| > | Many of them do not force any other action. They are simply of the
| > | form
| > |
| > | PROP = val;
| > |
| > | so they can be generated by the macro. Of course we will need a
| > | separate macro that does not generate the set_PROP function. Let me
| > | take a look at doing at least one or two classes this way.
| >
| > After spending some time on this, I think we need something more than
| > the C preprocessor to do the job. I'm working on a patch that will
| > move graphics.h to graphics.h.in and then use an AWK or Perl script to
| > generate graphics.h. The properties declarations in the graphics.h.in
| > file will be something like
| >
| > BEGIN_PROPERTIES
| > graphics_handle currentfigure S
| > octave_value visible
| > END_PROPERTIES
| >
| > The properties will be specified with
| >
| > TYPE PROPNAME FLAGS
| >
| > The optional FLAGS field can be some combination of characters that
| > tell the script whether to declare the field "mutable", emit a
| > definition and/or declaration for the set_PROPNAME and get_PROPNAME
| > functions, etc. The script will only generate the simple ones
| > automatically (the ones for which the body of the function is just
| > "PROPNAME = val;" or "return PROPNAME;"). The others will have to be
| > written by hand. With this approach, I think we can also
| > automatically generate the set and get functions that work with the
| > names of the fields. There are a few more details to work out, but I
| > think I can have something checked in by next week.
|
|
| Looks good to me. Until the patch is in I will assume the interface to
| c++ stays like you outlined before in this thread using the
| get_PROPNAME methods. Hopefully this won't change
I've checked in my changes now. The following comments at the top of
src/genprops.awk should explain how the new scheme works:
## This script is used to generate the graphics.h file from graphics.h.in.
##
## Lines between the BEGIN_PROPERTIES and END_PROPERTIES markers have
## one of the following formats:
##
## TYPE NAME
## TYPE NAME QUALIFIERS
## mutable TYPE NAME
## mutable TYPE NAME QUALIFIERS
##
## For each property, we generate a declaration for the property.
##
## If QUALIFIERS is omitted, we generate the following functions directly
## in the class declaration:
##
## TYPE
## get_NAME (void) const
## {
## return NAME;
## }
##
## void
## set_NAME (const TYPE& val)
## {
## if (! error_state)
## NAME = val;
## }
##
## void
## set_NAME (const octave_value& val)
## {
## set_NAME (TYPE (val));
## }
##
## If present, the QUALIFIERS string may include any of the characters
## g, G, m, s, S, o, O, which have the following meanings:
##
## g: There is a custom inline definition for the get function,
## so we don't emit one.
##
## G: There is a custom extern definition for the get function,
## so we emit only the declaration.
##
## s: There is a custom inline definition for the type-specific set
## function, so we don't emit one.
##
## S: There is a custom extern definition for the type-specific set
## function, so we emit only the declaration.
##
## o: There is a custom inline definition for the octave_value version
## of the set function, so we don't emit one.
##
## O: There is a custom extern definition for the octave_value version
## of the set function, so we emit only the declaration.
##
## m: Add the line
##
## set_NAMEmode ("manual");
##
## to the type-specific set function.
##
## The 'o' and 'O' qualifiers are only useful when the the property type
## is something other than octave_value.
After updating, you'll need to update the src/Makefile, be sure that
src/graphics.h is no longer in your source tree, and maybe also remove
any src/*.d files that mention the old location of the graphics.h
header file.
I haven't decided yet whether to also have the genprops.awk script
generate the functions that get and set properties by names, but I
may do that eventually. For now, you still have to edit those
functions when you add a property.
jwe
- Re: general c++ question,
John W. Eaton <=