Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

(Incomplete) Matlab interface generated from https://github.com/jaeandersson/swig/tree/matlab

View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
classdef Circle < Shape
methods
function self = Circle(varargin)
self@Shape('_swigCreate',uint64(0),false);
if nargin==3 && ischar(varargin{1}) && strcmp(varargin{1},'_swigCreate')
self.swigCPtr = varargin{2};
self.swigOwn = varargin{3};
else
% How to get working on C side? Commented out, replaed by hack below
%self.swigCPtr = example_wrap('new_Circle',varargin{:});
%self.swigOwn = true;
tmp = example_wrap('new_Circle',varargin{:}); % FIXME
self.swigCPtr = tmp.swigCPtr;
self.swigOwn = tmp.swigOwn;
tmp.swigOwn = false;
end
end
function varargout = area(self,varargin)
[varargout{1:nargout}] = example_wrap('Circle_area',self,varargin{:});
end
function varargout = foo(self,varargin)
[varargout{1:nargout}] = example_wrap('Circle_foo',self,varargin{:});
end
function varargout = perimeter(self,varargin)
[varargout{1:nargout}] = example_wrap('Circle_perimeter',self,varargin{:});
end
function delete(self)
if self.swigOwn
example_wrap('delete_Circle',self);
end
end
end
end
View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
classdef Shape < SwigRef
methods
function delete(self)
if self.swigOwn
example_wrap('delete_Shape',self);
end
end
function varargout = move(self,varargin)
[varargout{1:nargout}] = example_wrap('Shape_move',self,varargin{:});
end
function varargout = area(self,varargin)
[varargout{1:nargout}] = example_wrap('Shape_area',self,varargin{:});
end
function varargout = perimeter(self,varargin)
[varargout{1:nargout}] = example_wrap('Shape_perimeter',self,varargin{:});
end
function self = Shape(varargin)
if nargin==3 && ischar(varargin{1}) && strcmp(varargin{1},'_swigCreate')
self.swigCPtr = varargin{2};
self.swigOwn = varargin{3};
else
error('No matching constructor');
end
end
end
end
View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
classdef Square < Shape
methods
function self = Square(varargin)
self@Shape('_swigCreate',uint64(0),false);
if nargin==3 && ischar(varargin{1}) && strcmp(varargin{1},'_swigCreate')
self.swigCPtr = varargin{2};
self.swigOwn = varargin{3};
else
% How to get working on C side? Commented out, replaed by hack below
%self.swigCPtr = example_wrap('new_Square',varargin{:});
%self.swigOwn = true;
tmp = example_wrap('new_Square',varargin{:}); % FIXME
self.swigCPtr = tmp.swigCPtr;
self.swigOwn = tmp.swigOwn;
tmp.swigOwn = false;
end
end
function varargout = area(self,varargin)
[varargout{1:nargout}] = example_wrap('Square_area',self,varargin{:});
end
function varargout = perimeter(self,varargin)
[varargout{1:nargout}] = example_wrap('Square_perimeter',self,varargin{:});
end
function delete(self)
if self.swigOwn
example_wrap('delete_Square',self);
end
end
end
end
View Circle.m
1 2 3 4 5 6
classdef SwigRef < handle
properties % (GetAccess = protected, SetAccess = protected) % FIXME: mxGetProperty not working with protected access
swigCPtr
swigOwn
end
end
View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
#include "example.h"
#define M_PI 3.14159265358979323846
 
/* Move the shape to a new location */
void Shape::move(double dx, double dy) {
x += dx;
y += dy;
}
 
int Shape::nshapes = 0;
 
double Circle::area(void) {
return M_PI*radius*radius;
}
 
double Circle::perimeter(void) {
return 2*M_PI*radius;
}
 
double Square::area(void) {
return width*width;
}
 
double Square::perimeter(void) {
return 4*width;
}
View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
class Shape {
public:
Shape() {
nshapes++;
}
virtual ~Shape() {
nshapes--;
}
double x, y;
void move(double dx, double dy);
virtual double area() = 0;
virtual double perimeter() = 0;
static int nshapes;
};
 
class Circle : public Shape {
private:
double radius;
public:
Circle(double r) : radius(r) { }
virtual double area();
// Test overloading
virtual double foo(int d){ return area();}
virtual double foo(){ return perimeter();}
 
virtual double perimeter();
};
 
class Square : public Shape {
private:
double width;
public:
Square(double w) : width(w) { }
virtual double area();
virtual double perimeter();
};
View Circle.m
1 2 3 4 5 6 7 8
%module swigexample
 
%{
#include "example.h"
%}
 
/* Let's just grab the original header file here */
%include "example.h"
View Circle.m
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.1
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
 
#define SWIGMATLAB
#define SWIG_name_d "swigexample"
#define SWIG_name swigexample
 
#define SWIG_global_name "cvar"
#define SWIG_op_prefix "op_"
 
 
#ifdef __cplusplus
/* SwigValueWrapper is described in swig.swg */
template<typename T> class SwigValueWrapper {
struct SwigMovePointer {
T *ptr;
SwigMovePointer(T *p) : ptr(p) { }
~SwigMovePointer() { delete ptr; }
SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
} pointer;
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
SwigValueWrapper(const SwigValueWrapper<T>& rhs);
public:
SwigValueWrapper() : pointer(0) { }
SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
operator T&() const { return *pointer.ptr; }
T *operator&() { return pointer.ptr; }
};
 
template <typename T> T SwigValueInit() {
return T();
}
#endif
 
/* -----------------------------------------------------------------------------
* This section contains generic SWIG labels for method/variable
* declarations/attributes, and other compiler dependent labels.
* ----------------------------------------------------------------------------- */
 
/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
# define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
# define SWIGTEMPLATEDISAMBIGUATOR template
# else
# define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif
 
/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
# define SWIGINLINE inline
# else
# define SWIGINLINE
# endif
#endif
 
/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
# elif defined(__ICC)
# define SWIGUNUSED __attribute__ ((__unused__))
# else
# define SWIGUNUSED
# endif
#endif
 
#ifndef SWIG_MSC_UNSUPPRESS_4505
# if defined(_MSC_VER)
# pragma warning(disable : 4505) /* unreferenced local function has been removed */
# endif
#endif
 
