From 7b24d9fcc3d6f82195a5e7a95af9f60a833cf79f Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 10 Dec 2001 20:29:41 +0000 Subject: [PATCH] 2001-12-10 Michael Meeks * cspi/spi_text.c: audit for exception handling, tolerating NULL object references safely etc. * cspi/spi_value.c: ditto. * cspi/spi_table.c (AccessibleTable_getSummary), (AccessibleTable_getAccessibleAt), (AccessibleTable_getRowHeader), (AccessibleTable_getColumnHeader), (AccessibleTable_getCaption): fix bugs hidden by incorrect casts. (long_seq_to_array): impl. (AccessibleTable_getSelectedRows), (AccessibleTable_getSelectedColumns): use it. git-svn-id: http://svn.gnome.org/svn/at-spi/trunk@163 e2bd861d-eb25-0410-b326-f6ed22b6b98c --- ChangeLog | 17 +++ cspi/spi_accessible.c | 2 - cspi/spi_action.c | 2 - cspi/spi_component.c | 2 - cspi/spi_hyperlink.c | 2 - cspi/spi_table.c | 309 ++++++++++++++++++++++++++++++++------------------ cspi/spi_text.c | 256 ++++++++++++++++++++++++++++++----------- cspi/spi_value.c | 44 ++++--- 8 files changed, 437 insertions(+), 197 deletions(-) diff --git a/ChangeLog b/ChangeLog index df18771..f05476a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2001-12-10 Michael Meeks + + * cspi/spi_text.c: audit for exception handling, + tolerating NULL object references safely etc. + + * cspi/spi_value.c: ditto. + + * cspi/spi_table.c (AccessibleTable_getSummary), + (AccessibleTable_getAccessibleAt), + (AccessibleTable_getRowHeader), + (AccessibleTable_getColumnHeader), + (AccessibleTable_getCaption): fix bugs hidden by + incorrect casts. + (long_seq_to_array): impl. + (AccessibleTable_getSelectedRows), + (AccessibleTable_getSelectedColumns): use it. + 2001-12-10 Bill Haneman * TODO: diff --git a/cspi/spi_accessible.c b/cspi/spi_accessible.c index 2f753da..78db9f6 100644 --- a/cspi/spi_accessible.c +++ b/cspi/spi_accessible.c @@ -107,7 +107,6 @@ AccessibleRole_getName (AccessibleRole role) * @obj: a pointer to the #Accessible object on which to operate. * * Increment the reference count for an #Accessible object. - * **/ void Accessible_ref (Accessible *obj) @@ -120,7 +119,6 @@ Accessible_ref (Accessible *obj) * @obj: a pointer to the #Accessible object on which to operate. * * Decrement the reference count for an #Accessible object. - * **/ void Accessible_unref (Accessible *obj) diff --git a/cspi/spi_action.c b/cspi/spi_action.c index ab50427..4a5fa29 100644 --- a/cspi/spi_action.c +++ b/cspi/spi_action.c @@ -5,7 +5,6 @@ * @obj: a pointer to the #AccessibleAction on which to operate. * * Increment the reference count for an #AccessibleAction. - * **/ void AccessibleAction_ref (AccessibleAction *obj) @@ -18,7 +17,6 @@ AccessibleAction_ref (AccessibleAction *obj) * @obj: a pointer to the #AccessibleAction on which to operate. * * Decrement the reference count for an #AccessibleAction. - * **/ void AccessibleAction_unref (AccessibleAction *obj) diff --git a/cspi/spi_component.c b/cspi/spi_component.c index 52ef98e..8e746e4 100644 --- a/cspi/spi_component.c +++ b/cspi/spi_component.c @@ -11,7 +11,6 @@ * @obj: a pointer to an object implementing #AccessibleComponent on which to operate. * * Increment the reference count for an #AccessibleComponent. - * **/ void AccessibleComponent_ref (AccessibleComponent *obj) @@ -24,7 +23,6 @@ AccessibleComponent_ref (AccessibleComponent *obj) * @obj: a pointer to the object implementing #AccessibleComponent on which to operate. * * Decrement the reference count for an #AccessibleComponent. - * **/ void AccessibleComponent_unref (AccessibleComponent *obj) diff --git a/cspi/spi_hyperlink.c b/cspi/spi_hyperlink.c index 89bb776..8760fcc 100644 --- a/cspi/spi_hyperlink.c +++ b/cspi/spi_hyperlink.c @@ -115,8 +115,6 @@ AccessibleHyperlink_getIndexRange (AccessibleHyperlink *obj, long int *startIndex, long int *endIndex) { - long retval; - cspi_return_if_fail (obj != NULL); *startIndex = (long) diff --git a/cspi/spi_table.c b/cspi/spi_table.c index 6d525d6..db61c3d 100644 --- a/cspi/spi_table.c +++ b/cspi/spi_table.c @@ -36,8 +36,8 @@ AccessibleTable_unref (AccessibleTable *obj) Accessible * AccessibleTable_getCaption (AccessibleTable *obj) { - return (Accessible *) - Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ()); + return cspi_object_add ( + Accessibility_Table__get_caption (CSPI_OBJREF (obj), cspi_ev ())); } /** @@ -48,13 +48,12 @@ AccessibleTable_getCaption (AccessibleTable *obj) * * Returns: an #Accessible object that serves as the table's summary (often a * reduced #AccessibleTable). - * **/ Accessible * AccessibleTable_getSummary (AccessibleTable *obj) { - return (Accessible *) - Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ()); + return cspi_object_add ( + Accessibility_Table__get_summary (CSPI_OBJREF (obj), cspi_ev ())); } /** @@ -66,13 +65,21 @@ AccessibleTable_getSummary (AccessibleTable *obj) * of rows that may be outside of the current scrolling window or viewport. * * Returns: a #long integer indicating the number of rows in the table. - * **/ long AccessibleTable_getNRows (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nRows (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("getNRows", -1); + + return retval; + } /** @@ -84,13 +91,20 @@ AccessibleTable_getNRows (AccessibleTable *obj) * of columns that may be outside of the current scrolling window or viewport. * * Returns: a #long integer indicating the number of columns in the table. - * **/ long AccessibleTable_getNColumns (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nColumns (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("", -1); + + return retval; } /** @@ -104,16 +118,16 @@ AccessibleTable_getNColumns (AccessibleTable *obj) * use #Accessible_getAccessibleAtPoint (). * * Returns: an #Accessible object representing the specified table cell. - * **/ Accessible * AccessibleTable_getAccessibleAt (AccessibleTable *obj, long int row, long int column) { - return (Accessible *) - Accessibility_Table_getAccessibleAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); + return cspi_object_add ( + Accessibility_Table_getAccessibleAt ( + CSPI_OBJREF (obj), (CORBA_long) row, + (CORBA_long) column, cspi_ev ())); } /** @@ -129,19 +143,25 @@ AccessibleTable_getAccessibleAt (AccessibleTable *obj, * * Returns: a long integer which serves as the index of a specified cell in the * table, in a form usable by #Accessible_getChildAtIndex(). - * **/ long AccessibleTable_getIndexAt (AccessibleTable *obj, long int row, long int column) { - return (long) - Accessibility_Table_getIndexAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getIndexAt ( + CSPI_OBJREF (obj), (CORBA_long) row, + (CORBA_long) column, cspi_ev ()); + + cspi_return_val_if_ev ("getIndexAt", -1); + + return retval; +} /** * AccessibleTable_getRowAtIndex: @@ -154,18 +174,23 @@ AccessibleTable_getIndexAt (AccessibleTable *obj, * * Returns: a long integer indicating the first row spanned by the child of a * table, at the specified 1-D (zero-offset) @index. - * **/ long AccessibleTable_getRowAtIndex (AccessibleTable *obj, long index) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table_getRowAtIndex (CSPI_OBJREF (obj), (CORBA_long) index, cspi_ev ()); -} - + + cspi_return_val_if_ev ("", -1); + return retval; +} /** * AccessibleTable_getColumnAtIndex: @@ -178,18 +203,23 @@ AccessibleTable_getRowAtIndex (AccessibleTable *obj, * * Returns: a long integer indicating the first column spanned by the child of a * table, at the specified 1-D (zero-offset) @index. - * **/ long AccessibleTable_getColumnAtIndex (AccessibleTable *obj, long index) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table_getColumnAtIndex (CSPI_OBJREF (obj), (CORBA_long) index, cspi_ev ()); -} - + + cspi_return_val_if_ev ("getColumnAtIndex", -1); + return retval; +} /** * AccessibleTable_getRowDescription: @@ -200,18 +230,23 @@ AccessibleTable_getColumnAtIndex (AccessibleTable *obj, * AccessibleTable_getRowHeader, which returns an #Accessible. * * Returns: a UTF-8 string describing the specified table row, if available. - * **/ char * AccessibleTable_getRowDescription (AccessibleTable *obj, - long int row) + long int row) { - return (char *) + char *retval; + + cspi_return_val_if_fail (obj != NULL, NULL); + + retval = Accessibility_Table_getRowDescription (CSPI_OBJREF (obj), (CORBA_long) row, cspi_ev ()); -} - + + cspi_return_val_if_ev ("getRowDescription", NULL); + return retval; +} /** * AccessibleTable_getColumnDescription: @@ -222,18 +257,23 @@ AccessibleTable_getRowDescription (AccessibleTable *obj, * AccessibleTable_getColumnHeader, which returns an #Accessible. * * Returns: a UTF-8 string describing the specified table column, if available. - * **/ char * AccessibleTable_getColumnDescription (AccessibleTable *obj, - long int column) + long int column) { - return (char *) + char *retval; + + cspi_return_val_if_fail (obj != NULL, NULL); + + retval = Accessibility_Table_getColumnDescription (CSPI_OBJREF (obj), (CORBA_long) column, cspi_ev ()); -} + cspi_return_val_if_ev ("getColumnDescription", NULL); + return retval; +} /** * AccessibleTable_getRowExtentAt: @@ -245,19 +285,25 @@ AccessibleTable_getColumnDescription (AccessibleTable *obj, * (some tables can have cells which span multiple rows and/or columns). * * Returns: a long integer indicating the number of rows spanned by the specified cell. - * **/ long AccessibleTable_getRowExtentAt (AccessibleTable *obj, - long int row, - long int column) + long int row, + long int column) { - return (long) - Accessibility_Table_getRowExtentAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getRowExtentAt ( + CSPI_OBJREF (obj), (CORBA_long) row, + (CORBA_long) column, cspi_ev ()); + + cspi_return_val_if_ev ("getRowExtentAt", -1); + return retval; +} /** * AccessibleTable_getColumnExtentAt: @@ -269,18 +315,25 @@ AccessibleTable_getRowExtentAt (AccessibleTable *obj, * (some tables can have cells which span multiple rows and/or columns). * * Returns: a long integer indicating the number of columns spanned by the specified cell. - * **/ long AccessibleTable_getColumnExtentAt (AccessibleTable *obj, - long int row, - long int column) + long int row, + long int column) { - return (long) - Accessibility_Table_getColumnExtentAt (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); -} + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + retval = + Accessibility_Table_getColumnExtentAt ( + CSPI_OBJREF (obj), (CORBA_long) row, + (CORBA_long) column, cspi_ev ()); + + cspi_return_val_if_ev ("getColumnExtentAt", -1); + + return retval; +} /** * AccessibleTable_getRowHeader: @@ -291,19 +344,16 @@ AccessibleTable_getColumnExtentAt (AccessibleTable *obj, * AccessibleTable_getRowDescription, which returns a string. * * Returns: a #Accessible representatin of the specified table row, if available. - * **/ Accessible * AccessibleTable_getRowHeader (AccessibleTable *obj, - long int row) + long int row) { - return (Accessible *) + return cspi_object_add ( Accessibility_Table_getRowHeader (CSPI_OBJREF (obj), - (CORBA_long) row, cspi_ev ()); + (CORBA_long) row, cspi_ev ())); } - - /** * AccessibleTable_getColumnHeader: * @obj: a pointer to the #AccessibleTable implementor on which to operate. @@ -313,18 +363,16 @@ AccessibleTable_getRowHeader (AccessibleTable *obj, * AccessibleTable_getColumnDescription, which returns a string. * * Returns: a #Accessible representatin of the specified table column, if available. - * **/ Accessible * AccessibleTable_getColumnHeader (AccessibleTable *obj, long int column) { - return (Accessible *) + return cspi_object_add ( Accessibility_Table_getColumnHeader (CSPI_OBJREF (obj), - (CORBA_long) column, cspi_ev ()); + (CORBA_long) column, cspi_ev ())); } - /** * AccessibleTable_getNSelectedRows: * @obj: a pointer to the #AccessibleTable implementor on which to operate. @@ -337,11 +385,42 @@ AccessibleTable_getColumnHeader (AccessibleTable *obj, long AccessibleTable_getNSelectedRows (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); + + cspi_return_val_if_ev ("getNSelectedRows", -1); + + return retval; } +static long +long_seq_to_array (Accessibility_LongSeq *seq, long int **array) +{ + long *j, length, i; + + if (!cspi_check_ev ("getSelectionItems")) + { + *array = NULL; + return 0; + } + + length = seq->_length; + + j = *array = g_new (long, length); + for (i = 0; i < length; i++) + { + j[i] = seq->_buffer [i]; + } + + CORBA_free (seq); + + return length; +} /** * AccessibleTable_getSelectedRows: @@ -355,26 +434,18 @@ AccessibleTable_getNSelectedRows (AccessibleTable *obj) **/ long AccessibleTable_getSelectedRows (AccessibleTable *obj, - long int **selectedRows) + long int **selectedRows) { - Accessibility_LongSeq *rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); - CORBA_long *i; - long *j; - long length; - - i = rows->_buffer; - length = (long) rows->_length; - j = *selectedRows = (long *) malloc (sizeof(long)*length); - - while (length--) - *j++ = (CORBA_long) (*i++); - - length = rows->_length; - CORBA_free (rows); - return length; -} + Accessibility_LongSeq *rows; + *selectedRows = NULL; + cspi_return_val_if_fail (obj != NULL, 0); + + rows = Accessibility_Table_getSelectedRows (CSPI_OBJREF (obj), cspi_ev ()); + + return long_seq_to_array (rows, selectedRows); +} /** * AccessibleTable_getNSelectedColumns: @@ -388,10 +459,17 @@ AccessibleTable_getSelectedRows (AccessibleTable *obj, long AccessibleTable_getNSelectedColumns (AccessibleTable *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Table__get_nSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); -} + + cspi_return_val_if_ev ("getNSelectedColumns", -1); + return retval; +} /** * AccessibleTable_getSelectedColumns: @@ -406,25 +484,18 @@ AccessibleTable_getNSelectedColumns (AccessibleTable *obj) **/ long AccessibleTable_getSelectedColumns (AccessibleTable *obj, - long int **selectedColumns) + long int **selectedColumns) { - Accessibility_LongSeq *columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); - CORBA_long *i; - long *j; - long length; - - i = columns->_buffer; - length = (long) columns->_length; - j = *selectedColumns = (long *) malloc (sizeof(long)*length); - - while (length--) - *j++ = (CORBA_long) (*i++); - - length = columns->_length; - CORBA_free (columns); - return length; -} + Accessibility_LongSeq *columns; + + *selectedColumns = NULL; + + cspi_return_val_if_fail (obj != NULL, 0); + columns = Accessibility_Table_getSelectedColumns (CSPI_OBJREF (obj), cspi_ev ()); + + return long_seq_to_array (columns, selectedColumns); +} /** * AccessibleTable_isRowSelected: @@ -434,18 +505,23 @@ AccessibleTable_getSelectedColumns (AccessibleTable *obj, * Determine whether a table row is selected. Not all tables support row selection. * * Returns: #TRUE if the specified row is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isRowSelected (AccessibleTable *obj, - long int row) + long int row) { - return (SPIBoolean) + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = Accessibility_Table_isRowSelected (CSPI_OBJREF (obj), (CORBA_long) row, cspi_ev ()); -} + cspi_return_val_if_ev ("isRowSelected", FALSE); + return retval; +} /** * AccessibleTable_isColumnSelected: @@ -456,18 +532,23 @@ AccessibleTable_isRowSelected (AccessibleTable *obj, * Not all tables support column selection. * * Returns: #TRUE if the specified column is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isColumnSelected (AccessibleTable *obj, - long int column) + long int column) { - return (SPIBoolean) - Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj), - (CORBA_long) column, cspi_ev ()); -} + SPIBoolean retval; + cspi_return_val_if_fail (obj != NULL, FALSE); + retval = + Accessibility_Table_isColumnSelected (CSPI_OBJREF (obj), + (CORBA_long) column, cspi_ev ()); + + cspi_return_val_if_ev ("isColumnSelected", FALSE); + + return retval; +} /** * AccessibleTable_isSelected: @@ -478,15 +559,23 @@ AccessibleTable_isColumnSelected (AccessibleTable *obj, * Determine whether the cell at a specific row and column is selected. * * Returns: #TRUE if the specified cell is currently selected, #FALSE if not. - * **/ SPIBoolean AccessibleTable_isSelected (AccessibleTable *obj, long int row, long int column) { - return (SPIBoolean) - Accessibility_Table_isSelected (CSPI_OBJREF (obj), - (CORBA_long) row, (CORBA_long) column, cspi_ev ()); + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Table_isSelected (CSPI_OBJREF (obj), + (CORBA_long) row, + (CORBA_long) column, cspi_ev ()); + + cspi_return_val_if_ev ("isSelected", FALSE); + + return retval; } diff --git a/cspi/spi_text.c b/cspi/spi_text.c index a49adbd..558b38f 100644 --- a/cspi/spi_text.c +++ b/cspi/spi_text.c @@ -5,7 +5,6 @@ * @obj: a pointer to the #AccessibleText object on which to operate. * * Increment the reference count for an #AccessibleText object. - * **/ void AccessibleText_ref (AccessibleText *obj) @@ -18,7 +17,6 @@ AccessibleText_ref (AccessibleText *obj) * @obj: a pointer to the #Accessible object on which to operate. * * Decrement the reference count for an #AccessibleText object. - * **/ void AccessibleText_unref (AccessibleText *obj) @@ -34,7 +32,6 @@ AccessibleText_unref (AccessibleText *obj) * * Returns: a long integer indicating the total number of * characters in the #AccessibleText object. - * **/ long AccessibleText_getCharacterCount (AccessibleText *obj) @@ -46,7 +43,7 @@ AccessibleText_getCharacterCount (AccessibleText *obj) retval = (long) Accessibility_Text__get_characterCount (CSPI_OBJREF (obj), cspi_ev ()); - cspi_return_val_if_ev ("_getCharacterCount", -1); + cspi_return_val_if_ev ("getCharacterCount", -1); return retval; } @@ -63,16 +60,25 @@ AccessibleText_getCharacterCount (AccessibleText *obj) * * Returns: a text string containing characters from @startOffset * to @endOffset-1, inclusive, encoded as UTF-8. - * **/ char * AccessibleText_getText (AccessibleText *obj, long int startOffset, long int endOffset) { - return (char *) + char *retval; + + cspi_return_val_if_fail (obj != NULL, NULL); + + retval = Accessibility_Text_getText (CSPI_OBJREF (obj), - (CORBA_long) startOffset, (CORBA_long) endOffset, cspi_ev ()); + (CORBA_long) startOffset, + (CORBA_long) endOffset, + cspi_ev ()); + + cspi_return_val_if_ev ("getText", NULL); + + return retval; } /** @@ -82,15 +88,21 @@ AccessibleText_getText (AccessibleText *obj, * Get the current offset of the text caret in an #AccessibleText object. * * Returns: a long integer indicating the current position of the text caret. - * **/ long AccessibleText_getCaretOffset (AccessibleText *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Text__get_caretOffset (CSPI_OBJREF (obj), cspi_ev ()); -} + cspi_return_val_if_ev ("getCaretOffset", -1); + + return retval; +} /** * AccessibleText_getAttributes: @@ -106,7 +118,6 @@ AccessibleText_getCaretOffset (AccessibleText *obj) * Returns: a text string describing the attributes occurring within the * attribute run containing @offset, encoded as UTF-8 and * delimited by ':' - * **/ char * AccessibleText_getAttributes (AccessibleText *obj, @@ -116,18 +127,32 @@ AccessibleText_getAttributes (AccessibleText *obj, { CORBA_long retStartOffset, retEndOffset; char *retval; + + if (obj == NULL) + { + *startOffset = *endOffset = 0; + return NULL; + } + retval = (char *) Accessibility_Text_getAttributes (CSPI_OBJREF (obj), (CORBA_long) offset, &retStartOffset, &retEndOffset, cspi_ev ()); - *startOffset = (long) retStartOffset; - *endOffset = (long) retEndOffset; - return retval; -} + if (!cspi_check_ev ("getAttributes")) + { + *startOffset = *endOffset = 0; + } + else + { + *startOffset = retStartOffset; + *endOffset = retEndOffset; + } + return retval; +} /** * AccessibleText_setCaretOffset: @@ -137,15 +162,22 @@ AccessibleText_getAttributes (AccessibleText *obj, * Set the text caret position for an #AccessibleText object. * * Returns: #TRUE if successful, #FALSE otherwise. - * **/ SPIBoolean AccessibleText_setCaretOffset (AccessibleText *obj, long int newOffset) { - return (SPIBoolean) + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = Accessibility_Text_setCaretOffset (CSPI_OBJREF (obj), (CORBA_long) newOffset, cspi_ev ()); + + cspi_return_val_if_ev ("setCaretOffset", FALSE); + + return retval; } /** @@ -168,7 +200,6 @@ AccessibleText_setCaretOffset (AccessibleText *obj, * Returns: a UTF-8 string representing the delimited text, both of whose * delimiting boundaries are before the current offset, or * an empty string if no such text exists. - * **/ char * AccessibleText_getTextBeforeOffset (AccessibleText *obj, @@ -209,7 +240,6 @@ AccessibleText_getTextBeforeOffset (AccessibleText *obj, * Returns: a UTF-8 string representing the delimited text, whose * delimiting boundaries bracket the current offset, or * an empty string if no such text exists. - * **/ char * AccessibleText_getTextAtOffset (AccessibleText *obj, @@ -219,22 +249,37 @@ AccessibleText_getTextAtOffset (AccessibleText *obj, { CORBA_long corbaStartOffset; CORBA_long corbaEndOffset; - char *retval = ""; + char *retval; + + if (obj == NULL) + { + *startOffset = *endOffset = 0; + return NULL; + } + retval = Accessibility_Text_getTextAtOffset (CSPI_OBJREF (obj), (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type, &corbaStartOffset, &corbaEndOffset, cspi_ev ()); - *startOffset = (long) corbaStartOffset; - *endOffset = (long) corbaEndOffset; + + if (!cspi_check_ev ("getTextAtOffset")) + { + *startOffset = *endOffset = 0; + retval = NULL; + } + else + { + *startOffset = corbaStartOffset; + *endOffset = corbaEndOffset; + } #ifdef CSPI_DEBUG fprintf (stderr, "text offsets %ld to %ld\n", *startOffset, *endOffset); #endif return retval; } - /** * AccessibleText_getTextAfterOffset: * @obj: a pointer to the #AccessibleText object on which to operate. @@ -255,7 +300,6 @@ AccessibleText_getTextAtOffset (AccessibleText *obj, * Returns: a UTF-8 string representing the delimited text, both of whose * delimiting boundaries are after or inclusive of the current * offset, or an empty string if no such text exists. - * **/ char * AccessibleText_getTextAfterOffset (AccessibleText *obj, @@ -265,17 +309,31 @@ AccessibleText_getTextAfterOffset (AccessibleText *obj, { char *retval; CORBA_long retStartOffset, retEndOffset; + + if (obj == NULL) + { + *startOffset = *endOffset = 0; + return NULL; + } + retval = (char *) Accessibility_Text_getTextAfterOffset (CSPI_OBJREF (obj), (CORBA_long) offset, (Accessibility_TEXT_BOUNDARY_TYPE) type, &retStartOffset, &retEndOffset, cspi_ev ()); - *startOffset = (long) retStartOffset; - *endOffset = (long) retEndOffset; - return retval; -} + if (!cspi_check_ev ("getTextAfterOffset")) + { + *startOffset = *endOffset = 0; + } + else + { + *startOffset = retStartOffset; + *endOffset = retEndOffset; + } + return retval; +} /** * AccessibleText_getCharacterAtOffset: @@ -289,15 +347,23 @@ AccessibleText_getTextAfterOffset (AccessibleText *obj, * UCS-4 unicode code point of the given character, or * 0xFFFFFFFF if the character in question cannot be represented * in the UCS-4 encoding. - * **/ unsigned long AccessibleText_getCharacterAtOffset (AccessibleText *obj, long int offset) { - return (unsigned long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Text_getCharacterAtOffset (CSPI_OBJREF (obj), - (CORBA_long) offset, cspi_ev ()); + (CORBA_long) offset, + cspi_ev ()); + + cspi_return_val_if_ev ("getCharacterAtOffset", -1); + + return retval; } /** @@ -318,7 +384,6 @@ AccessibleText_getCharacterAtOffset (AccessibleText *obj, * * Get the bounding box containing the glyph representing * the character at a particular text offset. - * **/ void AccessibleText_getCharacterExtents (AccessibleText *obj, @@ -330,6 +395,14 @@ AccessibleText_getCharacterExtents (AccessibleText *obj, AccessibleCoordType type) { CORBA_long retX, retY, retWidth, retHeight; + + if (obj == NULL) + { + *x = *y = 0; + *width = *height = 0; + return; + } + Accessibility_Text_getCharacterExtents (CSPI_OBJREF (obj), (CORBA_long) offset, &retX, @@ -337,12 +410,20 @@ AccessibleText_getCharacterExtents (AccessibleText *obj, &retWidth, &retHeight, (CORBA_short) type, cspi_ev ()); - *x = (long) retX; - *y = (long) retY; - *width = (long) retWidth; - *height = (long) retHeight; -} + if (!cspi_check_ev ("getCharacterExtents")) + { + *x = *y = 0; + *width = *height = 0; + } + else + { + *x = retX; + *y = retY; + *width = retWidth; + *height = retHeight; + } +} /** * AccessibleText_getOffsetAtPoint: @@ -364,11 +445,20 @@ AccessibleText_getOffsetAtPoint (AccessibleText *obj, long int y, AccessibleCoordType type) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Text_getOffsetAtPoint (CSPI_OBJREF (obj), - (CORBA_long) x, (CORBA_long) y, (CORBA_short) type, cspi_ev ()); -} + (CORBA_long) x, + (CORBA_long) y, + (CORBA_short) type, cspi_ev ()); + cspi_return_val_if_ev ("getOffsetAtPoint", -1); + + return retval; +} /** * AccessibleText_getNSelections: @@ -380,16 +470,21 @@ AccessibleText_getOffsetAtPoint (AccessibleText *obj, * Returns: a long integer indicating the current * number of non-contiguous text selections active * within an #AccessibleText object. - * **/ long AccessibleText_getNSelections (AccessibleText *obj) { - return (long) + long retval; + + cspi_return_val_if_fail (obj != NULL, -1); + + retval = Accessibility_Text_getNSelections (CSPI_OBJREF (obj), cspi_ev ()); -} + cspi_return_val_if_ev ("getNSelections", -1); + return retval; +} /** * AccessibleText_getSelection: @@ -402,7 +497,6 @@ AccessibleText_getNSelections (AccessibleText *obj) * * Get the bounds of the @selectionNum-th active text selection for an * #AccessibleText object. - * **/ void AccessibleText_getSelection (AccessibleText *obj, @@ -411,16 +505,29 @@ AccessibleText_getSelection (AccessibleText *obj, long int *endOffset) { CORBA_long retStartOffset, retEndOffset; + + if (obj == NULL) + { + *endOffset = *startOffset = -1; + return; + } + Accessibility_Text_getSelection (CSPI_OBJREF (obj), (CORBA_long) selectionNum, - &retStartOffset, &retEndOffset, cspi_ev ()); - - *startOffset = (long) retStartOffset; - *endOffset = (long) retEndOffset; + &retStartOffset, &retEndOffset, + cspi_ev ()); + + if (!cspi_check_ev ("getSelection")) + { + *startOffset = *endOffset = 0; + } + else + { + *startOffset = retStartOffset; + *endOffset = retEndOffset; + } } - - /** * AccessibleText_addSelection: * @obj: a pointer to the #AccessibleText object on which to operate. @@ -430,18 +537,24 @@ AccessibleText_getSelection (AccessibleText *obj, * Select some text (add a text selection) in an #AccessibleText object. * * Returns: #TRUE if successful, #FALSE otherwise. - * **/ SPIBoolean AccessibleText_addSelection (AccessibleText *obj, long int startOffset, long int endOffset) { - return (SPIBoolean) - Accessibility_Text_addSelection (CSPI_OBJREF (obj), - (CORBA_long) startOffset, (CORBA_long) endOffset, - cspi_ev ()); -} + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + retval = + Accessibility_Text_addSelection ( + CSPI_OBJREF (obj), (CORBA_long) startOffset, + (CORBA_long) endOffset, cspi_ev ()); + + cspi_return_val_if_ev ("addSelection", FALSE); + + return retval; +} /** * AccessibleText_removeSelection: @@ -452,15 +565,22 @@ AccessibleText_addSelection (AccessibleText *obj, * De-select a text selection. * * Returns: #TRUE if successful, #FALSE otherwise. - * **/ SPIBoolean AccessibleText_removeSelection (AccessibleText *obj, long int selectionNum) { - return (SPIBoolean) - Accessibility_Text_removeSelection (CSPI_OBJREF (obj), - (CORBA_long) selectionNum, cspi_ev ()); + SPIBoolean retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + retval = + Accessibility_Text_removeSelection ( + CSPI_OBJREF (obj), (CORBA_long) selectionNum, cspi_ev ()); + + cspi_return_val_if_ev ("removeSelection", FALSE); + + return retval; } /** @@ -474,7 +594,6 @@ AccessibleText_removeSelection (AccessibleText *obj, * Change the bounds of an existing #AccessibleText text selection. * * Returns: #TRUE if successful, #FALSE otherwise. - * **/ SPIBoolean AccessibleText_setSelection (AccessibleText *obj, @@ -482,11 +601,16 @@ AccessibleText_setSelection (AccessibleText *obj, long int startOffset, long int endOffset) { - return (SPIBoolean) - Accessibility_Text_setSelection (CSPI_OBJREF (obj), - (CORBA_long) selectionNum, - (CORBA_long) startOffset, - (CORBA_long) endOffset, cspi_ev ()); + cspi_return_val_if_fail (obj != NULL, FALSE); + + Accessibility_Text_setSelection (CSPI_OBJREF (obj), + (CORBA_long) selectionNum, + (CORBA_long) startOffset, + (CORBA_long) endOffset, cspi_ev ()); + + cspi_return_val_if_ev ("setSelection", FALSE); + + return TRUE; } diff --git a/cspi/spi_value.c b/cspi/spi_value.c index 6e299b3..bfc5545 100644 --- a/cspi/spi_value.c +++ b/cspi/spi_value.c @@ -5,7 +5,6 @@ * @obj: a pointer to the #AccessibleValue implementor on which to operate. * * Increment the reference count for an #AccessibleValue object. - * **/ void AccessibleValue_ref (AccessibleValue *obj) @@ -18,7 +17,6 @@ AccessibleValue_ref (AccessibleValue *obj) * @obj: a pointer to the #AccessibleValue implementor on which to operate. * * Decrement the reference count for an #AccessibleValue object. - * **/ void AccessibleValue_unref (AccessibleValue *obj) @@ -38,11 +36,17 @@ AccessibleValue_unref (AccessibleValue *obj) float AccessibleValue_getMinimumValue (AccessibleValue *obj) { - return (float) + float retval; + + cspi_return_val_if_fail (obj != NULL, 0.0); + + retval = Accessibility_Value__get_minimumValue (CSPI_OBJREF (obj), cspi_ev ()); -} + cspi_return_val_if_ev ("getMinimumValue", 0.0); + return retval; +} /** * AccessibleValue_getCurrentValue: @@ -51,16 +55,21 @@ AccessibleValue_getMinimumValue (AccessibleValue *obj) * Get the current value for an #AccessibleValue. * * Returns: the current value for this object. - * **/ float AccessibleValue_getCurrentValue (AccessibleValue *obj) { - return (float) + float retval; + + cspi_return_val_if_fail (obj != NULL, 0.0); + + retval = Accessibility_Value__get_currentValue (CSPI_OBJREF (obj), cspi_ev ()); -} + cspi_return_val_if_ev ("getCurrentValue", 0.0); + return retval; +} /** * AccessibleValue_getMaximumValue: @@ -69,16 +78,21 @@ AccessibleValue_getCurrentValue (AccessibleValue *obj) * Get the maximum allowed value for an #AccessibleValue. * * Returns: the maximum allowed value for this object. - * **/ float AccessibleValue_getMaximumValue (AccessibleValue *obj) { - return (float) + float retval; + + cspi_return_val_if_fail (obj != NULL, 0.0); + + retval = Accessibility_Value__get_maximumValue (CSPI_OBJREF (obj), cspi_ev ()); -} + cspi_return_val_if_ev ("getMaximumValue", 0.0); + return retval; +} /** * AccessibleValue_setCurrentValue: @@ -89,14 +103,18 @@ AccessibleValue_getMaximumValue (AccessibleValue *obj) * * Returns: #TRUE if the value could be assigned the specified value, * #FALSE otherwise. - * **/ SPIBoolean AccessibleValue_setCurrentValue (AccessibleValue *obj, float newValue) { - Accessibility_Value__set_currentValue (CSPI_OBJREF (obj), - (CORBA_float) newValue, cspi_ev ()); + cspi_return_val_if_fail (obj != NULL, FALSE); + + Accessibility_Value__set_currentValue ( + CSPI_OBJREF (obj), (CORBA_float) newValue, cspi_ev ()); + + cspi_return_val_if_ev ("setCurrentValue", FALSE); + return TRUE; } -- 2.7.4