The Gerris Object System
From Gerris
| Revision as of 16:46, 21 August 2012 GeordieMcBain (Talk | contribs) (→Note for dummies: pointers to functions - added navigation to footer) ← Previous diff |
Current revision GeordieMcBain (Talk | contribs) (→Note for dummies: pointers to functions - reword; put code snippets in <code> tags) |
||
| Line 13: | Line 13: | ||
| ====== Note for dummies: pointers to functions ====== | ====== Note for dummies: pointers to functions ====== | ||
| - | At this stage you (or your teacher if this is a live class) should remind the basic facts about ''pointers to functions''. | + | At this stage you (or your teacher if this is a live class) should recall the basic facts about ''pointers to functions''. |
| Remember in particular that | Remember in particular that | ||
| <source lang="c"> | <source lang="c"> | ||
| Line 26: | Line 26: | ||
| int *ptr_foo (int bar); | int *ptr_foo (int bar); | ||
| </source> | </source> | ||
| - | In that case, because '()' has precedence over indirection '*', | + | In that case, because <code>()</code> has precedence over indirection <code>*</code>, |
| we would define a function of an integer returning a pointer to an integer. | we would define a function of an integer returning a pointer to an integer. | ||
| (That [http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Operator-Precedence C operator precedence table] comes in handy here.) | (That [http://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Operator-Precedence C operator precedence table] comes in handy here.) | ||
Current revision
Gerris and GTS are programmed in a style analogous to that of GLib, Gnome and GTK+. It is a style of C programming that offers several advantages:
- Most aspects of Object-Oriented Programming (OOP), such as the existence of classes with their own methods and inheritance.
- The ability to interface to other programming languages. (As far as I know, this feature is not used in Gerris, but this has been exploited to give GTS Python bindings in PyGTS.)
To implement Object-Oriented Programming, Gerris/GTS uses its own ‘Object system’. This system is analogous to the GLib object system (GObject), but not identical to it.
THIS CHAPTER IS CURRENTLY BEING WRITTEN.
Note for dummies: pointers to functions
At this stage you (or your teacher if this is a live class) should recall the basic facts about pointers to functions. Remember in particular that
int foo(int bar);
declares a function of an integer returning an integer and
int (*ptr_foo) (int bar);
declares a pointer to an integer function. If we were to write
int *ptr_foo (int bar);
In that case, because () has precedence over indirection *,
we would define a function of an integer returning a pointer to an integer.
(That C operator precedence table comes in handy here.)
⇐ previous: Programming the Advection Scheme, ⇑ up: Gerris Flow Solver Programming Course for Dummies, ⇒ next: An Example of Use of the Gerris Object System

