# This file was automatically generated by SWIG (http://www.swig.org).
# Version 2.0.7
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.

##   Generated via the command line invocation:
##	 swig -c++ -Isrc -module ChemmineR -o src/r_wrap.cc -r -outdir R swig.i


#                         srun.swg                            #
#
# This is the basic code that is needed at run time within R to
# provide and define the relevant classes.  It is included
# automatically in the generated code by copying the contents of
# srun.swg into the newly created binding code.


# This could be provided as a separate run-time library but this
# approach allows the code to to be included directly into the
# generated bindings and so removes the need to have and install an
# additional library.  We may however end up with multiple copies of
# this and some confusion at run-time as to which class to use. This
# is an issue when we use NAMESPACES as we may need to export certain
# classes.

######################################################################

if(length(getClassDef("RSWIGStruct")) == 0) 
  setClass("RSWIGStruct", representation("VIRTUAL"))



if(length(getClassDef("ExternalReference")) == 0) 
# Should be virtual but this means it loses its slots currently
#representation("VIRTUAL")
  setClass("ExternalReference", representation( ref = "externalptr"))



if(length(getClassDef("NativeRoutinePointer")) == 0) 
  setClass("NativeRoutinePointer", 
              representation(parameterTypes = "character",
                             returnType = "character",
                             "VIRTUAL"), 
              contains = "ExternalReference")

if(length(getClassDef("CRoutinePointer")) == 0) 
  setClass("CRoutinePointer", contains = "NativeRoutinePointer")


#if(length(getClassDef("EnumerationValue")) == 0) 
  #setClass("EnumerationValue", contains = "integer")


if(!isGeneric("copyToR")) 
 setGeneric("copyToR",
            function(value, obj = new(gsub("Ref$", "", class(value)))) 
               standardGeneric("copyToR"
           ))

setGeneric("delete", function(obj) standardGeneric("delete"))


RSWIG_createNewRef = 
function(className, ..., append = TRUE)
{
  f = get(paste("new", className, sep = "_"), mode = "function")

  f(...)
}

if(!isGeneric("copyToC")) 
 setGeneric("copyToC", 
             function(value, obj = RSWIG_createNewRef(class(value)))
              standardGeneric("copyToC"
            ))


# 
#defineEnumeration =
#function(name, .values, where = topenv(parent.frame()), suffix = "Value")
#{
#   # Mirror the class definitions via the E analogous to .__C__
#  defName = paste(".__E__", name, sep = "")
#  assign(defName,  .values,  envir = where)
#
#  if(nchar(suffix))
#    name = paste(name, suffix, sep = "")
#
#  setClass(name, contains = "EnumerationValue", where = where)
#}

enumToInteger <- function(name,type)
{
   if (is.character(name)) {
   ans <- as.integer(get(paste(".__E__", type, sep = ""))[name])
   if (is.na(ans)) {warning("enum not found ", name, " ", type)}
   ans
   } 
}

enumFromInteger =
function(i,type)
{
  itemlist <- get(paste(".__E__", type, sep=""))
  names(itemlist)[match(i, itemlist)]
}

coerceIfNotSubclass =
function(obj, type) 
{
    if(!is(obj, type)) {as(obj, type)} else obj
}


#setClass("SWIGArray", representation(dims = "integer"), contains = "ExternalReference")

#setMethod("length", "SWIGArray", function(x) x@dims[1])


#defineEnumeration("SCopyReferences",
#                   .values = c( "FALSE" = 0, "TRUE" = 1, "DEEP" = 2))

assert = 
function(condition, message = "")
{
  if(!condition)
    stop(message)

  TRUE
}


if(FALSE) {
print.SWIGFunction =
function(x, ...)
 {
 }
}


#######################################################################

R_SWIG_getCallbackFunctionStack =
function()
{
    # No PACKAGE argument as we don't know what the DLL is.
  .Call("R_SWIG_debug_getCallbackFunctionData")
}

R_SWIG_addCallbackFunctionStack =
function(fun, userData = NULL)
{
    # No PACKAGE argument as we don't know what the DLL is.
  .Call("R_SWIG_R_pushCallbackFunctionData", fun, userData)
}


#######################################################################


setClass('C++Reference', contains = 'ExternalReference')
setClass('_p_Descriptors', contains = 'C++Reference')



#setMethod('[', "ExternalReference",
#function(x,i,j, ..., drop=TRUE) 
#if (!is.null(x$"__getitem__")) 
#sapply(i, function(n) x$"__getitem__"(i=as.integer(n-1))))
#
#setMethod('[<-' , "ExternalReference",
#function(x,i,j, ..., value) 
#if (!is.null(x$"__setitem__")) {
#sapply(1:length(i), function(n) 
#x$"__setitem__"(i=as.integer(i[n]-1), x=value[n]))
#x
#})

#setAs('ExternalReference', 'character',
#function(from) {if (!is.null(from$"__str__")) from$"__str__"()})

setMethod('print', 'ExternalReference',
function(x) {print(as(x, "character"))})

# Start of new_Descriptors

`Descriptors` = function()
{
  ;ans = .Call('R_swig_new_Descriptors', PACKAGE='ChemmineR');
  class(ans) <- "_p_Descriptors";
  
  reg.finalizer(ans, delete_Descriptors)
  ans
  
}

attr(`Descriptors`, 'returnType') = '_p_Descriptors'
class(`Descriptors`) = c("SWIGFunction", class('Descriptors'))

# Start of Descriptors_parse_sdf

`Descriptors_parse_sdf` = function(self, sdf, .copy = FALSE)
{
  sdf = as(sdf, "character"); 
  ;.Call('R_swig_Descriptors_parse_sdf', self, sdf, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`Descriptors_parse_sdf`, 'returnType') = 'integer'
attr(`Descriptors_parse_sdf`, "inputTypes") = c('_p_Descriptors', 'character')
class(`Descriptors_parse_sdf`) = c("SWIGFunction", class('Descriptors_parse_sdf'))

# Start of Descriptors_parse_sdfile

`Descriptors_parse_sdfile` = function(self, sdfile, .copy = FALSE)
{
  sdfile = as(sdfile, "character"); 
  ;.Call('R_swig_Descriptors_parse_sdfile', self, sdfile, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`Descriptors_parse_sdfile`, 'returnType') = 'integer'
attr(`Descriptors_parse_sdfile`, "inputTypes") = c('_p_Descriptors', 'character')
class(`Descriptors_parse_sdfile`) = c("SWIGFunction", class('Descriptors_parse_sdfile'))

# Start of Descriptors_parse_smiles

`Descriptors_parse_smiles` = function(self, smile, .copy = FALSE)
{
  smile = as(smile, "character"); 
  ;.Call('R_swig_Descriptors_parse_smiles', self, smile, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`Descriptors_parse_smiles`, 'returnType') = 'integer'
attr(`Descriptors_parse_smiles`, "inputTypes") = c('_p_Descriptors', 'character')
class(`Descriptors_parse_smiles`) = c("SWIGFunction", class('Descriptors_parse_smiles'))

# Start of Descriptors_get_descriptor

`Descriptors_get_descriptor` = function(self, i, .copy = FALSE)
{
  if(length(i) > 1) {
    warning("using only the first element of i");
  };
  
  ;.Call('R_swig_Descriptors_get_descriptor', self, i, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`Descriptors_get_descriptor`, 'returnType') = 'integer'
attr(`Descriptors_get_descriptor`, "inputTypes") = c('_p_Descriptors', 'integer')
class(`Descriptors_get_descriptor`) = c("SWIGFunction", class('Descriptors_get_descriptor'))

# Start of Descriptors_get_len

`Descriptors_get_len` = function(self, .copy = FALSE)
{
  ;.Call('R_swig_Descriptors_get_len', self, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`Descriptors_get_len`, 'returnType') = 'integer'
attr(`Descriptors_get_len`, "inputTypes") = c('_p_Descriptors')
class(`Descriptors_get_len`) = c("SWIGFunction", class('Descriptors_get_len'))

# Start of delete_Descriptors

`delete_Descriptors` = function(self)
{
  ;.Call('R_swig_delete_Descriptors', self, PACKAGE='ChemmineR');
  
}

attr(`delete_Descriptors`, 'returnType') = 'void'
attr(`delete_Descriptors`, "inputTypes") = c('_p_Descriptors')
class(`delete_Descriptors`) = c("SWIGFunction", class('delete_Descriptors'))

# Start of accessor method for Descriptors
#setMethod('$', '_p_Descriptors', function(x, name)
#
#{
#  accessorFuns = list('parse_sdf' = Descriptors_parse_sdf, 'parse_sdfile' = Descriptors_parse_sdfile, 'parse_smiles' = Descriptors_parse_smiles, 'get_descriptor' = Descriptors_get_descriptor, 'get_len' = Descriptors_get_len);
#  ;        idx = pmatch(name, names(accessorFuns));
#  if(is.na(idx)) 
#  return(callNextMethod(x, name));
#  f = accessorFuns[[idx]];
#  function(...){
#    f(x, ...)
#  };
#}
#);
# end of accessor method for Descriptors
setMethod('delete', '_p_Descriptors', function(obj) {delete_Descriptors(obj)})
# Start of similarity

`similarity` = function(d1, d2, .copy = FALSE)
{
  ;.Call('R_swig_similarity', d1, d2, as.logical(.copy), PACKAGE='ChemmineR');
  
}

attr(`similarity`, 'returnType') = 'numeric'
attr(`similarity`, "inputTypes") = c('_p_Descriptors', '_p_Descriptors')
class(`similarity`) = c("SWIGFunction", class('similarity'))