#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
# define SWIGUNUSEDPARM(p)
# else
# define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif
 
/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif
 
/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif
 
/* exporting methods */
#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# ifndef GCC_HASCLASSVISIBILITY
# define GCC_HASCLASSVISIBILITY
# endif
#endif
 
#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# if defined(STATIC_LINKED)
# define SWIGEXPORT
# else
# define SWIGEXPORT __declspec(dllexport)
# endif
# else
# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
# define SWIGEXPORT __attribute__ ((visibility("default")))
# else
# define SWIGEXPORT
# endif
# endif
#endif
 
/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
# define SWIGSTDCALL __stdcall
# else
# define SWIGSTDCALL
# endif
#endif
 
/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif
 
/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif
 
 
 
#include <cstdlib>
#include <iostream>
#include <mex.h>
#include <math.h>
 
/* -----------------------------------------------------------------------------
* swigrun.swg
*
* This file contains generic C API SWIG runtime support for pointer
* type checking.
* ----------------------------------------------------------------------------- */
 
/* This should only be incremented when either the layout of swig_type_info changes,
or for whatever reason, the runtime changes incompatibly */
#define SWIG_RUNTIME_VERSION "4"
 
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
#ifdef SWIG_TYPE_TABLE
# define SWIG_QUOTE_STRING(x) #x
# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x)
# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE)
#else
# define SWIG_TYPE_TABLE_NAME
#endif
 
/*
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
creating a static or dynamic library from the SWIG runtime code.
In 99.9% of the cases, SWIG just needs to declare them as 'static'.
But only do this if strictly necessary, ie, if you have problems
with your compiler or suchlike.
*/
 
#ifndef SWIGRUNTIME
# define SWIGRUNTIME SWIGINTERN
#endif
 
#ifndef SWIGRUNTIMEINLINE
# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
#endif
 
/* Generic buffer size */
#ifndef SWIG_BUFFER_SIZE
# define SWIG_BUFFER_SIZE 1024
#endif
 
/* Flags for pointer conversions */
#define SWIG_POINTER_DISOWN 0x1
#define SWIG_CAST_NEW_MEMORY 0x2
 
/* Flags for new pointer objects */
#define SWIG_POINTER_OWN 0x1
 
 
/*
Flags/methods for returning states.
The SWIG conversion methods, as ConvertPtr, return an integer
that tells if the conversion was successful or not. And if not,
an error code can be returned (see swigerrors.swg for the codes).
Use the following macros/flags to set or process the returning
states.
In old versions of SWIG, code such as the following was usually written:
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
// success code
} else {
//fail code
}
Now you can be more explicit:
int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
if (SWIG_IsOK(res)) {
// success code
} else {
// fail code
}
which is the same really, but now you can also do
Type *ptr;
int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
if (SWIG_IsOK(res)) {
// success code
if (SWIG_IsNewObj(res) {
...
delete *ptr;
} else {
...
}
} else {
// fail code
}
I.e., now SWIG_ConvertPtr can return new objects and you can
identify the case and take care of the deallocation. Of course that
also requires SWIG_ConvertPtr to return new result values, such as
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
if (<need new object>) {
*ptr = <ptr to new allocated object>;
return SWIG_NEWOBJ;
} else {
*ptr = <ptr to old object>;
return SWIG_OLDOBJ;
}
} else {
return SWIG_BADOBJ;
}
}
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
SWIG errors code.
Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
allows to return the 'cast rank', for example, if you have this
int food(double)
int fooi(int);
and you call
food(1) // cast rank '1' (1 -> 1.0)
fooi(1) // cast rank '0'
just use the SWIG_AddCast()/SWIG_CheckState()
*/
 
#define SWIG_OK (0)
#define SWIG_ERROR (-1)
#define SWIG_IsOK(r) (r >= 0)
#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError)
 
/* The CastRankLimit says how many bits are used for the cast rank */
#define SWIG_CASTRANKLIMIT (1 << 8)
/* The NewMask denotes the object was created (using new/malloc) */
#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1)
/* The TmpMask is for in/out typemaps that use temporal objects */
#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1)
/* Simple returning values */
#define SWIG_BADOBJ (SWIG_ERROR)
#define SWIG_OLDOBJ (SWIG_OK)
#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK)
#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK)
/* Check, add and del mask methods */
#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r)
#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r)
#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK))
#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r)
#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
 
/* Cast-Rank Mode */
#if defined(SWIG_CASTRANK_MODE)
# ifndef SWIG_TypeRank
# define SWIG_TypeRank unsigned long
# endif
# ifndef SWIG_MAXCASTRANK /* Default cast allowed */
# define SWIG_MAXCASTRANK (2)
# endif
# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1)
# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK)
SWIGINTERNINLINE int SWIG_AddCast(int r) {
return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
}
SWIGINTERNINLINE int SWIG_CheckState(int r) {
return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
}
#else /* no cast-rank mode */
# define SWIG_AddCast(r) (r)
# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
#endif
 
 
#include <string.h>
 
#ifdef __cplusplus
extern "C" {
#endif
 
typedef void *(*swig_converter_func)(void *, int *);
typedef struct swig_type_info *(*swig_dycast_func)(void **);
 
/* Structure to store information on one type */
typedef struct swig_type_info {
const char *name; /* mangled name of this type */
const char *str; /* human readable name of this type */
swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
struct swig_cast_info *cast; /* linked list of types that can cast into this type */
void *clientdata; /* language specific type data */
int owndata; /* flag if the structure owns the clientdata */
} swig_type_info;
 
/* Structure to store a type and conversion function used for casting */
typedef struct swig_cast_info {
swig_type_info *type; /* pointer to type that is equivalent to this type */
swig_converter_func converter; /* function to cast the void pointers */
struct swig_cast_info *next; /* pointer to next cast in linked list */
struct swig_cast_info *prev; /* pointer to the previous cast */
} swig_cast_info;
 
/* Structure used to store module information
* Each module generates one structure like this, and the runtime collects
* all of these structures and stores them in a circularly linked list.*/
typedef struct swig_module_info {
swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
size_t size; /* Number of types in this module */
struct swig_module_info *next; /* Pointer to next element in circularly linked list */
swig_type_info **type_initial; /* Array of initially generated type structures */
swig_cast_info **cast_initial; /* Array of initially generated casting structures */
void *clientdata; /* Language specific module data */
} swig_module_info;
 
/*
Compare two type names skipping the space characters, therefore
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
Return 0 when the two name types are equivalent, as in
strncmp, but skipping ' '.
*/
SWIGRUNTIME int
SWIG_TypeNameComp(const char *f1, const char *l1,
const char *f2, const char *l2) {
for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) {
while ((*f1 == ' ') && (f1 != l1)) ++f1;
while ((*f2 == ' ') && (f2 != l2)) ++f2;
if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
}
return (int)((l1 - f1) - (l2 - f2));
}
 
