Bug 1863

Summary: python bindings TypeLookupErrror 'int64_t &'
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: python bindingsAssignee: Gustavo J. A. M. Carneiro <gjcarneiro>
Status: RESOLVED FIXED    
Severity: normal CC: alexander.afanasyev, ns-bugs, pdbarnes
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: All   

Description Tom Henderson 2014-02-23 16:50:08 UTC
This can be reproduced with changeset 8e7d67510b46 from 23 Feb 2014, when trying to build with python bindings enabled.

The error raised in nsmodulegen.log for the core module is:

    raise TypeLookupError(tried_names)
pybindgen.typehandlers.base.TypeLookupError: ['int64_t &']

I think (but haven't bisected to be sure) that these are due to these recent changes to nstime.h:

$ hg diff -r ns-3.19 nstime.h  | grep int64_t
+  friend Time operator * (const Time &lhs, const int64_t &rhs);
+  friend Time operator * (const int64_t &lhs, const Time &rhs);
+  friend int64_t operator / (const Time &lhs, const Time &rhs);
+  friend Time operator / (const Time &lhs, const int64_t &rhs);
+operator * (const Time &lhs, const int64_t &rhs)
+operator * (const int64_t &lhs, const Time &rhs)
+inline int64_t
+  int64_t res = lhs.m_data / rhs.m_data;
+operator / (const Time &lhs, const int64_t &rhs)


When I look at pybindgen, this type seems to be defined in the typehandlers as LongLongRef:

class LongLongRefParam(LongLongParam):
    DIRECTIONS = [Parameter.DIRECTION_IN] # other directions not yet implemented
    CTYPES = ['long long&', 'int64_t&', 'long long int&'] 

however, there is a comment that says that only one direction is supported.

I was able to get past this compilation error by manually disabling two bindings:

--- a/src/core/bindings/modulegen__gcc_LP64.py	Sun Feb 23 11:40:20 2014 -0800
+++ b/src/core/bindings/modulegen__gcc_LP64.py	Sun Feb 23 13:44:31 2014 -0800
@@ -2474,10 +2474,10 @@
     return
 
 def register_Ns3Time_methods(root_module, cls):
-    cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
+    #cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
     cls.add_binary_numeric_operator('+', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
     cls.add_binary_numeric_operator('-', root_module['ns3::Time'], root_module['ns3::Time'], param('ns3::Time const &', u'right'))
-    cls.add_binary_numeric_operator('/', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
+    #cls.add_binary_numeric_operator('/', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
     cls.add_binary_comparison_operator('<')
     cls.add_binary_comparison_operator('>')
     cls.add_binary_comparison_operator('!=')

which I committed as a workaround in changeset a258a16d4793
Comment 1 Peter Barnes 2014-02-24 18:03:07 UTC
These operators were introduced in r10592 e2a12de1184d on Jan 29, 2014.
Comment 2 Peter Barnes 2014-02-24 18:04:02 UTC
It would be a little unorthodox, but would changing the argument to pass by value, `int64_t rhs' be another workaround?
Comment 3 Tom Henderson 2014-03-14 15:38:57 UTC
fixed in changeset 10641:b372889aadef
Comment 4 Alex Afanasyev 2014-07-10 00:52:15 UTC
I believe that this issue has been reincarnated in ns-3.20 release (after bindings rescan).  At least I was getting exactly the same error on OSX 10.9 with bindings enabled.  Exactly the same fix solved the problem.