9 /* Setup of the symbol table */
10 void functions_init (void);
11 void functions_shutdown (void);
13 GPtrArray
*gnm_func_enumerate (void);
15 /******************************************************************************/
16 /* Function group support */
18 struct _GnmFuncGroup
{
19 GOString
*internal_name
, *display_name
;
20 gboolean has_translation
;
22 unsigned ref_count
; /* boxed type */
25 GType
gnm_func_group_get_type (void); /* boxed type */
26 GnmFuncGroup
*gnm_func_group_get_nth (gint n
);
27 GnmFuncGroup
*gnm_func_group_fetch (char const *name
,
28 char const *translation
);
30 /******************************************************************************/
33 * Function registration routines
35 * Functions come in two fashions: Those that only deal with
36 * very specific data types and a constant number of arguments,
37 * and those who don't.
39 * The former kind of functions receives a precomputed array of
42 * The latter sort of functions receives the plain ExprNodes and
43 * it is up to that routine to do the value computations and range
48 * Argument tokens passed in 'args'
50 * With intersection and iteration support
51 * f : floating point (no errors, string conversion attempted)
52 * b : boolean (identical to f, Do we need this ?)
53 * s : string (no errors)
54 * S : 'scalar': any non-error value
55 * E : scalar including errors
56 * Without intersection or iteration support
57 * r : cell range content is _NOT_ guaranteed to have been evaluated yet
58 * A : area either range or array (as above)
62 * For optional arguments do:
63 * "ff|ss" where the strings are optional
67 GNM_FUNC_TYPE_ARGS
, /* Arguments get marshalled by type */
68 GNM_FUNC_TYPE_NODES
, /* Takes unevaulated expers directly */
70 /* implementation has not been loaded yet, but we know where it is */
76 GNM_FUNC_VOLATILE
= 1 << 0, /* eg now(), today() */
77 GNM_FUNC_RETURNS_NON_SCALAR
= 1 << 1, /* eg transpose(), mmult() */
79 /* For functions that are not exactly compatible with various import
80 * formats. We need to recalc their results to avoid changing values
81 * unexpectedly when we recalc later. This probably needs to be done
82 * on a per import format basis. It may not belong here.
84 /* GNM_FUNC_RECALC_ONLOAD = 1 << 2, */
86 /* an unknown function that will hopefully be defined later */
87 GNM_FUNC_IS_PLACEHOLDER
= 1 << 3,
88 GNM_FUNC_IS_WORKBOOK_LOCAL
= 1 << 5,
89 GNM_FUNC_INTERNAL
= 1 << 6,
91 GNM_FUNC_AUTO_UNKNOWN
= 0 << 8,
92 GNM_FUNC_AUTO_MONETARY
= 1 << 8, /* Like PV */
93 GNM_FUNC_AUTO_DATE
= 2 << 8, /* Like DATE */
94 GNM_FUNC_AUTO_TIME
= 3 << 8, /* Like TIME */
95 GNM_FUNC_AUTO_PERCENT
= 4 << 8, /* Like IRR */
96 GNM_FUNC_AUTO_FIRST
= 5 << 8, /* Like SUM */
97 GNM_FUNC_AUTO_SECOND
= 6 << 8, /* Like IF */
98 GNM_FUNC_AUTO_UNITLESS
= 7 << 8, /* Like COUNT */
99 GNM_FUNC_AUTO_MASK
= 7 << 8 /* The bits we use for AUTO. */
102 /* I do not like this. It is going to be different for different apps probably
103 * want to split it into bit file with our notion of its state, and 2 bits of
104 * state per import format.
107 GNM_FUNC_IMPL_STATUS_EXISTS
= 0,
108 GNM_FUNC_IMPL_STATUS_UNIMPLEMENTED
,
109 GNM_FUNC_IMPL_STATUS_SUBSET
,
110 GNM_FUNC_IMPL_STATUS_COMPLETE
,
111 GNM_FUNC_IMPL_STATUS_SUPERSET
,
112 GNM_FUNC_IMPL_STATUS_SUBSET_WITH_EXTENSIONS
,
113 GNM_FUNC_IMPL_STATUS_UNDER_DEVELOPMENT
,
114 GNM_FUNC_IMPL_STATUS_UNIQUE_TO_GNUMERIC
118 GNM_FUNC_TEST_STATUS_UNKNOWN
= 0,
119 GNM_FUNC_TEST_STATUS_NO_TESTSUITE
,
120 GNM_FUNC_TEST_STATUS_BASIC
,
121 GNM_FUNC_TEST_STATUS_EXHAUSTIVE
,
122 GNM_FUNC_TEST_STATUS_UNDER_DEVELOPMENT
125 typedef GnmValue
*(*GnmFuncArgs
) (GnmFuncEvalInfo
*ei
, GnmValue
const * const *args
);
126 typedef GnmValue
*(*GnmFuncNodes
) (GnmFuncEvalInfo
*ei
,
127 int argc
, GnmExprConstPtr
const *argv
);
128 typedef GnmDependentFlags (*GnmFuncLink
) (GnmFuncEvalInfo
*ei
, gboolean qlink
);
130 typedef void (*GnmFuncUsageNotify
) (GnmFunc
*f
, int refcount
);
131 typedef gboolean (*GnmFuncLoadDesc
) (GnmFunc
const *f
, GnmFuncDescriptor
*fd
);
134 GNM_FUNC_HELP_END
, /* Format */
137 /* <NAME>:<1 SENTENCE DESCRIPTION> (translated) */
140 /* <NAME>:<1 SENTENCE DESCRIPTION> (translated) */
142 GNM_FUNC_HELP_DESCRIPTION
,
143 /* <LONG DESCRIPTION (reference args using @{arg})> (translated) */
146 /* <SPECIAL CASES (reference args using @{arg})> (translated) */
148 GNM_FUNC_HELP_EXAMPLES
,
150 * Either translated text, or a formula that is only marked for
151 * translation if it contains strings that need to be translated.
154 GNM_FUNC_HELP_SEEALSO
,
155 /* name,name,name ... (not translated) */
157 GNM_FUNC_HELP_EXTREF
,
159 * Link to external descriptions. The following styles defined:
161 * wiki:en:Trigonometric_functions
165 /* <SPECIAL NOTE RE EXCEL (reference args using @{arg})> (translated) */
168 /* <SPECIAL NOTE RE ODF (reference args using @{arg})> (translated) */
171 GnmFuncHelpType type
;
175 struct _GnmFuncDescriptor
{
177 char const *arg_spec
;
178 GnmFuncHelp
const *help
;
180 GnmFuncNodes fn_nodes
;
182 GnmFuncUsageNotify usage_notify
;
184 GnmFuncImplStatus impl_status
;
185 GnmFuncTestStatus test_status
;
190 GPtrArray
*arg_names_p
;
191 GnmFuncHelp
const *help
;
193 char *localized_name
;
198 char const *arg_spec
;
200 int min_args
, max_args
;
203 GnmFuncLoadDesc load_desc
;
205 GnmFuncGroup
*fn_group
; /* most recent it was assigned to */
207 GnmFuncUsageNotify usage_notify
;
208 GnmFuncImplStatus impl_status
;
209 GnmFuncTestStatus test_status
;
216 struct _GnmFuncEvalInfo
{
217 GnmEvalPos
const *pos
;
218 GnmExprFunction
const *func_call
;
219 GnmExprEvalFlags flags
;
222 GnmFunc
const *gnm_eval_info_get_func (GnmFuncEvalInfo
const *ei
);
223 int gnm_eval_info_get_arg_count (GnmFuncEvalInfo
const *ei
);
226 GType
gnm_func_get_type (void);
227 void gnm_func_free (GnmFunc
*func
);
228 GnmFunc
*gnm_func_ref (GnmFunc
*func
);
229 void gnm_func_unref (GnmFunc
*func
);
230 void gnm_func_load_if_stub (GnmFunc
*func
);
231 void gnm_func_load_stub (GnmFunc
*fn_def
);
232 char const *gnm_func_get_name (GnmFunc
const *func
,
234 gpointer
gnm_func_get_user_data (GnmFunc
const *func
);
235 void gnm_func_set_user_data (GnmFunc
*func
, gpointer user_data
);
236 GnmFunc
*gnm_func_lookup (char const *name
, Workbook
*scope
);
237 GnmFunc
*gnm_func_lookup_localized (char const *name
, Workbook
*scope
);
238 GSList
*gnm_func_lookup_prefix (char const *prefix
, Workbook
*scope
,
240 GnmFunc
*gnm_func_add (GnmFuncGroup
*group
,
241 GnmFuncDescriptor
const *descriptor
,
242 const char *tdomain
);
243 GnmFunc
*gnm_func_add_placeholder (Workbook
*optional_scope
,
246 GnmFunc
*gnm_func_add_placeholder_localized (char const *gname
, char const *lname
);
247 GnmFunc
*gnm_func_lookup_or_add_placeholder (char const *name
);
248 void gnm_func_upgrade_placeholder
250 GnmFuncGroup
*fn_group
,
252 GnmFuncLoadDesc load_desc
,
253 GnmFuncUsageNotify opt_usage_notify
);
256 char const *gnm_func_get_description (GnmFunc
const *fn_def
);
257 void gnm_func_count_args (GnmFunc
const *fn_def
,
258 gint
*min
, int *max
);
259 char gnm_func_get_arg_type (GnmFunc
const *fn_def
,
261 char const *gnm_func_get_arg_type_string (GnmFunc
const *fn_def
,
263 char *gnm_func_get_arg_name (GnmFunc
const *fn_def
,
265 char const *gnm_func_get_arg_description (GnmFunc
const *fn_def
,
267 char *gnm_func_convert_markup_to_pango (char const *desc
,
270 /*************************************************************************/
272 GnmValue
*function_call_with_exprs (GnmFuncEvalInfo
*ei
);
273 GnmValue
*function_call_with_values (GnmEvalPos
const *ep
, char const *name
,
274 int argc
, GnmValue
const * const *values
);
275 GnmValue
*function_def_call_with_values (GnmEvalPos
const *ep
, GnmFunc
const *fn
,
276 int argc
, GnmValue
const * const *values
);
278 /* Utilies to interate through ranges and argument lists */
279 typedef GnmValue
* (*FunctionIterateCB
) (GnmEvalPos
const *ep
, GnmValue
const *value
,
281 GnmValue
*function_iterate_argument_values (GnmEvalPos
const *ep
,
282 FunctionIterateCB callback
,
283 gpointer callback_closure
,
285 GnmExprConstPtr
const *argv
,
287 CellIterFlags iter_flags
);
291 #endif /* _GNM_FUNC_H_ */