/*
Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if equal, -1 if nb < tb, 1 if nb > tb
*/
SWIGRUNTIME int
SWIG_TypeCmp(const char *nb, const char *tb) {
int equiv = 1;
const char* te = tb + strlen(tb);
const char* ne = nb;
while (equiv != 0 && *ne) {
for (nb = ne; *ne; ++ne) {
if (*ne == '|') break;
}
equiv = SWIG_TypeNameComp(nb, ne, tb, te);
if (*ne) ++ne;
}
return equiv;
}
 
/*
Check type equivalence in a name list like <name1>|<name2>|...
Return 0 if not equal, 1 if equal
*/
SWIGRUNTIME int
SWIG_TypeEquiv(const char *nb, const char *tb) {
return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
}
 
/*
Check the typename
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
if (ty) {
swig_cast_info *iter = ty->cast;
while (iter) {
if (strcmp(iter->type->name, c) == 0) {
if (iter == ty->cast)
return iter;
/* Move iter to the top of the linked list */
iter->prev->next = iter->next;
if (iter->next)
iter->next->prev = iter->prev;
iter->next = ty->cast;
iter->prev = 0;
if (ty->cast) ty->cast->prev = iter;
ty->cast = iter;
return iter;
}
iter = iter->next;
}
}
return 0;
}
 
/*
Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
if (ty) {
swig_cast_info *iter = ty->cast;
while (iter) {
if (iter->type == from) {
if (iter == ty->cast)
return iter;
/* Move iter to the top of the linked list */
iter->prev->next = iter->next;
if (iter->next)
iter->next->prev = iter->prev;
iter->next = ty->cast;
iter->prev = 0;
if (ty->cast) ty->cast->prev = iter;
ty->cast = iter;
return iter;
}
iter = iter->next;
}
}
return 0;
}
 
/*
Cast a pointer up an inheritance hierarchy
*/
SWIGRUNTIMEINLINE void *
SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
}
 
/*
Dynamic pointer casting. Down an inheritance hierarchy
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) {
swig_type_info *lastty = ty;
if (!ty || !ty->dcast) return ty;
while (ty && (ty->dcast)) {
ty = (*ty->dcast)(ptr);
if (ty) lastty = ty;
}
return lastty;
}
 
/*
Return the name associated with this type
*/
SWIGRUNTIMEINLINE const char *
SWIG_TypeName(const swig_type_info *ty) {
return ty->name;
}
 
/*
Return the pretty name associated with this type,
that is an unmangled type name in a form presentable to the user.
*/
SWIGRUNTIME const char *
SWIG_TypePrettyName(const swig_type_info *type) {
/* The "str" field contains the equivalent pretty names of the
type, separated by vertical-bar characters. We choose
to print the last name, as it is often (?) the most
specific. */
if (!type) return NULL;
if (type->str != NULL) {
const char *last_name = type->str;
const char *s;
for (s = type->str; *s; s++)
if (*s == '|') last_name = s+1;
return last_name;
}
else
return type->name;
}
 
/*
Set the clientdata field for a type
*/
SWIGRUNTIME void
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
swig_cast_info *cast = ti->cast;
/* if (ti->clientdata == clientdata) return; */
ti->clientdata = clientdata;
 
while (cast) {
if (!cast->converter) {
swig_type_info *tc = cast->type;
if (!tc->clientdata) {
SWIG_TypeClientData(tc, clientdata);
}
}
cast = cast->next;
}
}
SWIGRUNTIME void
SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
SWIG_TypeClientData(ti, clientdata);
ti->owndata = 1;
}
 
/*
Search for a swig_type_info structure only by mangled name
Search is a O(log #types)
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_MangledTypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
swig_module_info *iter = start;
do {
if (iter->size) {
size_t l = 0;
size_t r = iter->size - 1;
do {
/* since l+r >= 0, we can (>> 1) instead (/ 2) */
size_t i = (l + r) >> 1;
const char *iname = iter->types[i]->name;
if (iname) {
int compare = strcmp(name, iname);
if (compare == 0) {
return iter->types[i];
} else if (compare < 0) {
if (i) {
r = i - 1;
} else {
break;
}
} else if (compare > 0) {
l = i + 1;
}
} else {
break; /* should never happen */
}
} while (l <= r);
}
iter = iter->next;
} while (iter != end);
return 0;
}
 
/*
Search for a swig_type_info structure for either a mangled name or a human readable name.
It first searches the mangled names of the types, which is a O(log #types)
If a type is not found it then searches the human readable names, which is O(#types).
We start searching at module start, and finish searching when start == end.
Note: if start == end at the beginning of the function, we go all the way around
the circular list.
*/
SWIGRUNTIME swig_type_info *
SWIG_TypeQueryModule(swig_module_info *start,
swig_module_info *end,
const char *name) {
/* STEP 1: Search the name field using binary search */
swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
if (ret) {
return ret;
} else {
/* STEP 2: If the type hasn't been found, do a complete search
of the str field (the human readable name) */
swig_module_info *iter = start;
do {
size_t i = 0;
for (; i < iter->size; ++i) {
if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
return iter->types[i];
}
iter = iter->next;
} while (iter != end);
}
 
/* neither found a match */
return 0;
}
 
/*
Pack binary data into a string
*/
SWIGRUNTIME char *
SWIG_PackData(char *c, void *ptr, size_t sz) {
static const char hex[17] = "0123456789abcdef";
const unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
unsigned char uu = *u;
*(c++) = hex[(uu & 0xf0) >> 4];
*(c++) = hex[uu & 0xf];
}
return c;
}
 
