Commit af8470dc authored by Morten Welinder's avatar Morten Welinder

Introspection and doc fixes

parent c5acbad1
...@@ -59,9 +59,7 @@ gnm_cell_pos_get_type (void) ...@@ -59,9 +59,7 @@ gnm_cell_pos_get_type (void)
static GnmEvalPos * static GnmEvalPos *
gnm_eval_pos_dup (GnmEvalPos *ep) gnm_eval_pos_dup (GnmEvalPos *ep)
{ {
GnmEvalPos *res = g_new0 (GnmEvalPos, 1); return g_memdup (ep, sizeof (*ep));
memcpy (res, ep, sizeof (GnmEvalPos)); /* is this safe? */
return res;
} }
GType GType
...@@ -218,11 +216,9 @@ eval_pos_is_array_context (GnmEvalPos const *ep) ...@@ -218,11 +216,9 @@ eval_pos_is_array_context (GnmEvalPos const *ep)
static GnmParsePos * static GnmParsePos *
gnm_parse_pos_dup (GnmParsePos *ep) gnm_parse_pos_dup (GnmParsePos *pp)
{ {
GnmParsePos *res = g_new0 (GnmParsePos, 1); return g_memdup (pp, sizeof (*pp));
memcpy (res, ep, sizeof (GnmParsePos)); /* is this safe? */
return res;
} }
GType GType
...@@ -238,9 +234,8 @@ gnm_parse_pos_get_type (void) ...@@ -238,9 +234,8 @@ gnm_parse_pos_get_type (void)
return t; return t;
} }
/* /**
* parse_pos_init: * parse_pos_init:
*
* @pp: The position to init. * @pp: The position to init.
* @sheet: The sheet being selected * @sheet: The sheet being selected
* @wb: The workbook being selected. * @wb: The workbook being selected.
...@@ -269,7 +264,7 @@ parse_pos_init (GnmParsePos *pp, Workbook *wb, Sheet const *sheet, ...@@ -269,7 +264,7 @@ parse_pos_init (GnmParsePos *pp, Workbook *wb, Sheet const *sheet,
return pp; return pp;
} }
/* /**
* parse_pos_init_dep: * parse_pos_init_dep:
* @pp: The position to init. * @pp: The position to init.
* @dep: The dependent * @dep: The dependent
...@@ -288,7 +283,7 @@ parse_pos_init_dep (GnmParsePos *pp, GnmDependent const *dep) ...@@ -288,7 +283,7 @@ parse_pos_init_dep (GnmParsePos *pp, GnmDependent const *dep)
return pp; return pp;
} }
/* /**
* parse_pos_init_cell: * parse_pos_init_cell:
* @pp: The position to init. * @pp: The position to init.
* @cell: The cell * @cell: The cell
...@@ -306,10 +301,10 @@ parse_pos_init_cell (GnmParsePos *pp, GnmCell const *cell) ...@@ -306,10 +301,10 @@ parse_pos_init_cell (GnmParsePos *pp, GnmCell const *cell)
cell->pos.col, cell->pos.row); cell->pos.col, cell->pos.row);
} }
/* /**
* parse_pos_init_evalpos: * parse_pos_init_evalpos:
* @pp: The position to init. * @pp: The position to init.
* @ep: #GnmEvalPos * @pos: #GnmEvalPos
* *
* Returns: (skip) (transfer none): the initialized #GnmParsePos (@pp). * Returns: (skip) (transfer none): the initialized #GnmParsePos (@pp).
*/ */
...@@ -321,7 +316,7 @@ parse_pos_init_evalpos (GnmParsePos *pp, GnmEvalPos const *ep) ...@@ -321,7 +316,7 @@ parse_pos_init_evalpos (GnmParsePos *pp, GnmEvalPos const *ep)
return parse_pos_init (pp, NULL, ep->sheet, ep->eval.col, ep->eval.row); return parse_pos_init (pp, NULL, ep->sheet, ep->eval.col, ep->eval.row);
} }
/* /**
* parse_pos_init_editpos: * parse_pos_init_editpos:
* @pp: The position to init. * @pp: The position to init.
* @sv: sheet view * @sv: sheet view
...@@ -337,7 +332,7 @@ parse_pos_init_editpos (GnmParsePos *pp, SheetView const *sv) ...@@ -337,7 +332,7 @@ parse_pos_init_editpos (GnmParsePos *pp, SheetView const *sv)
sv->edit_pos.col, sv->edit_pos.row); sv->edit_pos.col, sv->edit_pos.row);
} }
/* /**
* parse_pos_init_sheet: * parse_pos_init_sheet:
* @pp: The position to init. * @pp: The position to init.
* @sheet: The sheet * @sheet: The sheet
...@@ -356,11 +351,9 @@ parse_pos_init_sheet (GnmParsePos *pp, Sheet const *sheet) ...@@ -356,11 +351,9 @@ parse_pos_init_sheet (GnmParsePos *pp, Sheet const *sheet)
static GnmCellRef * static GnmCellRef *
gnm_cellref_dup (GnmCellRef *ep) gnm_cellref_dup (GnmCellRef *cr)
{ {
GnmCellRef *res = g_new0 (GnmCellRef, 1); return g_memdup (cr, sizeof (*cr));
memcpy (res, ep, sizeof (GnmCellRef)); /* is this safe? */
return res;
} }
GType GType
......
...@@ -141,7 +141,7 @@ range_init_rangeref (GnmRange *range, GnmRangeRef const *rr) ...@@ -141,7 +141,7 @@ range_init_rangeref (GnmRange *range, GnmRangeRef const *rr)
* *
* Updates @r to be the same as the cell range of @v. * Updates @r to be the same as the cell range of @v.
* *
* Returns: (skip) (transfer none) (nullable): @r * Returns: (skip) (transfer none): @r
*/ */
GnmRange * GnmRange *
range_init_value (GnmRange *range, GnmValue const *v) range_init_value (GnmRange *range, GnmValue const *v)
...@@ -254,19 +254,13 @@ range_parse (GnmRange *r, char const *text, GnmSheetSize const *ss) ...@@ -254,19 +254,13 @@ range_parse (GnmRange *r, char const *text, GnmSheetSize const *ss)
* @ranges: (element-type GnmValue) (transfer full): a list of value ranges * @ranges: (element-type GnmValue) (transfer full): a list of value ranges
* to destroy. * to destroy.
* *
* Destroys a list of ranges returned from parse_cell_range_list * Destroys a list of ranges returned from parse_cell_range_list. Note:
* the element type here is GnmValue, not GnmRange.
**/ **/
void void
range_list_destroy (GSList *ranges) range_list_destroy (GSList *ranges)
{ {
GSList *l; g_slist_free_full (ranges, (GDestroyNotify)value_release);
for (l = ranges; l; l = l->next){
GnmValue *value = l->data;
value_release (value);
}
g_slist_free (ranges);
} }
...@@ -274,7 +268,7 @@ range_list_destroy (GSList *ranges) ...@@ -274,7 +268,7 @@ range_list_destroy (GSList *ranges)
* range_as_string: * range_as_string:
* @r: A #GnmRange * @r: A #GnmRange
* *
* Returns: (transfer none): a string repesentation of @src * Returns: (transfer none): a string representation of @src
**/ **/
char const * char const *
range_as_string (GnmRange const *r) range_as_string (GnmRange const *r)
...@@ -331,7 +325,7 @@ ranges_dump (GList *l, char const *txt) ...@@ -331,7 +325,7 @@ ranges_dump (GList *l, char const *txt)
* @a: * @a:
* @b: * @b:
* *
* Is @a totaly contained by @b * Is @a totally contained by @b
* *
* Return value: * Return value:
**/ **/
...@@ -360,7 +354,7 @@ range_contained (GnmRange const *a, GnmRange const *b) ...@@ -360,7 +354,7 @@ range_contained (GnmRange const *a, GnmRange const *b)
* *
* Splits soft into several chunks, and returns the still * Splits soft into several chunks, and returns the still
* overlapping remainder of soft as the first list item * overlapping remainder of soft as the first list item
* ( the central region in the pathalogical case ). * (the central region in the pathological case).
* *
* Returns: (element-type GnmRange) (transfer full): A list of fragments. * Returns: (element-type GnmRange) (transfer full): A list of fragments.
**/ **/
...@@ -373,7 +367,7 @@ range_split_ranges (GnmRange const *hard, GnmRange const *soft) ...@@ -373,7 +367,7 @@ range_split_ranges (GnmRange const *hard, GnmRange const *soft)
* Original Methodology ( approximately ) * Original Methodology ( approximately )
* a) Get a vertex: is it contained ? * a) Get a vertex: is it contained ?
* b) Yes: split so it isn't * b) Yes: split so it isn't
* c) Continue for all verticees. * c) Continue for all vertices.
* *
* NB. We prefer to have long columns at the expense * NB. We prefer to have long columns at the expense
* of long rows. * of long rows.
...@@ -528,22 +522,20 @@ range_split_ranges (GnmRange const *hard, GnmRange const *soft) ...@@ -528,22 +522,20 @@ range_split_ranges (GnmRange const *hard, GnmRange const *soft)
* Returns: (transfer full): A copy of the GnmRange. * Returns: (transfer full): A copy of the GnmRange.
**/ **/
GnmRange * GnmRange *
gnm_range_dup (GnmRange const *a) gnm_range_dup (GnmRange const *r)
{ {
GnmRange *r = g_new (GnmRange, 1); return g_memdup (r, sizeof (*r));
*r = *a;
return r;
} }
/** /**
* range_fragment: * range_fragment:
* @a: #GnmRange a * @a: First #GnmRange
* @b: #GnmRange b * @b: Second #GnmRange
* *
* Fragments the ranges into totaly non-overlapping regions, * Fragments the ranges into totally non-overlapping regions,
* *
* Returns: (element-type GnmRange) (transfer full): A list of fragmented * Returns: (element-type GnmRange) (transfer full): A list of fragmented
* ranges or at minimum simply a and b. * ranges or at minimum simply @a and @b.
**/ **/
GSList * GSList *
range_fragment (GnmRange const *a, GnmRange const *b) range_fragment (GnmRange const *a, GnmRange const *b)
...@@ -566,13 +558,13 @@ range_fragment (GnmRange const *a, GnmRange const *b) ...@@ -566,13 +558,13 @@ range_fragment (GnmRange const *a, GnmRange const *b)
/** /**
* range_intersection: * range_intersection:
* @r: intersection range * @r: intersection range
* @a: range a * @a: First #GnmRange
* @b: range b * @b: Second #GnmRange
* *
* This computes the intersection of two ranges; on a Venn * This computes the intersection of two ranges; on a Venn
* diagram this would be A (upside down U) B. * diagram this would be A (upside down U) B.
* If the ranges do not intersect, false is returned an the * If the ranges do not intersect, false is returned an the
* values of r are unpredictable. * values of @r are unpredictable.
* *
* NB. totally commutative * NB. totally commutative
* *
...@@ -627,7 +619,7 @@ range_normalize (GnmRange *src) ...@@ -627,7 +619,7 @@ range_normalize (GnmRange *src)
* diagram this would be A U B * diagram this would be A U B
* NB. totally commutative. Also, this may * NB. totally commutative. Also, this may
* include cells not in either range since * include cells not in either range since
* it must return a GnmRange. * it must return a #GnmRange.
* *
* Return value: the union * Return value: the union
**/ **/
...@@ -675,12 +667,13 @@ range_is_singleton (GnmRange const *r) ...@@ -675,12 +667,13 @@ range_is_singleton (GnmRange const *r)
* range_is_full: * range_is_full:
* @r: the range. * @r: the range.
* @sheet: the sheet in which @r lives * @sheet: the sheet in which @r lives
* @horiz: %TRUE to check for a horizontal full ref (_cols_ [0..MAX)) * @horiz: %TRUE to check for a horizontal full ref (all _cols_); %FALSE
* to check for a vertical full ref (all _rows_).
* *
* This determines whether @r completely spans a sheet * This determines whether @r completely spans a sheet in the dimension
* in the dimension specified by @horiz. * specified by @horiz.
* *
* Return value: %TRUE if it is infinite else %FALSE. * Returns: %TRUE if it is infinite, %FALSE otherwise.
**/ **/
gboolean gboolean
range_is_full (GnmRange const *r, Sheet const *sheet, gboolean horiz) range_is_full (GnmRange const *r, Sheet const *sheet, gboolean horiz)
...@@ -704,7 +697,7 @@ range_is_full (GnmRange const *r, Sheet const *sheet, gboolean horiz) ...@@ -704,7 +697,7 @@ range_is_full (GnmRange const *r, Sheet const *sheet, gboolean horiz)
* The idea here is that users may select a whole column or row when they * The idea here is that users may select a whole column or row when they
* really are only concerned with the extent of the sheet. * really are only concerned with the extent of the sheet.
* On the otehr hand, if users select any smaller region they probably * On the otehr hand, if users select any smaller region they probably
* intend to selec tjust that. * intend to select just that.
* *
* WARNING THIS IS EXPENSIVE! * WARNING THIS IS EXPENSIVE!
**/ **/
...@@ -724,6 +717,12 @@ range_clip_to_finite (GnmRange *range, Sheet *sheet) ...@@ -724,6 +717,12 @@ range_clip_to_finite (GnmRange *range, Sheet *sheet)
range->end.row = extent.end.row; range->end.row = extent.end.row;
} }
/**
* range_width:
* @r: #GnmRange
*
* Returns: width of @r.
*/
int int
range_width (GnmRange const *r) range_width (GnmRange const *r)
{ {
...@@ -731,6 +730,12 @@ range_width (GnmRange const *r) ...@@ -731,6 +730,12 @@ range_width (GnmRange const *r)
return ABS (r->end.col - r->start.col) + 1; return ABS (r->end.col - r->start.col) + 1;
} }
/**
* range_height:
* @r: #GnmRange
*
* Returns: height of @r.
*/
int int
range_height (GnmRange const *r) range_height (GnmRange const *r)
{ {
...@@ -745,9 +750,9 @@ range_height (GnmRange const *r) ...@@ -745,9 +750,9 @@ range_height (GnmRange const *r)
* @col_offset: * @col_offset:
* @row_offset: * @row_offset:
* *
* Translate the range and return TRUE if it is invalidated. * Translate the range and return %TRUE if it is invalidated.
* *
* return TRUE if the range is no longer valid. * Return: %TRUE if the range is no longer valid.
**/ **/
gboolean gboolean
range_translate (GnmRange *range, Sheet const *sheet, int col_offset, int row_offset) range_translate (GnmRange *range, Sheet const *sheet, int col_offset, int row_offset)
...@@ -1053,7 +1058,7 @@ undo_range_name (Sheet const *sheet, GnmRange const *r) ...@@ -1053,7 +1058,7 @@ undo_range_name (Sheet const *sheet, GnmRange const *r)
/* /*
* Create range list name, but don't exceed max_width. * Create range list name, but don't exceed max_width.
* Return TRUE iff the name is complete. * Returns: %TRUE iff the name is complete.
*/ */
static gboolean static gboolean
range_list_name_try (GString *names, char const *sheet, GSList const *ranges) range_list_name_try (GString *names, char const *sheet, GSList const *ranges)
...@@ -1095,9 +1100,9 @@ range_list_name_try (GString *names, char const *sheet, GSList const *ranges) ...@@ -1095,9 +1100,9 @@ range_list_name_try (GString *names, char const *sheet, GSList const *ranges)
/** /**
* undo_range_list_name: * undo_range_list_name:
* @sheet: * @sheet:
* @ranges: (element-type GnmRange): GSList containing GnmRange *'s * @ranges: (element-type GnmRange): list of ranges
* *
* Returns the range list name depending on the preference setting. * Returns: the range list name depending on the preference setting.
* (The result will be something like: "A1:C3, D4:E5"). The string will be * (The result will be something like: "A1:C3, D4:E5"). The string will be
* truncated to max_descriptor_width. * truncated to max_descriptor_width.
**/ **/
...@@ -1223,12 +1228,11 @@ global_range_list_foreach (GSList *gr_list, GnmEvalPos const *ep, ...@@ -1223,12 +1228,11 @@ global_range_list_foreach (GSList *gr_list, GnmEvalPos const *ep,
/** /**
* global_range_contained: * global_range_contained:
* @sheet: The calling context #Sheet for references with sheet==NULL * @sheet: The calling context #Sheet for references without sheet.
* @a: * @a: A #GnmValue representing a range
* @b: * @b: A #GnmValue representing a range
* *
* return true if a is contained in b * Returns: %TRUE if @a is contained in @b. We do not handle 3d ranges
* we do not handle 3d ranges
**/ **/
gboolean gboolean
global_range_contained (Sheet const *sheet, GnmValue const *a, GnmValue const *b) global_range_contained (Sheet const *sheet, GnmValue const *a, GnmValue const *b)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment