maiWidget = new MaiWidget(aSelection);
maiWidget = MaiWidget::CreateAndCache(aSelection);
static void interfaceInitCB(AtkSelectionIface *aIface);static gboolean addSelectionCB(AtkSelection *aSelection,                               gint i);static gboolean clearSelectionCB(AtkSelection *aSelection);static AtkObject *refSelectionCB(AtkSelection *aSelection,                                 gint i);static gint getSelectionCountCB(AtkSelection *aSelection);static gboolean isChildSelectedCB(AtkSelection *aSelection,                                  gint i);static gboolean removeSelectionCB(AtkSelection *aSelection,                                  gint i);static gboolean selectAllSelectionCB(AtkSelection *aSelection);G_END_DECLSMaiInterfaceSelection::MaiInterfaceSelection(MaiWidget *aMaiWidget):    MaiInterface(aMaiWidget){}MaiInterfaceSelection::~MaiInterfaceSelection(){}MaiInterfaceTypeMaiInterfaceSelection::GetType(){    return MAI_INTERFACE_SELECTION;}const GInterfaceInfo *MaiInterfaceSelection::GetInterfaceInfo(){    static const GInterfaceInfo atk_if_selection_info = {        (GInterfaceInitFunc) interfaceInitCB,        (GInterfaceFinalizeFunc) NULL,        NULL    };    return &atk_if_selection_info;}#define MAI_IFACE_RETURN_VAL_IF_FAIL(accessIface, retvalue) \    nsIAccessible *tmpAccess = GetNSAccessible(); \    nsCOMPtr<nsIAccessibleSelectable> \        accessIface(do_QueryInterface(tmpAccess)); \    if (!(accessIface)) \        return (retvalue)/*interface virtual functions*/gbooleanMaiInterfaceSelection::AddSelection(gint i){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);    return NS_SUCCEEDED(accessInterfaceSelectable->AddSelection(i)) != 0;}gbooleanMaiInterfaceSelection::ClearSelection(){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);    return NS_SUCCEEDED(accessInterfaceSelectable->ClearSelection()) != 0;}MaiObject *MaiInterfaceSelection::RefSelection(gint i){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, NULL);    nsCOMPtr<nsIAccessible> aSelection;    nsresult rv =        accessInterfaceSelectable->RefSelection(i, getter_AddRefs(aSelection));    MaiWidget *maiWidget;    if (NS_SUCCEEDED(rv))        maiWidget = new MaiWidget(aSelection);    return (maiWidget != NULL) ? maiWidget : NULL;}gintMaiInterfaceSelection::GetSelectionCount(){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, 0);    PRInt32 num = 0;    nsresult rv = accessInterfaceSelectable->GetSelectionCount(&num);    return (NS_FAILED(rv)) ? -1 : num;}gbooleanMaiInterfaceSelection::IsChildSelected(gint i){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);    PRBool result = FALSE;    nsresult rv = accessInterfaceSelectable->IsChildSelected(i, &result);    return (NS_FAILED(rv)) ? FALSE : result;}gbooleanMaiInterfaceSelection::RemoveSelection(gint i){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);    nsresult rv = accessInterfaceSelectable->RemoveSelection(i);    return (NS_FAILED(rv)) ? FALSE : TRUE;}gbooleanMaiInterfaceSelection::SelectAllSelection(){    MAI_IFACE_RETURN_VAL_IF_FAIL(accessInterfaceSelectable, FALSE);    PRBool result = FALSE;    nsresult rv = accessInterfaceSelectable->SelectAllSelection(&result);    return (NS_FAILED(rv)) ? FALSE : result;}/* static functions *//* do general checking for callbacks functions * return the MaiInterfaceSelection extracted from atk selection */MaiInterfaceSelection *getSelection(AtkSelection *aSelection){    MAI_CHECK_ATK_OBJECT_RETURN_VAL_IF_FAIL(aSelection, NULL);    g_return_val_if_fail(MAI_IS_ATK_WIDGET(aSelection), NULL);    MaiWidget *maiWidget = (MaiWidget*)(MAI_ATK_OBJECT(aSelection)->maiObject);        MaiInterfaceSelection *maiInterfaceSelection = (MaiInterfaceSelection*)        maiWidget->GetMaiInterface(MAI_INTERFACE_SELECTION);    return maiInterfaceSelection;}voidinterfaceInitCB(AtkSelectionIface *aIface){    g_return_if_fail(aIface != NULL);    aIface->add_selection = addSelectionCB;    aIface->clear_selection = clearSelectionCB;    aIface->ref_selection = refSelectionCB;    aIface->get_selection_count = getSelectionCountCB;    aIface->is_child_selected = isChildSelectedCB;    aIface->remove_selection = removeSelectionCB;    aIface->select_all_selection = selectAllSelectionCB;}