/*
Unpack binary data from a string
*/
SWIGRUNTIME const char *
SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
unsigned char *u = (unsigned char *) ptr;
const unsigned char *eu = u + sz;
for (; u != eu; ++u) {
char d = *(c++);
unsigned char uu;
if ((d >= '0') && (d <= '9'))
uu = ((d - '0') << 4);
else if ((d >= 'a') && (d <= 'f'))
uu = ((d - ('a'-10)) << 4);
else
return (char *) 0;
d = *(c++);
if ((d >= '0') && (d <= '9'))
uu |= (d - '0');
else if ((d >= 'a') && (d <= 'f'))
uu |= (d - ('a'-10));
else
return (char *) 0;
*u = uu;
}
return c;
}
 
/*
Pack 'void *' into a string buffer.
*/
SWIGRUNTIME char *
SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) {
char *r = buff;
if ((2*sizeof(void *) + 2) > bsz) return 0;
*(r++) = '_';
r = SWIG_PackData(r,&ptr,sizeof(void *));
if (strlen(name) + 1 > (bsz - (r - buff))) return 0;
strcpy(r,name);
return buff;
}
 
SWIGRUNTIME const char *
SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) {
if (*c != '_') {
if (strcmp(c,"NULL") == 0) {
*ptr = (void *) 0;
return name;
} else {
return 0;
}
}
return SWIG_UnpackData(++c,ptr,sizeof(void *));
}
 
SWIGRUNTIME char *
SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) {
char *r = buff;
size_t lname = (name ? strlen(name) : 0);
if ((2*sz + 2 + lname) > bsz) return 0;
*(r++) = '_';
r = SWIG_PackData(r,ptr,sz);
if (lname) {
strncpy(r,name,lname+1);
} else {
*r = 0;
}
return buff;
}
 
SWIGRUNTIME const char *
SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
if (*c != '_') {
if (strcmp(c,"NULL") == 0) {
memset(ptr,0,sz);
return name;
} else {
return 0;
}
}
return SWIG_UnpackData(++c,ptr,sz);
}
 
#ifdef __cplusplus
}
#endif
 
/* Errors in SWIG */
#define SWIG_UnknownError -1
#define SWIG_IOError -2
#define SWIG_RuntimeError -3
#define SWIG_IndexError -4
#define SWIG_TypeError -5
#define SWIG_DivisionByZero -6
#define SWIG_OverflowError -7
#define SWIG_SyntaxError -8
#define SWIG_ValueError -9
#define SWIG_SystemError -10
#define SWIG_AttributeError -11
#define SWIG_MemoryError -12
#define SWIG_NullReferenceError -13
 
 
 
SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) {
if (num_args > max_args && !varargs)
mexWarnMsgIdAndTxt("SWIG","function %s takes at most %i arguments", func_name, max_args);
else if (num_args < min_args)
mexWarnMsgIdAndTxt("SWIG","function %s requires at least %i arguments", func_name, min_args);
else
return true;
return false;
}
 
SWIGRUNTIME const char* SWIG_ErrorType(int code) {
switch (code) {
case SWIG_MemoryError:
return "SWIG:MemoryError";
case SWIG_IOError:
return "SWIG:IOError";
case SWIG_RuntimeError:
return "SWIG:RuntimeError";
case SWIG_IndexError:
return "SWIG:IndexError";
case SWIG_TypeError:
return "SWIG:TypeError";
case SWIG_DivisionByZero:
return "SWIG:DivisionByZero";
case SWIG_OverflowError:
return "SWIG:OverflowError";
case SWIG_SyntaxError:
return "SWIG:SyntaxError";
case SWIG_ValueError:
return "SWIG:ValueError";
case SWIG_SystemError:
return "SWIG:SystemError";
case SWIG_AttributeError:
return "SWIG:AttributeError";
}
return "SWIG:UnknownError";
}
 
SWIGRUNTIME void SWIG_Error(int code, const char *msg) {
mexWarnMsgIdAndTxt(SWIG_ErrorType(code),msg);
}
 
#define SWIG_fail goto fail
 
#define SWIG_Matlab_ConvertPtr(obj, pptr, type, flags) SWIG_Matlab_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Matlab_ConvertPtr(obj, pptr, type, flags)
#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Matlab_ConvertPtrAndOwn(obj, pptr, type, flags, own)
#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Matlab_ConvertPtr(obj, pptr, type, flags)
#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Matlab_NewPointerObj(ptr, type, flags)
#define swig_owntype int
 
#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Matlab_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Matlab_NewPackedObj(ptr, sz, type)
 
#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_ConvertPtr(obj, pptr, type, 0)
#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_NewPointerObj(ptr, type, 0)
 
#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Matlab_ConvertPacked(obj, ptr, sz, ty)
#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Matlab_NewPackedObj(ptr, sz, type)
 
#define SWIG_GetModule(clientdata) SWIG_Matlab_GetModule(clientdata)
#define SWIG_SetModule(clientdata, pointer) SWIG_Matlab_SetModule(clientdata,pointer);
#define SWIG_MODULE_CLIENTDATA_TYPE void*
 
#define Matlab_Error_Occurred() 0
#define SWIG_Matlab_AddErrorMsg(msg) {;}
 
SWIGRUNTIME swig_module_info *SWIG_Matlab_GetModule(void *clientdata);
SWIGRUNTIME void SWIG_Matlab_SetModule(void *clientdata, swig_module_info *pointer);
 
// For backward compatibility only
#define SWIG_POINTER_EXCEPTION 0
#define SWIG_arg_fail(arg) 0
 
// Runtime API implementation
 
#include <map>
#include <vector>
#include <string>
 
