durable_rules 0.34.47 → 0.34.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c244607aab331ef3e18e6251cd5b01a5dfb2a71
4
- data.tar.gz: 0bec05ac51c6379c7b906d050622a78e534092ab
3
+ metadata.gz: 48d84abbe4090ab34d7cdc91409cf4d8051afce1
4
+ data.tar.gz: 196e6c8eb885f12d46a32deaaf6d6d0161e6ec44
5
5
  SHA512:
6
- metadata.gz: a6b9c5cbe40df7dee845ad23682a13bfc730c444e3f3b1586778cd259d0d41f2a28bd4070b9ff0f873158055b8afd31483f6f70bc2ca0bb6036592a8b6964811
7
- data.tar.gz: 7bffaa80fb9a37adc92c26e41238269bf8164f0044817002449ad93b1ace7f829d004b1a0e160cc52ff3331a610a02f1c955bb48913f6943118a029424f1d780
6
+ metadata.gz: 109df08236d6b157e1f631ea502960ae5205ecdeef2a7bb55769978bbd7b62f1b4988e5154b602f6a2ac125c2927956bf39e3bce48add692549d4fc58b7a6e5c
7
+ data.tar.gz: 8971e18c1d4b4a479e29712db7fa3fec15de5df1c511aa7bf705fcf6da0e10d1a5ecf9b0a705b15cd92bdb8501b31b66888702ba68980a82278ea3902cfa5f98
data/src/rules/events.c CHANGED
@@ -1430,7 +1430,7 @@ static unsigned int handleMessage(ruleset *tree,
1430
1430
  rulesBinding);
1431
1431
  }
1432
1432
 
