R generated code has identifiers with leading underscores

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

R generated code has identifiers with leading underscores

Ivan Popivanov
Hello,

I am using swig to generate R bindings on a C++ project. The generated R code is not accepted by R. There is a snippet at the end of this email, but it all boils down to swig's use of names with leading underscore. Although one can generate R attributes, types etc with a leading underscore, they cannot be used in an assignment as is 'f <- __ne____SWIG_0'. In R an identifier must not start with an underscore.

Is there an interface file directive to modify the naming? Anything else that can help me?

Thanks,
Ivan

`__ne__` <- function(...) {
  argtypes <- mapply(class, list(...));
  argv <- list(...);
  argc <- length(argtypes);
# dispatch functions 4
  if (argc == 2) {
    if (extends(argtypes[1], '_p_CNTK__DeviceDescriptor') && length(argv[[1]]) == 1 && extends(argtypes[2], '_p_CNTK__DeviceDescriptor') && length(argv[[2]]) == 1) {
      f <- __ne____SWIG_0; 
    }
    else if (extends(argtypes[1], '_p_CNTK__NDShape') && length(argv[[1]]) == 1 && extends(argtypes[2], '_p_CNTK__NDShape') && length(argv[[2]]) == 1) {
      f <- __ne____SWIG_1; 
    }
    else if (extends(argtypes[1], '_p_CNTK__Axis') && length(argv[[1]]) == 1 && extends(argtypes[2], '_p_CNTK__Axis') && length(argv[[2]]) == 1) {
      f <- __ne____SWIG_2; 
    }
    else if (extends(argtypes[1], '_p_CNTK__Variable') && length(argv[[1]]) == 1 && extends(argtypes[2], '_p_CNTK__Variable') && length(argv[[2]]) == 1) {
      f <- __ne____SWIG_3; 
    }
  } else {
    stop("cannot find overloaded function for __ne__ with argtypes (",toString(argtypes),")");
  };
  f(...);
}

------------------------------------------------------------------------------

_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user