SWIGRUNTIME mxArray* SWIG_Matlab_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
mxArray* pm_command = mxCreateString("_swigCreate");
mxArray *pm_ptr = mxCreateNumericMatrix(1,1,mxUINT64_CLASS, mxREAL);
if(!pm_ptr) mexErrMsgIdAndTxt("SWIG:NewPointerObj","mxCreateNumericMatrix failed");
*(uint64_T *)mxGetData(pm_ptr) = (uint64_T)ptr;
bool own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
mxArray* pm_own = mxCreateLogicalScalar(own);
if(!pm_own) mexErrMsgIdAndTxt("SWIG:NewPointerObj","mxCreateLogicalScalar failed");
mxArray* prhs[3] = {pm_command,pm_ptr,pm_own};
mxArray* plhs[1];
const char* matlab_classname = type->name+3; /* FIXME: Hack to dereferece pointer */
mxArray* ex = mexCallMATLABWithTrap(1,plhs,3,prhs,matlab_classname);
if(ex) mexErrMsgIdAndTxt("SWIG:NewPointerObj","mexCallMATLABWithTrap threw exception");
mxDestroyArray(pm_ptr);
mxDestroyArray(pm_own);
mxDestroyArray(pm_command);
return plhs[0];
}
 
SWIGRUNTIME int SWIG_Matlab_ConvertPtrAndOwn(mxArray* pm, void **ptr, swig_type_info *type, int flags, int *own) {
/* Return value */
int ret = SWIG_OK;
 
/* Get pointer, represented as a uint64_T scalar */
mxArray *pm_ptr = mxGetProperty(pm,0,"swigCPtr");
if(!pm_ptr || mxGetNumberOfElements(pm_ptr) != 1 || mxGetClassID(pm_ptr) != mxUINT64_CLASS || mxIsComplex(pm_ptr)){
ret = SWIG_ERROR;
} else {
if(ptr) *ptr = (void*)(*(uint64_T*)mxGetData(pm_ptr));
}
if(pm_ptr) mxDestroyArray(pm_ptr);
 
/* Get ownership marker */
mxArray *pm_own = mxGetProperty(pm,0,"swigOwn");
if(!pm_own || !mxIsLogicalScalar(pm_own)){
ret = SWIG_ERROR;
} else {
if(own) *own = mxIsLogicalScalarTrue(pm_own);
}
if(pm_own) mxDestroyArray(pm_own);
 
/* Set ownership marker to false? */
if(flags & SWIG_POINTER_DISOWN){
mxArray* pm_own = mxCreateLogicalScalar(false);
mxSetProperty(pm,0,"swigOwn",pm_own);
mxDestroyArray(pm_own);
}
 
return ret;
}
 
SWIGRUNTIME swig_module_info *SWIG_Matlab_GetModule(void *clientdata) {
swig_module_info *pointer = 0;
return pointer;
}
 
SWIGRUNTIME void SWIG_Matlab_SetModule(void *clientdata, swig_module_info *pointer) {
}
 
 
 
#define SWIG_exception_fail(code, msg) do { SWIG_Error(code, msg); SWIG_fail; } while(0)
 
#define SWIG_contract_assert(expr, msg) if (!(expr)) { SWIG_Error(SWIG_RuntimeError, msg); SWIG_fail; } else
 
 
 
/* -------- TYPES TABLE (BEGIN) -------- */
 
#define SWIGTYPE_p_Circle swig_types[0]
#define SWIGTYPE_p_Shape swig_types[1]
#define SWIGTYPE_p_Square swig_types[2]
#define SWIGTYPE_p_char swig_types[3]
static swig_type_info *swig_types[5];
static swig_module_info swig_module = {swig_types, 4, 0, 0, 0, 0};
#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
/* -------- TYPES TABLE (END) -------- */
 
 
#define SWIGVERSION 0x030001
#define SWIG_VERSION SWIGVERSION
 
 
#define SWIG_as_voidptr(a) (void *)((const void *)(a))
#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a))
 
 
#include <stdexcept>
 
 
#include "example.h"
 
 
SWIGINTERN int SWIG_AsVal_double (mxArray* pm, double* val)
{
if(!mxIsDouble(pm) || mxGetNumberOfElements(pm)!=1) return SWIG_TypeError;
if (val) *val = mxGetScalar(pm);
return SWIG_OK;
}
 
 
SWIGINTERNINLINE mxArray* SWIG_From_double (double value)
{
return mxCreateDoubleScalar(value);
}
 
 
#include <limits.h>
#if !defined(SWIG_NO_LLONG_MAX)
# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
# define LLONG_MAX __LONG_LONG_MAX__
# define LLONG_MIN (-LLONG_MAX - 1LL)
# define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
# endif
#endif
 
 
SWIGINTERN int SWIG_AsVal_long (mxArray* pm, long* val)
{
if(mxGetNumberOfElements(pm)!=1) return SWIG_TypeError;
switch(mxGetClassID(pm)){
case mxINT8_CLASS:
if(val) *val = (long)(*(int8_T*)mxGetData(pm)); break;
case mxUINT8_CLASS:
if(val) *val = (long)(*(uint8_T*)mxGetData(pm)); break;
case mxINT16_CLASS:
if(val) *val = (long)(*(int16_T*)mxGetData(pm)); break;
case mxUINT16_CLASS:
if(val) *val = (long)(*(uint16_T*)mxGetData(pm)); break;
case mxINT32_CLASS:
if(val) *val = (long)(*(int32_T*)mxGetData(pm)); break;
case mxUINT32_CLASS:
if(val) *val = (long)(*(uint32_T*)mxGetData(pm)); break;
case mxINT64_CLASS:
if(val) *val = (long)(*(int64_T*)mxGetData(pm)); break;
case mxUINT64_CLASS:
if(val) *val = (long)(*(uint64_T*)mxGetData(pm)); break;
case mxDOUBLE_CLASS:
{
double v=mxGetScalar(pm);
if(v!=floor(v)) return SWIG_TypeError;
if(val) *val = (long)v;
break;
}
default: return SWIG_TypeError;
}
return SWIG_OK;
}
 
 
SWIGINTERN int
SWIG_AsVal_int (mxArray* obj, int *val)
{
long v;
int res = SWIG_AsVal_long (obj, &v);
if (SWIG_IsOK(res)) {
if ((v < INT_MIN || v > INT_MAX)) {
return SWIG_OverflowError;
} else {
if (val) *val = (int)(v);
}
}
return res;
}
 
 
SWIGINTERNINLINE mxArray* SWIG_From_long (long value)
{
mxArray* out = mxCreateNumericMatrix(1,1,mxINT64_CLASS,mxREAL);
*((int64_T*)mxGetData(out)) = (int64_T)value;
return out;
}
 
 
SWIGINTERNINLINE mxArray*
SWIG_From_int (int value)
{
return SWIG_From_long (value);
}
 
 
void _wrap_delete_Shape (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("delete_Shape",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Shape" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
delete arg1;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function delete_Shape.");
}
 
 
void _wrap_Shape_x_set (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
double arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
double val2 ;
int ecode2 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("Shape_x_set",argc,2,2,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_x_set" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
ecode2 = SWIG_AsVal_double(argv[1], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_x_set" "', argument " "2"" of type '" "double""'");
}
arg2 = (double)(val2);
if (arg1) (arg1)->x = arg2;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_x_set.");
}
 
 
void _wrap_Shape_x_get (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Shape_x_get",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_x_get" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
result = (double) ((arg1)->x);
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_x_get.");
}
 
 
void _wrap_Shape_y_set (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
double arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
double val2 ;
int ecode2 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("Shape_y_set",argc,2,2,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_y_set" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
ecode2 = SWIG_AsVal_double(argv[1], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_y_set" "', argument " "2"" of type '" "double""'");
}
arg2 = (double)(val2);
if (arg1) (arg1)->y = arg2;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_y_set.");
}
 
 
void _wrap_Shape_y_get (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Shape_y_get",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_y_get" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
result = (double) ((arg1)->y);
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_y_get.");
}
 
 
void _wrap_Shape_move (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
double arg2 ;
double arg3 ;
void *argp1 = 0 ;
int res1 = 0 ;
double val2 ;
int ecode2 = 0 ;
double val3 ;
int ecode3 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("Shape_move",argc,3,3,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_move" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
ecode2 = SWIG_AsVal_double(argv[1], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Shape_move" "', argument " "2"" of type '" "double""'");
}
arg2 = (double)(val2);
ecode3 = SWIG_AsVal_double(argv[2], &val3);
if (!SWIG_IsOK(ecode3)) {
SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Shape_move" "', argument " "3"" of type '" "double""'");
}
arg3 = (double)(val3);
(arg1)->move(arg2,arg3);
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_move.");
}
 
 
void _wrap_Shape_area (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Shape_area",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_area" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
result = (double)(arg1)->area();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_area.");
}
 
 
void _wrap_Shape_perimeter (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Shape *arg1 = (Shape *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Shape_perimeter",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Shape, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Shape_perimeter" "', argument " "1"" of type '" "Shape *""'");
}
arg1 = (Shape *)(argp1);
result = (double)(arg1)->perimeter();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_perimeter.");
}
 
 
void _wrap_Shape_nshapes_set (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
int arg1 ;
int val1 ;
int ecode1 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("Shape_nshapes_set",argc,1,1,0)) {
SWIG_fail;
}
ecode1 = SWIG_AsVal_int(argv[0], &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "Shape_nshapes_set" "', argument " "1"" of type '" "int""'");
}
arg1 = (int)(val1);
Shape::nshapes = arg1;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_nshapes_set.");
}
 
 
void _wrap_Shape_nshapes_get (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
mxArray * _out;
int result;
if (!SWIG_check_num_args("Shape_nshapes_get",argc,0,0,0)) {
SWIG_fail;
}
result = (int)Shape::nshapes;
_out = SWIG_From_int((int)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Shape_nshapes_get.");
}
 
 
void _wrap_new_Circle (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
double arg1 ;
double val1 ;
int ecode1 = 0 ;
mxArray * _out;
Circle *result = 0 ;
if (!SWIG_check_num_args("new_Circle",argc,1,1,0)) {
SWIG_fail;
}
ecode1 = SWIG_AsVal_double(argv[0], &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Circle" "', argument " "1"" of type '" "double""'");
}
arg1 = (double)(val1);
result = (Circle *)new Circle(arg1);
_out = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Circle, 1 | 0 );
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function new_Circle.");
}
 
 
void _wrap_Circle_area (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Circle *arg1 = (Circle *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Circle_area",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Circle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_area" "', argument " "1"" of type '" "Circle *""'");
}
arg1 = (Circle *)(argp1);
result = (double)(arg1)->area();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Circle_area.");
}
 
 
void _wrap_Circle_foo__SWIG_0 (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Circle *arg1 = (Circle *) 0 ;
int arg2 ;
void *argp1 = 0 ;
int res1 = 0 ;
int val2 ;
int ecode2 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Circle_foo",argc,2,2,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Circle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_foo" "', argument " "1"" of type '" "Circle *""'");
}
arg1 = (Circle *)(argp1);
ecode2 = SWIG_AsVal_int(argv[1], &val2);
if (!SWIG_IsOK(ecode2)) {
SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "Circle_foo" "', argument " "2"" of type '" "int""'");
}
arg2 = (int)(val2);
result = (double)(arg1)->foo(arg2);
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Circle_foo.");
}
 
 
void _wrap_Circle_foo__SWIG_1 (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Circle *arg1 = (Circle *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Circle_foo",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Circle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_foo" "', argument " "1"" of type '" "Circle *""'");
}
arg1 = (Circle *)(argp1);
result = (double)(arg1)->foo();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Circle_foo.");
}
 
 
void _wrap_Circle_foo (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
if (argc == 1) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Circle, 0);
_v = SWIG_CheckState(res);
if (_v) {
return _wrap_Circle_foo__SWIG_1(resc,resv,argc,argv);
}
}
if (argc == 2) {
int _v;
void *vptr = 0;
int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_Circle, 0);
_v = SWIG_CheckState(res);
if (_v) {
{
int res = SWIG_AsVal_int(argv[1], NULL);
_v = SWIG_CheckState(res);
}
if (_v) {
return _wrap_Circle_foo__SWIG_0(resc,resv,argc,argv);
}
}
}
mexWarnMsgIdAndTxt("SWIG","No matching function for overload");
return;
}
 
 
void _wrap_Circle_perimeter (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Circle *arg1 = (Circle *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Circle_perimeter",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Circle, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Circle_perimeter" "', argument " "1"" of type '" "Circle *""'");
}
arg1 = (Circle *)(argp1);
result = (double)(arg1)->perimeter();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Circle_perimeter.");
}
 
 
void _wrap_delete_Circle (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Circle *arg1 = (Circle *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("delete_Circle",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Circle, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Circle" "', argument " "1"" of type '" "Circle *""'");
}
arg1 = (Circle *)(argp1);
delete arg1;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function delete_Circle.");
}
 
 
void _wrap_new_Square (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
double arg1 ;
double val1 ;
int ecode1 = 0 ;
mxArray * _out;
Square *result = 0 ;
if (!SWIG_check_num_args("new_Square",argc,1,1,0)) {
SWIG_fail;
}
ecode1 = SWIG_AsVal_double(argv[0], &val1);
if (!SWIG_IsOK(ecode1)) {
SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_Square" "', argument " "1"" of type '" "double""'");
}
arg1 = (double)(val1);
result = (Square *)new Square(arg1);
_out = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Square, 1 | 0 );
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function new_Square.");
}
 
 
void _wrap_Square_area (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Square *arg1 = (Square *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Square_area",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Square, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Square_area" "', argument " "1"" of type '" "Square *""'");
}
arg1 = (Square *)(argp1);
result = (double)(arg1)->area();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Square_area.");
}
 
 
void _wrap_Square_perimeter (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Square *arg1 = (Square *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
double result;
if (!SWIG_check_num_args("Square_perimeter",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Square, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Square_perimeter" "', argument " "1"" of type '" "Square *""'");
}
arg1 = (Square *)(argp1);
result = (double)(arg1)->perimeter();
_out = SWIG_From_double((double)(result));
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function Square_perimeter.");
}
 
 
void _wrap_delete_Square (int resc, mxArray *resv[], int argc, mxArray *argv[]) {
Square *arg1 = (Square *) 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
mxArray * _out;
if (!SWIG_check_num_args("delete_Square",argc,1,1,0)) {
SWIG_fail;
}
res1 = SWIG_ConvertPtr(argv[0], &argp1,SWIGTYPE_p_Square, SWIG_POINTER_DISOWN | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_Square" "', argument " "1"" of type '" "Square *""'");
}
arg1 = (Square *)(argp1);
delete arg1;
_out = (mxArray*)0;
if(resc>0) *resv = _out;
return;
fail:
mexErrMsgTxt("Failure in function delete_Square.");
}
 
 
 
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
static void *_p_SquareTo_p_Shape(void *x, int *SWIGUNUSEDPARM(newmemory)) {
return (void *)((Shape *) ((Square *) x));
}
static void *_p_CircleTo_p_Shape(void *x, int *SWIGUNUSEDPARM(newmemory)) {
return (void *)((Shape *) ((Circle *) x));
}
static swig_type_info _swigt__p_Circle = {"_p_Circle", "Circle *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_Shape = {"_p_Shape", "Shape *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_Square = {"_p_Square", "Square *", 0, 0, (void*)0, 0};
static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
 
static swig_type_info *swig_type_initial[] = {
&_swigt__p_Circle,
&_swigt__p_Shape,
&_swigt__p_Square,
&_swigt__p_char,
};
 
static swig_cast_info _swigc__p_Circle[] = { {&_swigt__p_Circle, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Shape[] = { {&_swigt__p_Square, _p_SquareTo_p_Shape, 0, 0}, {&_swigt__p_Shape, 0, 0, 0}, {&_swigt__p_Circle, _p_CircleTo_p_Shape, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_Square[] = { {&_swigt__p_Square, 0, 0, 0},{0, 0, 0, 0}};
static swig_cast_info _swigc__p_char[] = { {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
 
static swig_cast_info *swig_cast_initial[] = {
_swigc__p_Circle,
_swigc__p_Shape,
_swigc__p_Square,
_swigc__p_char,
};
 
 
/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */
 
/* -----------------------------------------------------------------------------
* Type initialization:
* This problem is tough by the requirement that no dynamic
* memory is used. Also, since swig_type_info structures store pointers to
* swig_cast_info structures and swig_cast_info structures store pointers back
* to swig_type_info structures, we need some lookup code at initialization.
* The idea is that swig generates all the structures that are needed.
* The runtime then collects these partially filled structures.
* The SWIG_InitializeModule function takes these initial arrays out of
* swig_module, and does all the lookup, filling in the swig_module.types
* array with the correct data and linking the correct swig_cast_info
* structures together.
*
* The generated swig_type_info structures are assigned statically to an initial
* array. We just loop through that array, and handle each type individually.
* First we lookup if this type has been already loaded, and if so, use the
* loaded structure instead of the generated one. Then we have to fill in the
* cast linked list. The cast data is initially stored in something like a
* two-dimensional array. Each row corresponds to a type (there are the same
* number of rows as there are in the swig_type_initial array). Each entry in
* a column is one of the swig_cast_info structures for that type.
* The cast_initial array is actually an array of arrays, because each row has
* a variable number of columns. So to actually build the cast linked list,
* we find the array of casts associated with the type, and loop through it
* adding the casts to the list. The one last trick we need to do is making
* sure the type pointer in the swig_cast_info struct is correct.
*
* First off, we lookup the cast->type name to see if it is already loaded.
* There are three cases to handle:
* 1) If the cast->type has already been loaded AND the type we are adding
* casting info to has not been loaded (it is in this module), THEN we
* replace the cast->type pointer with the type pointer that has already
* been loaded.
* 2) If BOTH types (the one we are adding casting info to, and the
* cast->type) are loaded, THEN the cast info has already been loaded by
* the previous module so we just ignore it.
* 3) Finally, if cast->type has not already been loaded, then we add that
* swig_cast_info to the linked list (because the cast->type) pointer will
* be correct.
* ----------------------------------------------------------------------------- */
 
#ifdef __cplusplus
extern "C" {
#if 0
} /* c-mode */
#endif
#endif
 
#if 0
#define SWIGRUNTIME_DEBUG
#endif
 
 
SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
int found, init;
 
/* check to see if the circular list has been setup, if not, set it up */
if (swig_module.next==0) {
/* Initialize the swig_module */
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
init = 1;
} else {
init = 0;
}
 
/* Try and load any already created modules */
module_head = SWIG_GetModule(clientdata);
if (!module_head) {
/* This is the first module loaded for this interpreter */
/* so set the swig module into the interpreter */
SWIG_SetModule(clientdata, &swig_module);
module_head = &swig_module;
} else {
/* the interpreter has loaded a SWIG module, but has it loaded this one? */
found=0;
iter=module_head;
do {
if (iter==&swig_module) {
found=1;
break;
}
iter=iter->next;
} while (iter!= module_head);
 
/* if the is found in the list, then all is done and we may leave */
if (found) return;
/* otherwise we must add out module into the list */
swig_module.next = module_head->next;
module_head->next = &swig_module;
}
 
/* When multiple interpreters are used, a module could have already been initialized in
a different interpreter, but not yet have a pointer in this interpreter.
In this case, we do not want to continue adding types... everything should be
set up already */
if (init == 0) return;
 
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
#endif
for (i = 0; i < swig_module.size; ++i) {
swig_type_info *type = 0;
swig_type_info *ret;
swig_cast_info *cast;
 
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
#endif
 
/* if there is another module already loaded */
if (swig_module.next != &swig_module) {
type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
}
if (type) {
/* Overwrite clientdata field */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: found type %s\n", type->name);
#endif
if (swig_module.type_initial[i]->clientdata) {
type->clientdata = swig_module.type_initial[i]->clientdata;
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: found and overwrite type %s \n", type->name);
#endif
}
} else {
type = swig_module.type_initial[i];
}
 
/* Insert casting types */
cast = swig_module.cast_initial[i];
while (cast->type) {
 
/* Don't need to add information already in the list */
ret = 0;
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: look cast %s\n", cast->type->name);
#endif
if (swig_module.next != &swig_module) {
ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
#ifdef SWIGRUNTIME_DEBUG
if (ret) printf("SWIG_InitializeModule: found cast %s\n", ret->name);
#endif
}
if (ret) {
if (type == swig_module.type_initial[i]) {
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: skip old type %s\n", ret->name);
#endif
cast->type = ret;
ret = 0;
} else {
/* Check for casting already in the list */
swig_cast_info *ocast = SWIG_TypeCheck(ret->name, type);
#ifdef SWIGRUNTIME_DEBUG
if (ocast) printf("SWIG_InitializeModule: skip old cast %s\n", ret->name);
#endif
if (!ocast) ret = 0;
}
}
 
if (!ret) {
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: adding cast %s\n", cast->type->name);
#endif
if (type->cast) {
type->cast->prev = cast;
cast->next = type->cast;
}
type->cast = cast;
}
cast++;
}
/* Set entry in modules->types array equal to the type */
swig_module.types[i] = type;
}
swig_module.types[i] = 0;
 
#ifdef SWIGRUNTIME_DEBUG
printf("**** SWIG_InitializeModule: Cast List ******\n");
for (i = 0; i < swig_module.size; ++i) {
int j = 0;
swig_cast_info *cast = swig_module.cast_initial[i];
printf("SWIG_InitializeModule: type %d %s\n", i, swig_module.type_initial[i]->name);
while (cast->type) {
printf("SWIG_InitializeModule: cast type %s\n", cast->type->name);
cast++;
++j;
}
printf("---- Total casts: %d\n",j);
}
printf("**** SWIG_InitializeModule: Cast List ******\n");
#endif
}
 
/* This function will propagate the clientdata field of type to
* any new swig_type_info structures that have been added into the list
* of equivalent types. It is like calling
* SWIG_TypeClientData(type, clientdata) a second time.
*/
SWIGRUNTIME void
SWIG_PropagateClientData(void) {
size_t i;
swig_cast_info *equiv;
static int init_run = 0;
 
if (init_run) return;
init_run = 1;
 
for (i = 0; i < swig_module.size; i++) {
if (swig_module.types[i]->clientdata) {
equiv = swig_module.types[i]->cast;
while (equiv) {
if (!equiv->converter) {
if (equiv->type && !equiv->type->clientdata)
SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
}
equiv = equiv->next;
}
}
}
}
 
#ifdef __cplusplus
#if 0
{ /* c-mode */
#endif
}
#endif
 
 
static bool is_loaded = false;
void SWIG_Matlab_LoadModule(const char* name) {
SWIG_InitializeModule(0);
SWIG_PropagateClientData();
if(false){
mexErrMsgIdAndTxt("SWIG:LoadFailure","Could not load module %s",name);
}
}
 
 
extern "C"
void mexFunction(int resc, mxArray *resv[], int argc, const mxArray *argv[]){
if(!is_loaded){
SWIG_Matlab_LoadModule(SWIG_name_d);
is_loaded=true;
}
char cmd[256];
if(argc < 1 || mxGetString(argv[0], cmd, sizeof(cmd)))
mexWarnMsgTxt("First input should be a command string less than 256 characters long.");
if(!strcmp("delete_Shape",cmd)){
_wrap_delete_Shape(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Shape_move",cmd)){
_wrap_Shape_move(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Shape_area",cmd)){
_wrap_Shape_area(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Shape_perimeter",cmd)){
_wrap_Shape_perimeter(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("new_Circle",cmd)){
_wrap_new_Circle(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Circle_area",cmd)){
_wrap_Circle_area(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Circle_foo",cmd)){
_wrap_Circle_foo(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Circle_perimeter",cmd)){
_wrap_Circle_perimeter(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("delete_Circle",cmd)){
_wrap_delete_Circle(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("new_Square",cmd)){
_wrap_new_Square(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Square_area",cmd)){
_wrap_Square_area(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("Square_perimeter",cmd)){
_wrap_Square_perimeter(resc,resv,argc-1,(mxArray**)(argv+1));
} else if(!strcmp("delete_Square",cmd)){
_wrap_delete_Square(resc,resv,argc-1,(mxArray**)(argv+1));
} else {
mexWarnMsgIdAndTxt("SWIG","No command %s.",cmd);
}
}
ghorn commented

So you're using strings to reduce the number of mexFunctions?

Owner

So you're using strings to reduce the number of mexFunctions?

mexFunctions have a single entry point and it makes it much easier if we can have just one mexFunctions per SWIG module. I use strings in the current version. In a future version, it probably makes sense to replace it with an index for efficiency. In particular it makes it very simple to compile. To compile the above all you need to do is to call "mex example_wrap.cxx example.cxx" from MATLAB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.