1433
- static unsigned int handleMessages(void *handle,
1433
+ static unsigned int handleMessages(ruleset *tree,
1434
1434
  unsigned char actionType,
1435
1435
  char *messages,
1436
1436
  char **commands,
@@ -1464,7 +1464,7 @@ static unsigned int handleMessages(void *handle,
1464
1464
 
1465
1465
  lastTemp = *last;
1466
1466
  *last = '\0';
1467
- result = handleMessageCore(handle,
1467
+ result = handleMessageCore(tree,
1468
1468
  NULL,
1469
1469
  first,
1470
1470
  &jo,
@@ -1528,12 +1528,12 @@ static unsigned int handleState(ruleset *tree,
1528
1528
  return result;
1529
1529
  }
1530
1530
 
1531
- static unsigned int handleTimers(void *handle,
1531
+ static unsigned int handleTimers(ruleset *tree,
1532
1532
  char **commands,
1533
1533
  unsigned int *commandCount,
1534
1534
  void **rulesBinding) {
1535
1535
  redisReply *reply;
1536
- unsigned int result = peekTimers(handle, rulesBinding, &reply);
1536
+ unsigned int result = peekTimers(tree, rulesBinding, &reply);
1537
1537
  if (result != RULES_OK) {
1538
1538
  return result;
1539
1539
  }
@@ -1565,7 +1565,7 @@ static unsigned int handleTimers(void *handle,
1565
1565
 
1566
1566
  commands[*commandCount] = command;
1567
1567
  ++*commandCount;
1568
- result = handleMessage(handle,
1568
+ result = handleMessage(tree,
1569
1569
  NULL,
1570
1570
  reply->element[i]->str + 2,
1571
1571
  action,
@@ -1582,14 +1582,14 @@ static unsigned int handleTimers(void *handle,
1582
1582
  return RULES_OK;
1583
1583
  }
1584
1584
 
1585
- static unsigned int startHandleMessage(void *handle,
1585
+ static unsigned int startHandleMessage(ruleset *tree,
1586
1586
  char *message,
1587
1587
  unsigned char actionType,
1588
1588
  void **rulesBinding,
1589
1589
  unsigned int *replyCount) {
1590
1590
  char *commands[MAX_COMMAND_COUNT];
1591
1591
  unsigned int commandCount = 0;
1592
- unsigned int result = handleMessage(handle,
1592
+ unsigned int result = handleMessage(tree,
1593
1593
  NULL,
1594
1594
  message,
1595
1595
  actionType,
@@ -1609,13 +1609,13 @@ static unsigned int startHandleMessage(void *handle,
1609
1609
  return result;
1610
1610
  }
1611
1611
 
1612
- static unsigned int executeHandleMessage(void *handle,
1612
+ static unsigned int executeHandleMessage(ruleset *tree,
1613
1613
  char *message,
1614
1614
  unsigned char actionType) {
1615
1615
  char *commands[MAX_COMMAND_COUNT];
1616
1616
  unsigned int commandCount = 0;
1617
1617
  void *rulesBinding = NULL;
1618
- unsigned int result = handleMessage(handle,
1618
+ unsigned int result = handleMessage(tree,
1619
1619
  NULL,
1620
1620
  message,
1621
1621
  actionType,
@@ -1635,14 +1635,14 @@ static unsigned int executeHandleMessage(void *handle,
1635
1635
  return result;
1636
1636
  }
1637
1637
 
1638
- static unsigned int startHandleMessages(void *handle,
1638
+ static unsigned int startHandleMessages(ruleset *tree,
1639
1639
  char *messages,
1640
1640
  unsigned char actionType,
1641
1641
  void **rulesBinding,
1642
1642
  unsigned int *replyCount) {
1643
1643
  char *commands[MAX_COMMAND_COUNT];
1644
1644
  unsigned int commandCount = 0;
1645
- unsigned int result = handleMessages(handle,
1645
+ unsigned int result = handleMessages(tree,
1646
1646
  actionType,
1647
1647
  messages,
1648
1648
  commands,
@@ -1661,13 +1661,13 @@ static unsigned int startHandleMessages(void *handle,
1661
1661
  return result;
1662
1662
  }
1663
1663
 
1664
- static unsigned int executeHandleMessages(void *handle,
1664
+ static unsigned int executeHandleMessages(ruleset *tree,
1665
1665
  char *messages,
1666
1666
  unsigned char actionType) {
1667
1667
  char *commands[MAX_COMMAND_COUNT];
1668
1668
  unsigned int commandCount = 0;
1669
1669
  void *rulesBinding = NULL;
1670
- unsigned int result = handleMessages(handle,
1670
+ unsigned int result = handleMessages(tree,
1671
1671
  actionType,
1672
1672
  messages,
1673
1673
  commands,
@@ -1695,85 +1695,127 @@ unsigned int complete(void *rulesBinding, unsigned int replyCount) {
1695
1695
  return RULES_OK;
1696
1696
  }
1697
1697
 
1698
- unsigned int assertEvent(void *handle, char *message) {
1699
- return executeHandleMessage(handle, message, ACTION_ASSERT_EVENT);
1698
+ unsigned int assertEvent(unsigned int handle, char *message) {
1699
+ ruleset *tree;
1700
+ RESOLVE_HANDLE(handle, &tree);
1701
+
1702
+ return executeHandleMessage(tree, message, ACTION_ASSERT_EVENT);
1700
1703
  }
1701
1704
 
1702
- unsigned int startAssertEvent(void *handle,
1705
+ unsigned int startAssertEvent(unsigned int handle,
1703
1706
  char *message,
1704
1707
  void **rulesBinding,
1705
1708
  unsigned int *replyCount) {
1706
- return startHandleMessage(handle, message, ACTION_ASSERT_EVENT, rulesBinding, replyCount);
1709
+ ruleset *tree;
1710
+ RESOLVE_HANDLE(handle, &tree);
1711
+
1712
+ return startHandleMessage(tree, message, ACTION_ASSERT_EVENT, rulesBinding, replyCount);
1707
1713
  }
1708
1714
 
1709
- unsigned int assertEvents(void *handle,
1715
+ unsigned int assertEvents(unsigned int handle,
1710
1716
  char *messages) {
1711
- return executeHandleMessages(handle, messages, ACTION_ASSERT_EVENT);
1717
+ ruleset *tree;
1718
+ RESOLVE_HANDLE(handle, &tree);
1719
+
1720
+ return executeHandleMessages(tree, messages, ACTION_ASSERT_EVENT);
1712
1721
  }
1713
1722
 
1714
- unsigned int startAssertEvents(void *handle,
1723
+ unsigned int startAssertEvents(unsigned int handle,
1715
1724
  char *messages,
1716
1725
  void **rulesBinding,
1717
1726
  unsigned int *replyCount) {
1718
- return startHandleMessages(handle, messages, ACTION_ASSERT_EVENT, rulesBinding, replyCount);
1727
+ ruleset *tree;
1728
+ RESOLVE_HANDLE(handle, &tree);
1729
+
1730
+ return startHandleMessages(tree, messages, ACTION_ASSERT_EVENT, rulesBinding, replyCount);
1719
1731
  }
1720
1732
 
1721
- unsigned int retractEvent(void *handle, char *message) {
1722
- return executeHandleMessage(handle, message, ACTION_REMOVE_EVENT);
1733
+ unsigned int retractEvent(unsigned int handle, char *message) {
1734
+ ruleset *tree;
1735
+ RESOLVE_HANDLE(handle, &tree);
1736
+
1737
+ return executeHandleMessage(tree, message, ACTION_REMOVE_EVENT);
1723
1738
  }
1724
1739
 
1725
- unsigned int startAssertFact(void *handle,
1740
+ unsigned int startAssertFact(unsigned int handle,
1726
1741
  char *message,
1727
1742
  void **rulesBinding,
1728
1743
  unsigned int *replyCount) {
1729
- return startHandleMessage(handle, message, ACTION_ASSERT_FACT, rulesBinding, replyCount);
1744
+ ruleset *tree;
1745
+ RESOLVE_HANDLE(handle, &tree);
1746
+
1747
+ return startHandleMessage(tree, message, ACTION_ASSERT_FACT, rulesBinding, replyCount);
1730
1748
  }
1731
1749
 
1732
- unsigned int assertFact(void *handle, char *message) {
1733
- return executeHandleMessage(handle, message, ACTION_ASSERT_FACT);
1750
+ unsigned int assertFact(unsigned int handle, char *message) {
1751
+ ruleset *tree;
1752
+ RESOLVE_HANDLE(handle, &tree);
1753
+
1754
+ return executeHandleMessage(tree, message, ACTION_ASSERT_FACT);
1734
1755
  }
1735
1756
 
1736
- unsigned int startAssertFacts(void *handle,
1757
+ unsigned int startAssertFacts(unsigned int handle,
1737
1758
  char *messages,
1738
- void **rulesBinding,
1739
- unsigned int *replyCount) {
1740
- return startHandleMessages(handle, messages, ACTION_ASSERT_FACT, rulesBinding, replyCount);
1759
+ void **rulesBinding,
1760
+ unsigned int *replyCount) {
1761
+ ruleset *tree;
1762
+ RESOLVE_HANDLE(handle, &tree);
1763
+
1764
+ return startHandleMessages(tree, messages, ACTION_ASSERT_FACT, rulesBinding, replyCount);
1741
1765
  }
1742
1766
 
1743
- unsigned int assertFacts(void *handle,
1744
- char *messages) {
1745
- return executeHandleMessages(handle, messages, ACTION_ASSERT_FACT);
1767
+ unsigned int assertFacts(unsigned int handle,
1768
+ char *messages) {
1769
+ ruleset *tree;
1770
+ RESOLVE_HANDLE(handle, &tree);
1771
+
1772
+ return executeHandleMessages(tree, messages, ACTION_ASSERT_FACT);
1746
1773
  }
1747
1774
 
1748
- unsigned int retractFact(void *handle, char *message) {
1749
- return executeHandleMessage(handle, message, ACTION_REMOVE_FACT);
1775
+ unsigned int retractFact(unsigned int handle, char *message) {
1776
+ ruleset *tree;
1777
+ RESOLVE_HANDLE(handle, &tree);
1778
+
1779
+ return executeHandleMessage(tree, message, ACTION_REMOVE_FACT);
1750
1780
  }
1751
1781
 
1752
- unsigned int startRetractFact(void *handle,
1782
+ unsigned int startRetractFact(unsigned int handle,
1753
1783
  char *message,
1754
1784
  void **rulesBinding,
1755
1785
  unsigned int *replyCount) {
1756
- return startHandleMessage(handle, message, ACTION_REMOVE_FACT, rulesBinding, replyCount);
1786
+ ruleset *tree;
1787
+ RESOLVE_HANDLE(handle, &tree);
1788
+
1789
+ return startHandleMessage(tree, message, ACTION_REMOVE_FACT, rulesBinding, replyCount);
1757
1790
  }
1758
1791
 
1759
- unsigned int retractFacts(void *handle,
1792
+ unsigned int retractFacts(unsigned int handle,
1760
1793
  char *messages) {
1761
- return executeHandleMessages(handle, messages, ACTION_REMOVE_FACT);
1794
+ ruleset *tree;
1795
+ RESOLVE_HANDLE(handle, &tree);
1796
+
1797
+ return executeHandleMessages(tree, messages, ACTION_REMOVE_FACT);
1762
1798
  }
1763
1799
 
1764
- unsigned int startRetractFacts(void *handle,
1800
+ unsigned int startRetractFacts(unsigned int handle,
1765
1801
  char *messages,
1766
1802
  void **rulesBinding,
1767
1803
  unsigned int *replyCount) {
1768
- return startHandleMessages(handle, messages, ACTION_REMOVE_FACT, rulesBinding, replyCount);
1804
+ ruleset *tree;
1805
+ RESOLVE_HANDLE(handle, &tree);
1806
+
1807
+ return startHandleMessages(tree, messages, ACTION_REMOVE_FACT, rulesBinding, replyCount);
1769
1808
  }
1770
1809
 
1771
- unsigned int assertState(void *handle, char *sid, char *state) {
1810
+ unsigned int assertState(unsigned int handle, char *sid, char *state) {
1811
+ ruleset *tree;
1812
+ RESOLVE_HANDLE(handle, &tree);
1813
+
1772
1814
  char *commands[MAX_COMMAND_COUNT];
1773
1815
  unsigned int commandCount = 0;
1774
1816
  void *rulesBinding = NULL;
1775
1817
 
1776
- unsigned int result = handleState(handle,
1818
+ unsigned int result = handleState(tree,
1777
1819
  state,
1778
1820
  commands,
1779
1821
  &commandCount,
@@ -1791,11 +1833,14 @@ unsigned int assertState(void *handle, char *sid, char *state) {
1791
1833
  return result;
1792
1834
  }
1793
1835
 
1794
- unsigned int assertTimers(void *handle) {
1836
+ unsigned int assertTimers(unsigned int handle) {
1837
+ ruleset *tree;
1838
+ RESOLVE_HANDLE(handle, &tree);
1839
+
1795
1840
  char *commands[MAX_COMMAND_COUNT];
1796
1841
  unsigned int commandCount = 0;
1797
1842
  void *rulesBinding = NULL;
1798
- unsigned int result = handleTimers(handle,
1843
+ unsigned int result = handleTimers(tree,
1799
1844
  commands,
1800
1845
  &commandCount,
1801
1846
  &rulesBinding);
@@ -1812,14 +1857,17 @@ unsigned int assertTimers(void *handle) {
1812
1857
  return RULES_OK;
1813
1858
  }
1814
1859
 
1815
- unsigned int startAction(void *handle,
1860
+ unsigned int startAction(unsigned int handle,
1816
1861
  char **state,
1817
1862
  char **messages,
1818
1863
  void **actionHandle,
1819
1864
  void **actionBinding) {
1865
+ ruleset *tree;
1866
+ RESOLVE_HANDLE(handle, &tree);
1867
+
1820
1868
  redisReply *reply;
1821
1869
  void *rulesBinding;
1822
- unsigned int result = peekAction(handle, &rulesBinding, &reply);
1870
+ unsigned int result = peekAction(tree, &rulesBinding, &reply);
1823
1871
  if (result != RULES_OK) {
1824
1872
  return result;
1825
1873
  }
@@ -1838,15 +1886,18 @@ unsigned int startAction(void *handle,
1838
1886
  return RULES_OK;
1839
1887
  }
1840
1888
 
1841
- unsigned int startUpdateState(void *handle,
1889
+ unsigned int startUpdateState(unsigned int handle,
1842
1890
  void *actionHandle,
1843
1891
  char *state,
1844
1892
  void **rulesBinding,
1845
1893
  unsigned int *replyCount) {
1894
+ ruleset *tree;
1895
+ RESOLVE_HANDLE(handle, &tree);
1896
+
1846
1897
  char *commands[MAX_COMMAND_COUNT];
1847
1898
  unsigned int result = RULES_OK;
1848
1899
  unsigned int commandCount = 0;
1849
- result = handleState(handle,
1900
+ result = handleState(tree,
1850
1901
  state,
1851
1902
  commands,
1852
1903
  &commandCount,
@@ -1862,9 +1913,12 @@ unsigned int startUpdateState(void *handle,
1862
1913
 
1863
1914
  }
1864
1915
 
1865
- unsigned int completeAction(void *handle,
1916
+ unsigned int completeAction(unsigned int handle,
1866
1917
  void *actionHandle,
1867
1918
  char *state) {
1919
+ ruleset *tree;
1920
+ RESOLVE_HANDLE(handle, &tree);
1921
+
1868
1922
  char *commands[MAX_COMMAND_COUNT];
1869
1923
  unsigned int commandCount = 0;
1870
1924
  actionContext *context = (actionContext*)actionHandle;
@@ -1880,7 +1934,7 @@ unsigned int completeAction(void *handle,
1880
1934
  }
1881
1935
 
1882
1936
  ++commandCount;
1883
- result = handleState(handle,
1937
+ result = handleState(tree,
1884
1938
  state,
1885
1939
  commands,
1886
1940
  &commandCount,
@@ -1902,7 +1956,7 @@ unsigned int completeAction(void *handle,
1902
1956
  return RULES_OK;
1903
1957
  }
1904
1958
 
1905
- unsigned int completeAndStartAction(void *handle,
1959
+ unsigned int completeAndStartAction(unsigned int handle,
1906
1960
  unsigned int expectedReplies,
1907
1961
  void *actionHandle,
1908
1962
  char **messages) {
@@ -1959,19 +2013,22 @@ unsigned int completeAndStartAction(void *handle,
1959
2013
  return RULES_OK;
1960
2014
  }
1961
2015
 
1962
- unsigned int abandonAction(void *handle, void *actionHandle) {
2016
+ unsigned int abandonAction(unsigned int handle, void *actionHandle) {
1963
2017
  freeReplyObject(((actionContext*)actionHandle)->reply);
1964
2018
  free(actionHandle);
1965
2019
  return RULES_OK;
1966
2020
  }
1967
2021
 
1968
- unsigned int queueMessage(void *handle, unsigned int queueAction, char *sid, char *destination, char *message) {
2022
+ unsigned int queueMessage(unsigned int handle, unsigned int queueAction, char *sid, char *destination, char *message) {
2023
+ ruleset *tree;
2024
+ RESOLVE_HANDLE(handle, &tree);
2025
+
1969
2026
  void *rulesBinding;
1970
2027
  if (!sid) {
1971
2028
  sid = "0";
1972
2029
  }
1973
2030
 
1974
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
2031
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
1975
2032
  if (result != RULES_OK) {
1976
2033
  return result;
1977
2034
  }
@@ -1979,13 +2036,16 @@ unsigned int queueMessage(void *handle, unsigned int queueAction, char *sid, cha
1979
2036
  return registerMessage(rulesBinding, queueAction, destination, message);
1980
2037
  }
1981
2038
 
1982
- unsigned int startTimer(void *handle, char *sid, unsigned int duration, char manualReset, char *timer) {
2039
+ unsigned int startTimer(unsigned int handle, char *sid, unsigned int duration, char manualReset, char *timer) {
2040
+ ruleset *tree;
2041
+ RESOLVE_HANDLE(handle, &tree);
2042
+
1983
2043
  void *rulesBinding;
1984
2044
  if (!sid) {
1985
2045
  sid = "0";
1986
2046
  }
1987
2047
 
1988
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
2048
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
1989
2049
  if (result != RULES_OK) {
1990
2050
  return result;
1991
2051
  }
@@ -1993,13 +2053,16 @@ unsigned int startTimer(void *handle, char *sid, unsigned int duration, char man
1993
2053
  return registerTimer(rulesBinding, duration, manualReset, timer);
1994
2054
  }
1995
2055
 
1996
- unsigned int cancelTimer(void *handle, char *sid, char *timerName) {
2056
+ unsigned int cancelTimer(unsigned int handle, char *sid, char *timerName) {
2057
+ ruleset *tree;
2058
+ RESOLVE_HANDLE(handle, &tree);
2059
+
1997
2060
  void *rulesBinding;
1998
2061
  if (!sid) {
1999
2062
  sid = "0";
2000
2063
  }
2001
2064
 
2002
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
2065
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
2003
2066
  if (result != RULES_OK) {
2004
2067
  return result;
2005
2068
  }
@@ -2007,13 +2070,16 @@ unsigned int cancelTimer(void *handle, char *sid, char *timerName) {
2007
2070
  return removeTimer(rulesBinding, timerName);
2008
2071
  }
2009
2072
 
2010
- unsigned int renewActionLease(void *handle, char *sid) {
2073
+ unsigned int renewActionLease(unsigned int handle, char *sid) {
2074
+ ruleset *tree;
2075
+ RESOLVE_HANDLE(handle, &tree);
2076
+
2011
2077
  void *rulesBinding;
2012
2078
  if (!sid) {
2013
2079
  sid = "0";
2014
2080
  }
2015
2081
 
2016
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
2082
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
2017
2083
  if (result != RULES_OK) {
2018
2084
  return result;
2019
2085
  }
data/src/rules/net.c CHANGED
@@ -2395,12 +2395,14 @@ static unsigned int loadCommands(ruleset *tree, binding *rulesBinding) {
2395
2395
  return RULES_OK;
2396
2396
  }
2397
2397
 
2398
- unsigned int bindRuleset(void *handle,
2398
+ unsigned int bindRuleset(unsigned int handle,
2399
2399
  char *host,
2400
2400
  unsigned int port,
2401
2401
  char *password,
2402
2402
  unsigned char db) {
2403
- ruleset *tree = (ruleset*)handle;
2403
+ ruleset *tree;
2404
+ RESOLVE_HANDLE(handle, &tree);
2405
+
2404
2406
  bindingsList *list;
2405
2407
  if (tree->bindingsList) {
2406
2408
  list = tree->bindingsList;
data/src/rules/rete.c CHANGED
@@ -58,6 +58,10 @@ typedef struct all {
58
58
  unsigned short expressionsLength;
59
59
  } all;
60
60
 
61
+ unsigned int firstEmptyEntry = 1;
62
+ unsigned int lastEmptyEntry = MAX_HANDLES -1;
63
+ char entriesInitialized = 0;
64
+
61
65
  static unsigned int validateAlgebra(char *rule);
62
66
 
63
67
  static unsigned int createBeta(ruleset *tree,
@@ -1880,7 +1884,8 @@ static unsigned int createTree(ruleset *tree, char *rules) {
1880
1884
  return RULES_OK;
1881
1885
  }
1882
1886
 
1883
- unsigned int createRuleset(void **handle, char *name, char *rules, unsigned int stateCaheSize) {
1887
+ unsigned int createRuleset(unsigned int *handle, char *name, char *rules, unsigned int stateCaheSize) {
1888
+ INITIALIZE_ENTRIES;
1884
1889
 
1885
1890
  #ifdef _PRINT
1886
1891
  printf("%s\n", rules);
@@ -1967,15 +1972,17 @@ unsigned int createRuleset(void **handle, char *name, char *rules, unsigned int
1967
1972
  newNode->type = NODE_ALPHA;
1968
1973
  newNode->value.a.operator = OP_END;
1969
1974
 
1970
- *handle = tree;
1971
-
1972
1975
  // will use random numbers for state stored event mids
1973
1976
  srand(time(NULL));
1977
+
1978
+ CREATE_HANDLE(tree, handle);
1974
1979
  return createTree(tree, rules);
1975
1980
  }
1976
1981
 
1977
- unsigned int deleteRuleset(void *handle) {
1978
- ruleset *tree = (ruleset*)(handle);
1982
+ unsigned int deleteRuleset(unsigned int handle) {
1983
+ ruleset *tree;
1984
+ RESOLVE_HANDLE(handle, &tree);
1985
+
1979
1986
  deleteBindingsList(tree);
1980
1987
  free(tree->nodePool);
1981
1988
  free(tree->nextPool);
@@ -1996,10 +2003,13 @@ unsigned int deleteRuleset(void *handle) {
1996
2003
  }
1997
2004
  free(tree->state);
1998
2005
  free(tree);
2006
+ DELETE_HANDLE(handle);
1999
2007
  return RULES_OK;
2000
2008
  }
2001
2009
 
2002
- unsigned int createClient(void **handle, char *name, unsigned int stateCaheSize) {
2010
+ unsigned int createClient(unsigned int *handle, char *name, unsigned int stateCaheSize) {
2011
+ INITIALIZE_ENTRIES;
2012
+
2003
2013
  ruleset *tree = malloc(sizeof(ruleset));
2004
2014
  if (!tree) {
2005
2015
  return ERR_OUT_OF_MEMORY;
@@ -2033,12 +2043,14 @@ unsigned int createClient(void **handle, char *name, unsigned int stateCaheSize)
2033
2043
  return result;
2034
2044
  }
2035
2045
 
2036
- *handle = tree;
2046
+ CREATE_HANDLE(tree, handle);
2037
2047
  return RULES_OK;
2038
2048
  }
2039
2049
 
2040
- unsigned int deleteClient(void *handle) {
2041
- ruleset *tree = (ruleset*)(handle);
2050
+ unsigned int deleteClient(unsigned int handle) {
2051
+ ruleset *tree;
2052
+ RESOLVE_HANDLE(handle, &tree);
2053
+
2042
2054
  deleteBindingsList(tree);
2043
2055
  free(tree->stringPool);
2044
2056
  free(tree->stateBuckets);
@@ -2054,6 +2066,7 @@ unsigned int deleteClient(void *handle) {
2054
2066
  }
2055
2067
 
2056
2068
  free(tree);
2069
+ DELETE_HANDLE(handle);
2057
2070
  return RULES_OK;
2058
2071
  }
2059
2072
 
data/src/rules/rules.h CHANGED
@@ -10,6 +10,8 @@
10
10
  #define ERR_RULE_BETA_LIMIT_EXCEEDED 8
11
11
  #define ERR_RULE_WITHOUT_QUALIFIER 9
12
12
  #define ERR_SETTING_NOT_FOUND 10
13
+ #define ERR_INVALID_HANDLE 11
14
+ #define ERR_HANDLE_LIMIT_EXCEEDED 12
13
15
  #define ERR_PARSE_VALUE 101
14
16
  #define ERR_PARSE_STRING 102
15
17
  #define ERR_PARSE_NUMBER 103
@@ -56,24 +58,71 @@
56
58
  #define QUEUE_ASSERT_EVENT 2
57
59
  #define QUEUE_RETRACT_FACT 3
58
60
 
61
+ #define MAX_HANDLES 131072
62
+
59
63
  #ifdef __cplusplus
60
64
  extern "C" {
61
65
  #endif
62
66
 
63
- unsigned int createRuleset(void **handle,
67
+
68
+ typedef struct handleEntry {
69
+ void *content;
70
+ unsigned int nextEmptyEntry;
71
+ } handleEntry;
72
+
73
+ handleEntry handleEntries[MAX_HANDLES];
74
+ extern unsigned int firstEmptyEntry;
75
+ extern unsigned int lastEmptyEntry;
76
+ extern char entriesInitialized;
77
+
78
+ #define INITIALIZE_ENTRIES do { \
79
+ if (!entriesInitialized) { \
80
+ for (unsigned int i = 0; i < lastEmptyEntry; ++i) { \
81
+ handleEntries[i].content = NULL; \
82
+ handleEntries[i].nextEmptyEntry = i + 1; \
83
+ } \
84
+ handleEntries[lastEmptyEntry].nextEmptyEntry = 0; \
85
+ entriesInitialized = 1; \
86
+ } \
87
+ } while(0)
88
+
89
+ #define RESOLVE_HANDLE(h, cRef) do { \
90
+ if (h < 1 || h > MAX_HANDLES - 1) return ERR_INVALID_HANDLE; \
91
+ if (!handleEntries[h].content) return ERR_INVALID_HANDLE; \
92
+ *cRef = handleEntries[h].content; \
93
+ } while(0)
94
+
95
+ #define CREATE_HANDLE(c, hRef) do { \
96
+ if (firstEmptyEntry == 0) return ERR_HANDLE_LIMIT_EXCEEDED; \
97
+ handleEntries[firstEmptyEntry].content = c; \
98
+ *hRef = firstEmptyEntry; \
99
+ firstEmptyEntry = handleEntries[firstEmptyEntry].nextEmptyEntry; \
100
+ } while(0)
101
+
102
+ #define DELETE_HANDLE(h) do { \
103
+ if (h < 1 || h > MAX_HANDLES - 1) return ERR_INVALID_HANDLE; \
104
+ if (!handleEntries[h].content) return ERR_INVALID_HANDLE; \
105
+ handleEntries[h].content = NULL; \
106
+ handleEntries[h].nextEmptyEntry = 0; \
107
+ handleEntries[lastEmptyEntry].nextEmptyEntry = h; \
108
+ lastEmptyEntry = h; \
109
+ if (!firstEmptyEntry) firstEmptyEntry = lastEmptyEntry; \
110
+ } while(0)
111
+
112
+ unsigned int createRuleset(unsigned int *handle,
64
113
  char *name,
65
114
  char *rules,
66
115
  unsigned int stateCaheSize);
67
116
 
68
- unsigned int deleteRuleset(void *handle);
117
+ unsigned int deleteRuleset(unsigned int handle);
69
118
 
70
- unsigned int createClient(void **handle,
119
+ unsigned int createClient(unsigned int *handle,
71
120
  char *name,
72
121
  unsigned int stateCaheSize);
73
122
 
74
- unsigned int deleteClient(void *handle);
123
+ unsigned int deleteClient(unsigned int handle);
75
124
 
76
- unsigned int bindRuleset(void *handle,
125
+ unsigned int bindRuleset(unsigned int handle,
77
126
  char *host,
78
127
  unsigned int port,
79
128
  char *password,
@@ -82,111 +131,111 @@ unsigned int bindRuleset(void *handle,
82
131
  unsigned int complete(void *rulesBinding,
83
132
  unsigned int replyCount);
84
133
 
85
- unsigned int assertEvent(void *handle,
134
+ unsigned int assertEvent(unsigned int handle,
86
135
  char *message);
87
136
 
88
- unsigned int startAssertEvent(void *handle,
137
+ unsigned int startAssertEvent(unsigned int handle,
89
138
  char *message,
90
139
  void **rulesBinding,
91
140
  unsigned int *replyCount);
92
141
 
93
- unsigned int assertEvents(void *handle,
142
+ unsigned int assertEvents(unsigned int handle,
94
143
  char *messages);
95
144
 
96
- unsigned int startAssertEvents(void *handle,
145
+ unsigned int startAssertEvents(unsigned int handle,
97
146
  char *messages,
98
147
  void **rulesBinding,
99
148
  unsigned int *replyCount);
100
149
 
101
- unsigned int retractEvent(void *handle,
150
+ unsigned int retractEvent(unsigned int handle,
102
151
  char *message);
103
152
 
104
- unsigned int startAssertFact(void *handle,
153
+ unsigned int startAssertFact(unsigned int handle,
105
154
  char *message,
106
155
  void **rulesBinding,
107
156
  unsigned int *replyCount);
108
157
 
109
- unsigned int assertFact(void *handle,
158
+ unsigned int assertFact(unsigned int handle,
110
159
  char *message);
111
160
 
112
- unsigned int startAssertFacts(void *handle,
161
+ unsigned int startAssertFacts(unsigned int handle,
113
162
  char *messages,
114
163
  void **rulesBinding,
115
164
  unsigned int *replyCount);
116
165
 
117
- unsigned int assertFacts(void *handle,
166
+ unsigned int assertFacts(unsigned int handle,
118
167
  char *messages);
119
168
 
120
- unsigned int retractFact(void *handle,
169
+ unsigned int retractFact(unsigned int handle,
121
170
  char *message);
122
171
 
123
- unsigned int startRetractFact(void *handle,
172
+ unsigned int startRetractFact(unsigned int handle,
124
173
  char *message,
125
174
  void **rulesBinding,
126
175
  unsigned int *replyCount);
127
176
 
128
- unsigned int retractFacts(void *handle,
177
+ unsigned int retractFacts(unsigned int handle,
129
178
  char *messages);
130
179
 
131
- unsigned int startRetractFacts(void *handle,
180
+ unsigned int startRetractFacts(unsigned int handle,
132
181
  char *messages,
133
182
  void **rulesBinding,
134
183
  unsigned int *replyCount);
135
184
 
136
- unsigned int startUpdateState(void *handle,
185
+ unsigned int startUpdateState(unsigned int handle,
137
186
  void *actionHandle,
138
187
  char *state,
139
188
  void **rulesBinding,
140
189
  unsigned int *replyCount);
141
190
 
142
- unsigned int assertState(void *handle,
191
+ unsigned int assertState(unsigned int handle,
143
192
  char *sid,
144
193
  char *state);
145
194
 
146
- unsigned int startAction(void *handle,
195
+ unsigned int startAction(unsigned int handle,
147
196
  char **state,
148
197
  char **messages,
149
198
  void **actionHandle,
150
199
  void **actionBinding);
151
200
 
152
- unsigned int completeAction(void *handle,
201
+ unsigned int completeAction(unsigned int handle,
153
202
  void *actionHandle,
154
203
  char *state);
155
204
 
156
- unsigned int completeAndStartAction(void *handle,
205
+ unsigned int completeAndStartAction(unsigned int handle,
157
206
  unsigned int expectedReplies,
158
207
  void *actionHandle,
159
208
  char **messages);
160
209
 
161
- unsigned int abandonAction(void *handle,
210
+ unsigned int abandonAction(unsigned int handle,
162
211
  void *actionHandle);
163
212
 
164
- unsigned int startTimer(void *handle,
213
+ unsigned int startTimer(unsigned int handle,
165
214
  char *sid,
166
215
  unsigned int duration,
167
216
  char manualReset,
168
217
  char *timer);
169
218
 
170
- unsigned int cancelTimer(void *handle,
219
+ unsigned int cancelTimer(unsigned int handle,
171
220
  char *sid,
172
221
  char *timerName);
173
222
 
174
- unsigned int queueMessage(void *handle,
223
+ unsigned int queueMessage(unsigned int handle,
175
224
  unsigned int queueAction,
176
225
  char *sid,
177
226
  char *destination,
178
227
  char *message);
179
228
 
180
- unsigned int assertTimers(void *handle);
229
+ unsigned int assertTimers(unsigned int handle);
181
230
 
182
- unsigned int getState(void *handle,
231
+ unsigned int getState(unsigned int handle,
183
232
  char *sid,
184
233
  char **state);
185
234
 
186
- unsigned int deleteState(void *handle,
235
+ unsigned int deleteState(unsigned int handle,
187
236
  char *sid);
188
237
 
189
- unsigned int renewActionLease(void *handle,
238
+ unsigned int renewActionLease(unsigned int handle,
190
239
  char *sid);
191
240
 
192
241
  #ifdef _WIN32
data/src/rules/state.c CHANGED
@@ -503,19 +503,19 @@ static unsigned int resolveBindingAndEntry(ruleset *tree,
503
503
  return RULES_OK;
504
504
  }
505
505
 
506
- unsigned int resolveBinding(void *handle,
506
+ unsigned int resolveBinding(void *tree,
507
507
  char *sid,
508
508
  void **rulesBinding) {
509
509
  stateEntry *entry = NULL;
510
- return resolveBindingAndEntry(handle, sid, &entry, rulesBinding);
510
+ return resolveBindingAndEntry(tree, sid, &entry, rulesBinding);
511
511
  }
512
512
 
513
- unsigned int refreshState(void *handle,
513
+ unsigned int refreshState(void *tree,
514
514
  char *sid) {
515
515
  unsigned int result;
516
516
  stateEntry *entry = NULL;
517
517
  void *rulesBinding;
518
- result = resolveBindingAndEntry(handle, sid, &entry, &rulesBinding);
518
+ result = resolveBindingAndEntry(tree, sid, &entry, &rulesBinding);
519
519
  if (result != RULES_OK) {
520
520
  return result;
521
521
  }
@@ -585,13 +585,16 @@ unsigned int fetchStateProperty(void *tree,
585
585
  return RULES_OK;
586
586
  }
587
587
 
588
- unsigned int getState(void *handle, char *sid, char **state) {
588
+ unsigned int getState(unsigned int handle, char *sid, char **state) {
589
+ ruleset *tree;
590
+ RESOLVE_HANDLE(handle, &tree);
591
+
589
592
  void *rulesBinding = NULL;
590
593
  if (!sid) {
591
594
  sid = "0";
592
595
  }
593
596
 
594
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
597
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
595
598
  if (result != RULES_OK) {
596
599
  return result;
597
600
  }
@@ -599,9 +602,9 @@ unsigned int getState(void *handle, char *sid, char **state) {
599
602
  return getSession(rulesBinding, sid, state);
600
603
  }
601
604
 
602
- unsigned int getStateVersion(void *handle, char *sid, unsigned long *stateVersion) {
605
+ unsigned int getStateVersion(void *tree, char *sid, unsigned long *stateVersion) {
603
606
  void *rulesBinding = NULL;
604
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
607
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
605
608
  if (result != RULES_OK) {
606
609
  return result;
607
610
  }
@@ -610,17 +613,20 @@ unsigned int getStateVersion(void *handle, char *sid, unsigned long *stateVersio
610
613
  }
611
614
 
612
615
 
613
- unsigned int deleteState(void *handle, char *sid) {
616
+ unsigned int deleteState(unsigned int handle, char *sid) {
617
+ ruleset *tree;
618
+ RESOLVE_HANDLE(handle, &tree);
619
+
614
620
  if (!sid) {
615
621
  sid = "0";
616
622
  }
617
623
 
618
624
  void *rulesBinding = NULL;
619
- unsigned int result = resolveBinding(handle, sid, &rulesBinding);
625
+ unsigned int result = resolveBinding(tree, sid, &rulesBinding);
620
626
  if (result != RULES_OK) {
621
627
  return result;
622
628
  }
623
629
 
624
630
  unsigned int sidHash = fnv1Hash32(sid, strlen(sid));
625
- return deleteSession(handle, rulesBinding, sid, sidHash);
631
+ return deleteSession(tree, rulesBinding, sid, sidHash);
626
632
  }
data/src/rules/state.h CHANGED
@@ -74,6 +74,6 @@ unsigned int fetchStateProperty(void *tree,
74
74
  char **state,
75
75
  jsonProperty **property);
76
76
 
77
- unsigned int getStateVersion(void *handle,
77
+ unsigned int getStateVersion(void *tree,
78
78
  char *sid,
79
79
  unsigned long *stateVersion);
data/src/rulesrb/rules.c CHANGED
@@ -23,7 +23,7 @@ static VALUE rbCreateRuleset(VALUE self, VALUE name, VALUE rules, VALUE stateCac
23
23
  static VALUE rbDeleteRuleset(VALUE self, VALUE handle) {
24
24
  Check_Type(handle, T_FIXNUM);
25
25
 
26
- unsigned int result = deleteRuleset((void *)FIX2LONG(handle));
26
+ unsigned int result = deleteRuleset(FIX2INT(handle));
27
27
  if (result != RULES_OK) {
28
28
  if (result == ERR_OUT_OF_MEMORY) {
29
29
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -75,9 +75,9 @@ static VALUE rbBindRuleset(VALUE self, VALUE handle, VALUE host, VALUE port, VAL
75
75
 
76
76
  unsigned int result;
77
77
  if (TYPE(password) == T_STRING) {
78
- result = bindRuleset((void *)FIX2LONG(handle), RSTRING_PTR(host), FIX2INT(port), RSTRING_PTR(password), FIX2INT(db));
78
+ result = bindRuleset(FIX2INT(handle), RSTRING_PTR(host), FIX2INT(port), RSTRING_PTR(password), FIX2INT(db));
79
79
  } else if (TYPE(password) == T_NIL) {
80
- result = bindRuleset((void *)FIX2LONG(handle), RSTRING_PTR(host), FIX2INT(port), NULL, FIX2INT(db));
80
+ result = bindRuleset(FIX2INT(handle), RSTRING_PTR(host), FIX2INT(port), NULL, FIX2INT(db));
81
81
  } else {
82
82
  rb_raise(rb_eTypeError, "Wrong argument type for password");
83
83
  }
@@ -115,7 +115,7 @@ static VALUE rbStartAssertEvent(VALUE self, VALUE handle, VALUE event) {
115
115
 
116
116
  unsigned int replyCount;
117
117
  void *rulesBinding = NULL;
118
- unsigned int result = startAssertEvent((void *)FIX2LONG(handle), RSTRING_PTR(event), &rulesBinding, &replyCount);
118
+ unsigned int result = startAssertEvent(FIX2INT(handle), RSTRING_PTR(event), &rulesBinding, &replyCount);
119
119
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
120
120
  VALUE output = rb_ary_new();
121
121
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -136,7 +136,7 @@ static VALUE rbAssertEvent(VALUE self, VALUE handle, VALUE event) {
136
136
  Check_Type(handle, T_FIXNUM);
137
137
  Check_Type(event, T_STRING);
138
138
 
139
- unsigned int result = assertEvent((void *)FIX2LONG(handle), RSTRING_PTR(event));
139
+ unsigned int result = assertEvent(FIX2INT(handle), RSTRING_PTR(event));
140
140
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED || result == ERR_EVENT_OBSERVED) {
141
141
  return INT2FIX(result);
142
142
  } else {
@@ -156,7 +156,7 @@ static VALUE rbQueueAssertEvent(VALUE self, VALUE handle, VALUE sid, VALUE desti
156
156
  Check_Type(destination, T_STRING);
157
157
  Check_Type(event, T_STRING);
158
158
 
159
- unsigned int result = queueMessage((void *)FIX2LONG(handle), QUEUE_ASSERT_EVENT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
159
+ unsigned int result = queueMessage(FIX2INT(handle), QUEUE_ASSERT_EVENT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
160
160
  if (result != RULES_OK) {
161
161
  if (result == ERR_OUT_OF_MEMORY) {
162
162
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -174,7 +174,7 @@ static VALUE rbStartAssertEvents(VALUE self, VALUE handle, VALUE events) {
174
174
 
175
175
  unsigned int replyCount;
176
176
  void *rulesBinding = NULL;
177
- unsigned int result = startAssertEvents((void *)FIX2LONG(handle), RSTRING_PTR(events), &rulesBinding, &replyCount);
177
+ unsigned int result = startAssertEvents(FIX2INT(handle), RSTRING_PTR(events), &rulesBinding, &replyCount);
178
178
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
179
179
  VALUE output = rb_ary_new();
180
180
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -195,7 +195,7 @@ static VALUE rbAssertEvents(VALUE self, VALUE handle, VALUE events) {
195
195
  Check_Type(handle, T_FIXNUM);
196
196
  Check_Type(events, T_STRING);
197
197
 
198
- unsigned int result = assertEvents((void *)FIX2LONG(handle), RSTRING_PTR(events));
198
+ unsigned int result = assertEvents(FIX2INT(handle), RSTRING_PTR(events));
199
199
  if (result != RULES_OK) {
200
200
  if (result == ERR_OUT_OF_MEMORY) {
201
201
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -211,7 +211,7 @@ static VALUE rbRetractEvent(VALUE self, VALUE handle, VALUE event) {
211
211
  Check_Type(handle, T_FIXNUM);
212
212
  Check_Type(event, T_STRING);
213
213
 
214
- unsigned int result = retractEvent((void *)FIX2LONG(handle), RSTRING_PTR(event));
214
+ unsigned int result = retractEvent(FIX2INT(handle), RSTRING_PTR(event));
215
215
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED || result == ERR_EVENT_OBSERVED) {
216
216
  return INT2FIX(result);
217
217
  } else {
@@ -231,7 +231,7 @@ static VALUE rbStartAssertFact(VALUE self, VALUE handle, VALUE fact) {
231
231
 
232
232
  unsigned int replyCount;
233
233
  void *rulesBinding = NULL;
234
- unsigned int result = startAssertFact((void *)FIX2LONG(handle), RSTRING_PTR(fact), &rulesBinding, &replyCount);
234
+ unsigned int result = startAssertFact(FIX2INT(handle), RSTRING_PTR(fact), &rulesBinding, &replyCount);
235
235
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
236
236
  VALUE output = rb_ary_new();
237
237
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -252,7 +252,7 @@ static VALUE rbAssertFact(VALUE self, VALUE handle, VALUE fact) {
252
252
  Check_Type(handle, T_FIXNUM);
253
253
  Check_Type(fact, T_STRING);
254
254
 
255
- unsigned int result = assertFact((void *)FIX2LONG(handle), RSTRING_PTR(fact));
255
+ unsigned int result = assertFact(FIX2INT(handle), RSTRING_PTR(fact));
256
256
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED || result == ERR_EVENT_OBSERVED) {
257
257
  return INT2FIX(result);
258
258
  } else {
@@ -272,7 +272,7 @@ static VALUE rbQueueAssertFact(VALUE self, VALUE handle, VALUE sid, VALUE destin
272
272
  Check_Type(destination, T_STRING);
273
273
  Check_Type(event, T_STRING);
274
274
 
275
- unsigned int result = queueMessage((void *)FIX2LONG(handle), QUEUE_ASSERT_FACT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
275
+ unsigned int result = queueMessage(FIX2INT(handle), QUEUE_ASSERT_FACT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
276
276
  if (result != RULES_OK) {
277
277
  if (result == ERR_OUT_OF_MEMORY) {
278
278
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -290,7 +290,7 @@ static VALUE rbStartAssertFacts(VALUE self, VALUE handle, VALUE facts) {
290
290
 
291
291
  unsigned int replyCount;
292
292
  void *rulesBinding = NULL;
293
- unsigned int result = startAssertFacts((void *)FIX2LONG(handle), RSTRING_PTR(facts), &rulesBinding, &replyCount);
293
+ unsigned int result = startAssertFacts(FIX2INT(handle), RSTRING_PTR(facts), &rulesBinding, &replyCount);
294
294
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
295
295
  VALUE output = rb_ary_new();
296
296
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -311,7 +311,7 @@ static VALUE rbAssertFacts(VALUE self, VALUE handle, VALUE facts) {
311
311
  Check_Type(handle, T_FIXNUM);
312
312
  Check_Type(facts, T_STRING);
313
313
 
314
- unsigned int result = assertFacts((void *)FIX2LONG(handle), RSTRING_PTR(facts));
314
+ unsigned int result = assertFacts(FIX2INT(handle), RSTRING_PTR(facts));
315
315
  if (result != RULES_OK) {
316
316
  if (result == ERR_OUT_OF_MEMORY) {
317
317
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -329,7 +329,7 @@ static VALUE rbStartRetractFact(VALUE self, VALUE handle, VALUE fact) {
329
329
 
330
330
  unsigned int replyCount;
331
331
  void *rulesBinding = NULL;
332
- unsigned int result = startRetractFact((void *)FIX2LONG(handle), RSTRING_PTR(fact), &rulesBinding, &replyCount);
332
+ unsigned int result = startRetractFact(FIX2INT(handle), RSTRING_PTR(fact), &rulesBinding, &replyCount);
333
333
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
334
334
  VALUE output = rb_ary_new();
335
335
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -350,7 +350,7 @@ static VALUE rbRetractFact(VALUE self, VALUE handle, VALUE fact) {
350
350
  Check_Type(handle, T_FIXNUM);
351
351
  Check_Type(fact, T_STRING);
352
352
 
353
- unsigned int result = retractFact((void *)FIX2LONG(handle), RSTRING_PTR(fact));
353
+ unsigned int result = retractFact(FIX2INT(handle), RSTRING_PTR(fact));
354
354
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED || result == ERR_EVENT_OBSERVED) {
355
355
  return INT2FIX(result);
356
356
  } else {
@@ -370,7 +370,7 @@ static VALUE rbQueueRetractFact(VALUE self, VALUE handle, VALUE sid, VALUE desti
370
370
  Check_Type(destination, T_STRING);
371
371
  Check_Type(event, T_STRING);
372
372
 
373
- unsigned int result = queueMessage((void *)FIX2LONG(handle), QUEUE_RETRACT_FACT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
373
+ unsigned int result = queueMessage(FIX2INT(handle), QUEUE_RETRACT_FACT, RSTRING_PTR(sid), RSTRING_PTR(destination), RSTRING_PTR(event));
374
374
  if (result != RULES_OK) {
375
375
  if (result == ERR_OUT_OF_MEMORY) {
376
376
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -388,7 +388,7 @@ static VALUE rbStartRetractFacts(VALUE self, VALUE handle, VALUE facts) {
388
388
 
389
389
  unsigned int replyCount;
390
390
  void *rulesBinding = NULL;
391
- unsigned int result = startRetractFacts((void *)FIX2LONG(handle), RSTRING_PTR(facts), &rulesBinding, &replyCount);
391
+ unsigned int result = startRetractFacts(FIX2INT(handle), RSTRING_PTR(facts), &rulesBinding, &replyCount);
392
392
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
393
393
  VALUE output = rb_ary_new();
394
394
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -409,7 +409,7 @@ static VALUE rbRetractFacts(VALUE self, VALUE handle, VALUE facts) {
409
409
  Check_Type(handle, T_FIXNUM);
410
410
  Check_Type(facts, T_STRING);
411
411
 
412
- unsigned int result = retractFacts((void *)FIX2LONG(handle), RSTRING_PTR(facts));
412
+ unsigned int result = retractFacts(FIX2INT(handle), RSTRING_PTR(facts));
413
413
  if (result != RULES_OK) {
414
414
  if (result == ERR_OUT_OF_MEMORY) {
415
415
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -426,7 +426,7 @@ static VALUE rbAssertState(VALUE self, VALUE handle, VALUE sid, VALUE state) {
426
426
  Check_Type(sid, T_STRING);
427
427
  Check_Type(state, T_STRING);
428
428
 
429
- unsigned int result = assertState((void *)FIX2LONG(handle), RSTRING_PTR(sid), RSTRING_PTR(state));
429
+ unsigned int result = assertState(FIX2INT(handle), RSTRING_PTR(sid), RSTRING_PTR(state));
430
430
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED || result == ERR_EVENT_OBSERVED) {
431
431
  return INT2FIX(result);
432
432
  } else {
@@ -447,7 +447,7 @@ static VALUE rbStartUpdateState(VALUE self, VALUE handle, VALUE actionHandle, VA
447
447
 
448
448
  unsigned int replyCount;
449
449
  void *rulesBinding = NULL;
450
- unsigned int result = startUpdateState((void *)FIX2LONG(handle), (void *)FIX2LONG(actionHandle), RSTRING_PTR(state), &rulesBinding, &replyCount);
450
+ unsigned int result = startUpdateState(FIX2INT(handle), (void *)FIX2LONG(actionHandle), RSTRING_PTR(state), &rulesBinding, &replyCount);
451
451
  if (result == RULES_OK || result == ERR_EVENT_NOT_HANDLED) {
452
452
  VALUE output = rb_ary_new();
453
453
  rb_ary_push(output, INT2FIX(rulesBinding));
@@ -471,7 +471,7 @@ static VALUE rbStartAction(VALUE self, VALUE handle) {
471
471
  char *messages;
472
472
  void *actionHandle;
473
473
  void *actionBinding;
474
- unsigned int result = startAction((void *)FIX2LONG(handle), &state, &messages, &actionHandle, &actionBinding);
474
+ unsigned int result = startAction(FIX2INT(handle), &state, &messages, &actionHandle, &actionBinding);
475
475
  if (result == ERR_NO_ACTION_AVAILABLE) {
476
476
  return Qnil;
477
477
  } else if (result != RULES_OK) {
@@ -495,7 +495,7 @@ static VALUE rbCompleteAction(VALUE self, VALUE handle, VALUE actionHandle, VALU
495
495
  Check_Type(actionHandle, T_FIXNUM);
496
496
  Check_Type(state, T_STRING);
497
497
 
498
- unsigned int result = completeAction((void *)FIX2LONG(handle), (void *)FIX2LONG(actionHandle), RSTRING_PTR(state));
498
+ unsigned int result = completeAction(FIX2INT(handle), (void *)FIX2LONG(actionHandle), RSTRING_PTR(state));
499
499
  if (result != RULES_OK) {
500
500
  if (result == ERR_OUT_OF_MEMORY) {
501
501
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -513,7 +513,7 @@ static VALUE rbCompleteAndStartAction(VALUE self, VALUE handle, VALUE expectedRe
513
513
  Check_Type(actionHandle, T_FIXNUM);
514
514
 
515
515
  char *messages;
516
- unsigned int result = completeAndStartAction((void *)FIX2LONG(handle), FIX2LONG(expectedReplies), (void *)FIX2LONG(actionHandle), &messages);
516
+ unsigned int result = completeAndStartAction(FIX2INT(handle), FIX2LONG(expectedReplies), (void *)FIX2LONG(actionHandle), &messages);
517
517
  if (result == ERR_NO_ACTION_AVAILABLE) {
518
518
  return Qnil;
519
519
  } else if (result != RULES_OK) {
@@ -532,7 +532,7 @@ static VALUE rbAbandonAction(VALUE self, VALUE handle, VALUE actionHandle) {
532
532
  Check_Type(handle, T_FIXNUM);
533
533
  Check_Type(actionHandle, T_FIXNUM);
534
534
 
535
- unsigned int result = abandonAction((void *)FIX2LONG(handle), (void *)FIX2LONG(actionHandle));
535
+ unsigned int result = abandonAction(FIX2INT(handle), (void *)FIX2LONG(actionHandle));
536
536
  if (result != RULES_OK) {
537
537
  if (result == ERR_OUT_OF_MEMORY) {
538
538
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -551,7 +551,7 @@ static VALUE rbStartTimer(VALUE self, VALUE handle, VALUE sid, VALUE duration, V
551
551
  Check_Type(manualReset, T_FIXNUM);
552
552
  Check_Type(timer, T_STRING);
553
553
 
554
- unsigned int result = startTimer((void *)FIX2LONG(handle), RSTRING_PTR(sid), FIX2UINT(duration), FIX2SHORT(manualReset), RSTRING_PTR(timer));
554
+ unsigned int result = startTimer(FIX2INT(handle), RSTRING_PTR(sid), FIX2UINT(duration), FIX2SHORT(manualReset), RSTRING_PTR(timer));
555
555
  if (result != RULES_OK) {
556
556
  if (result == ERR_OUT_OF_MEMORY) {
557
557
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -568,7 +568,7 @@ static VALUE rbCancelTimer(VALUE self, VALUE handle, VALUE sid, VALUE timerName)
568
568
  Check_Type(sid, T_STRING);
569
569
  Check_Type(timerName, T_STRING);
570
570
 
571
- unsigned int result = cancelTimer((void *)FIX2LONG(handle), RSTRING_PTR(sid), RSTRING_PTR(timerName));
571
+ unsigned int result = cancelTimer(FIX2INT(handle), RSTRING_PTR(sid), RSTRING_PTR(timerName));
572
572
  if (result != RULES_OK) {
573
573
  if (result == ERR_OUT_OF_MEMORY) {
574
574
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -583,7 +583,7 @@ static VALUE rbCancelTimer(VALUE self, VALUE handle, VALUE sid, VALUE timerName)
583
583
  static VALUE rbAssertTimers(VALUE self, VALUE handle) {
584
584
  Check_Type(handle, T_FIXNUM);
585
585
 
586
- unsigned int result = assertTimers((void *)FIX2LONG(handle));
586
+ unsigned int result = assertTimers(FIX2INT(handle));
587
587
  if (result == RULES_OK) {
588
588
  return INT2FIX(1);
589
589
  } else if (result == ERR_NO_TIMERS_AVAILABLE) {
@@ -604,7 +604,7 @@ static VALUE rbGetState(VALUE self, VALUE handle, VALUE sid) {
604
604
  Check_Type(sid, T_STRING);
605
605
 
606
606
  char *state;
607
- unsigned int result = getState((void *)FIX2LONG(handle), RSTRING_PTR(sid), &state);
607
+ unsigned int result = getState(FIX2INT(handle), RSTRING_PTR(sid), &state);
608
608
  if (result != RULES_OK) {
609
609
  if (result == ERR_OUT_OF_MEMORY) {
610
610
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -622,7 +622,7 @@ static VALUE rbDeleteState(VALUE self, VALUE handle, VALUE sid) {
622
622
  Check_Type(handle, T_FIXNUM);
623
623
  Check_Type(sid, T_STRING);
624
624
 
625
- unsigned int result = deleteState((void *)FIX2LONG(handle), RSTRING_PTR(sid));
625
+ unsigned int result = deleteState(FIX2INT(handle), RSTRING_PTR(sid));
626
626
  if (result != RULES_OK) {
627
627
  if (result == ERR_OUT_OF_MEMORY) {
628
628
  rb_raise(rb_eNoMemError, "Out of memory");
@@ -638,7 +638,7 @@ static VALUE rbRenewActionLease(VALUE self, VALUE handle, VALUE sid) {
638
638
  Check_Type(handle, T_FIXNUM);
639
639
  Check_Type(sid, T_STRING);
640
640
 
641
- unsigned int result = renewActionLease((void *)FIX2LONG(handle), RSTRING_PTR(sid));
641
+ unsigned int result = renewActionLease(FIX2INT(handle), RSTRING_PTR(sid));
642
642
  if (result != RULES_OK) {
643
643
  if (result == ERR_OUT_OF_MEMORY) {
644
644
  rb_raise(rb_eNoMemError, "Out of memory");
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: durable_rules
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.34.47
4
+ version: 0.34.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-18 00:00:00.000000000 Z
11
+ date: 2018-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake