@@ -1733,37 +1733,28 @@ gnc_numeric_to_scm(gnc_numeric arg)
1733
1733
scm_divide (scm_from_int64 (arg.num ), scm_from_int64 (arg.denom ));
1734
1734
}
1735
1735
1736
+ static swig_type_info*
1737
+ get_swig_type (const gchar *type_str)
1738
+ {
1739
+ auto type = SWIG_TypeQuery (type_str);
1740
+ if (!type)
1741
+ PERR (" Unknown SWIG Type: %s " , type_str);
1742
+ return type;
1743
+ }
1744
+
1736
1745
static SCM
1737
- gnc_generic_to_scm (const void *cx, const gchar *type_str )
1746
+ gnc_generic_to_scm (const void *cx, swig_type_info* stype )
1738
1747
{
1739
- swig_type_info * stype = nullptr ;
1740
1748
void *x = (void *) cx;
1741
-
1742
- if (!x) return SCM_BOOL_F;
1743
- stype = SWIG_TypeQuery (type_str);
1744
-
1745
- if (!stype)
1746
- {
1747
- PERR (" Unknown SWIG Type: %s " , type_str);
1748
- return SCM_BOOL_F;
1749
- }
1749
+ if (!x || !stype) return SCM_BOOL_F;
1750
1750
1751
1751
return SWIG_NewPointerObj (x, stype, 0 );
1752
1752
}
1753
1753
1754
1754
static void *
1755
- gnc_scm_to_generic (SCM scm, const gchar *type_str )
1755
+ gnc_scm_to_generic (SCM scm, swig_type_info* stype )
1756
1756
{
1757
- swig_type_info * stype = nullptr ;
1758
-
1759
- stype = SWIG_TypeQuery (type_str);
1760
- if (!stype)
1761
- {
1762
- PERR (" Unknown SWIG Type: %s " , type_str);
1763
- return nullptr ;
1764
- }
1765
-
1766
- if (!SWIG_IsPointerOfType (scm, stype))
1757
+ if (!stype || !SWIG_IsPointerOfType (scm, stype))
1767
1758
return nullptr ;
1768
1759
1769
1760
return SWIG_MustGetPtr (scm, stype, 1 , 0 );
@@ -1772,38 +1763,30 @@ gnc_scm_to_generic(SCM scm, const gchar *type_str)
1772
1763
gnc_commodity *
1773
1764
gnc_scm_to_commodity (SCM scm)
1774
1765
{
1775
- return static_cast <gnc_commodity*>(gnc_scm_to_generic (scm, " _p_gnc_commodity" ));
1766
+ static auto stype = get_swig_type (" _p_gnc_commodity" );
1767
+ return GNC_COMMODITY (gnc_scm_to_generic (scm, stype));
1776
1768
}
1777
1769
1778
1770
SCM
1779
1771
gnc_commodity_to_scm (const gnc_commodity *commodity)
1780
1772
{
1781
- return gnc_generic_to_scm (commodity, " _p_gnc_commodity" );
1773
+ static auto stype = get_swig_type (" _p_gnc_commodity" );
1774
+ return gnc_generic_to_scm (commodity, stype);
1782
1775
}
1783
1776
1784
1777
SCM
1785
1778
gnc_book_to_scm (const QofBook *book)
1786
1779
{
1787
- return gnc_generic_to_scm (book, " _p_QofBook" );
1788
- }
1789
-
1790
- static swig_type_info *
1791
- get_acct_type ()
1792
- {
1793
- static swig_type_info * account_type = nullptr ;
1794
-
1795
- if (!account_type)
1796
- account_type = SWIG_TypeQuery (" _p_Account" );
1797
-
1798
- return account_type;
1780
+ static auto stype = get_swig_type (" _p_QofBook" );
1781
+ return gnc_generic_to_scm (book, stype);
1799
1782
}
1800
1783
1801
1784
GncAccountValue * gnc_scm_to_account_value_ptr (SCM valuearg)
1802
1785
{
1803
1786
GncAccountValue *res;
1804
1787
Account *acc = nullptr ;
1805
1788
gnc_numeric value;
1806
- swig_type_info * account_type = get_acct_type ( );
1789
+ static auto account_type = get_swig_type ( " _p_Account " );
1807
1790
SCM val;
1808
1791
1809
1792
/* Get the account */
@@ -1826,7 +1809,7 @@ GncAccountValue * gnc_scm_to_account_value_ptr (SCM valuearg)
1826
1809
1827
1810
SCM gnc_account_value_ptr_to_scm (GncAccountValue *av)
1828
1811
{
1829
- swig_type_info * account_type = get_acct_type ( );
1812
+ static auto account_type = get_swig_type ( " _p_Account " );
1830
1813
gnc_commodity * com;
1831
1814
gnc_numeric val;
1832
1815
@@ -1864,9 +1847,9 @@ scm_hook_cb (gpointer data, GncScmDangler *scm)
1864
1847
scm_call_0 (scm->proc );
1865
1848
else
1866
1849
{
1850
+ static auto stype = get_swig_type (" _p_QofSession" );
1867
1851
// XXX: FIXME: We really should make sure this is a session!!! */
1868
- scm_call_1 (scm->proc ,
1869
- SWIG_NewPointerObj (data, SWIG_TypeQuery (" _p_QofSession" ), 0 ));
1852
+ scm_call_1 (scm->proc , SWIG_NewPointerObj (data, stype, 0 ));
1870
1853
}
1871
1854
1872
1855
LEAVE (" " );
0 commit comments