* In RClangSimple
** clang_getExpansionLocation raises an error
    e = createRoutineBinding(rr[["clang_getExpansionLocation"]], typeMap = map)

** In if (sameType(m[["target"]], type)) return(m) :
       the condition has length > 1 and only the first element will be
       used
       Run all of them.

** When accessing an R string, try to declare const.char *
     clang_getFile it actually is so this would work nicely.
     RGCCTU doesn't get to see this. RCIndex will.
     Added in getNativeDeclaration method for PointerType.

** generating struct code for CXSourceLocation
    ArrayType method of getRTypeName().
    const void * [] for ptr_data field has a bogus (R) type.
    tripped in exists() for logical(0) in defineStructClass
    getRTypeName() is return logical(0) for this type. But it also
    emits a warning "Needs to be fixed".
    So we just make it a vector of the element type. In this case,
    raw() is fine.
    But want to do this more generally, e.g.   complesType foo[2].
    This should be a list. We should have a validity method for
    checking the length. So define a new class and put the length
    there.
*** Compile the structs to remove the warnings about routines to convert structs to R
    Needs a good bit of work
    Avoid recreating and insert the same code for the same data types.
     !!Problem is that getDataStructures() is returning duplicates
      ? Is this because we have typedef and struct declarations and
        ending up with  the same.

*  writing to an array requires a memcpy, not setting the array variable to point to our value.

** Don't generate a copyStruct for CXString

** Problem writing code for CXComment struct
     r code and in the classDefs.
     For some reason, the generateStructInterface() return the defn
     for CXTranslationUnit (a field in the struct) in classDefs.
     This is a dependency, but it shouldn't be in classDefs.
     Seem to be generated in defineStructClass().

* remove the new_unsigned_int() call in the R code for a pointer to a unsigned_int. 
    Make it NULL.
   If the caller wants to do this, then they can.

* Implement getCharArrayPtr(SEXP) in RConverters.c

* [Done] char ** is charPtr in createTranslationUnitFromSourceFile

    getRemappingsFromFileList
    Why isn't this an out parameter. It isn't in this case, but could be.

* getOverriddenCursors   & tokenize
    CXCursor **, CXTokenPtrPtr
    wrong type being passed 

* [Done] getDefinitionSpellingAndExtent
     2 pointer args not declared.
     wrong types

*  void type for local variable 
    The TU parsing code isn't chasing down the name correctly.
    in clang_getExpansionLocation()
    Looks like for the CXFile *file parameter (#2)
    Also, NA for dereferncing r_arg2 type in getExpansionLocation 


    Type in GCCTU description is void **.
    Should we wait until we have RClangSimple working to read these,
    i.e. bootstrap itself.
 

**    [Working] Also, pointer types to REAL() for unsigned int are wrong.
      Need to  use a local variable and then insert into the numeric/REAL if
      it is passed by the caller.  So different strategy in the code
      for unsigned int.
      We can just create the ScalarReal() ourselves rather than using
      the one that was passed to us.
      Perhaps extra case is that we are given an R object which is an
      external ptr and we want to use that. In that case, we might
      want to leave the copy stuff

* Should we reset the length of r_ans to r_ctr when we are finished collecting the out parameters 
   if there are NAs in r__copy, this will too long.

* undeclared pointer variable acting as a proxy.
    indexSourceFile

* generate code for all the enum types
    specifically the C converter code to allow tmp.c to be compiled.

* struct convert for IndexerCallbacks.
    indexSourceFile()

* ============= 

* Allow user to mark some types as being read-only, not ones we can create from R
    e.g. CXCursor types, etc. in RCIndex.

* Allow adding hints to indicate what are input and output variables.
  Can we just add const to inputs that are pointers.

* Allow user to specify opaque data types for which we don't want to generate accessors 
    CXTranslationUnit in RCIndex is an example of wherethe struct is
    not visible.

* For unsigned integers mapped to numeric, add a validity method. 
   Define a class and change the R methods that coerce to and from R, etc.


* change how we generate the routines

* Merge code for RGCCTranslationUnit and RClangSimple.

* Seem to be confusing union and struct. 
  See ds and CUctx_st
** CUmodule, etc. don't seem to be in the ds list.
    CUdevice is

* [Check] process cudaMemcpy3DParms struct type
   It contains nested structures
   b = generateStructInterface(ds[["cudaMemcpy3DParms"]], dc)
**  Need to get dependencies.
**  [Check] set_srcArray and cudaArray type.
**  [Done] cudaMemcpyKind missing enum in set_kind in the cast, but it is in  the declaration.
**  [Done] no ; in coerce struct to ptr:  ans->srcArray = DEREF_REF_PTR( tmp ,  cudaArray_t )
**  [Done]  no ;  or enum qualifier in cast in:     ans->kind = ( cudaMemcpyKind ) INTEGER( tmp )[0];


* The const in parameters, e.g.
   Did gcc stop giving us this in the TU?

* Create the declarations file and reference it.
   need to include all of the declarations, adding to the declarations
   file.
   [Done] declarations.h

* Allow specifying which functions should be made private so that we can build on them manually to provide a more R-like interface
  i.e. with a prefix in the name.
  Added parameters for createRoutineBinding

* [Check] when returning an enum, should we put the name on it in the C code or in the R code.
   [Done] Check other cases where we convert the values, e.g. from a struct field.
   [Done] Currently, not doing it in either. e.g. cudaGetDeviceProperties().
   [No] Need to compute the enums first and make them available to the code
       already there
   generating the routines (createRoutineBinding()).
   [Done] Should we remove the namespace prefix, e.g. cudaError::


* Remove the indentation in the C code we generate for the routine definition.
    Seems like it is only for the enums, not  the bitwise routines.
    It is in formatCode().

* memset structures/memory we allocate.
   and all of their fields.
   Make it optional?

* identify status variables such as cudaError_t and add code to identify when an error occurred
   Do this at the library level by allow the R programmer generating
   the code to specify the name of the status type. Also identify what
   is okay and what is not. Can also generate classes of errors.
   Similarly if it is just an int, but we can specify the routines for
   which this is an error.

* [low] When there are many functions generated, perhaps hide some of them, e.g. the individual accessors for structs. 
  Do we actually create these?

* [low] the code to call the copyStruct routine uses &*arg unnecessarily.

* [check] make the addDot in createRoutineBinding() more sane.
   If specify rfuncName, the dot isn't added. Only used in the default
   value of rfuncName.

* ======================

* [more] In calls to GET_SLOT, ensure that we protect the object and then unprotect it.
   Just the asInteger() or equivalent - so okay.

* [low] check R code for struct.
   sources() w/o error.
   * do we want arrays to have a default/prototype value with the same
     length, e.g. maxThreadsDim be integer(3), in the R class for the
     struct.

* ----------------

* [Done] Get RClangSimple working again.

* [Done] Generating enum converters in C code gets the name wrong for typedef'ed enums.
   puts the enum in front of the typedef.

* [Done] bitwise_enum_convert routine not in header file RConverters.h

* [Done] allow files argument in getDataStructures() to be a function to filter. 
   Like getRoutines()


* [Done] Why is devProp.R example seg faulting if we use .copy = TRUE (the default)
   We didn't have the declaration of the R_copyStruct routine and so C
   warned us and used an int.


* [Done] Remove call to library(RAutoGenRunTime)
   Allow the caller to pass a character vector of packages to be
   loaded. Shouldn't need this.
   If this is for use in an R session, they can load the packages
   themselves.
   If this is for a package, it should be an import.

   Doesn't work for writing proxy functions corresponding to C
   routines we generate. Easy to add but not worth it really.


* [Done] Check size_t being converted correctly, e.g. p$memPitch in devProp.R
   returned as an integer, but slot is a numeric in the R class.
   But the code for copying a struct * with this field uses
   ScalarInteger.  Similarly in get method. And in set method (coerce
   with asInteger()).

* [Done] Change the names of parameters to be a, b, c, rather than r8428.
     Do this when we create the descriptions of the routines
     arg1, arg2, ....


* [Done] Fix conversion of character array to an R string. p$name in devProp.R


* [Done] Check if finalizers are being called.
   Yes, they work, but are not enabled by default. They are now.
   [Done] Allow code generator to specify if this should be true or false. generateStructInterface()
      library(RCUDA)
      prop = new_cudaDeviceProp()
      rm(prop)
      gc(); gc(); gc()
 
      Trace addFinalizer

* [Done] Remove debugging print statement from finalizer.
    Can enable it with the preprocessor define DEBUG_R_FINALIZERS


* [Done] parsing the +Inf in 'valu: +Inf' attributes


* [Done] Put name on the copyStruct C routine created by generateStructInterface

* [Done] Fix warnings & errors from calls to convertIntArrayToR
   [Done] convertValueToR for parm = ArrayType  (convertValueToR.R:176)
   [Done] Resolve the differences between convertCharArrayToR() and
   [Done] convertIntArrayToR(). make the signatures the same.
   [Done] What is the copy and the dim and the front? - Not used.
   Can't specify the dims as sequential arguments. Make them [a,b,c]


* [Done] Missing ans->fieldName =  and ; when setting an integer.
  occurring in the coerce_struct_to_struct* method
     looks like it is getCopyFieldCode


* [Done] Remove unused variables
  i in R_cudaDevicePropPtr_set_name
   { i; convertRCharacterToCharArray }
  Part of coerce method for struct to struct * and also in set for field.

* [Done] Don't put backticks on variable names that don't need them, 
  e.g.  in newInst$r for a struct.
   dc = DefinitionContainer(tu)
   ss = generateStructInterface(ds[['cudaDeviceProp']], dc)

* [Done] Option to not generate code for other types recursively.
  ? or does it actually do this for structs ? No, it just generates
  a lot of code due to the C routines to set/get the fields, coercion
  to and from R, pointers and instances, etc.

* [Done] accessors for struct fields getting the initializer for the asInteger() wrong.
    ; before that code.
    see makeCFieldAccessorRoutine

* [Done] remove the extra return(r_obj) that is added, at least, in get_<fieldName>

* [Done] output on console of void * ptr_data [ n ]  (n is  a literal number)
   related to having a type map.
   Seems to be for CXFileUniquID struct and other structs.
   In show.R for StructDefinition method for character.


* [Done] CXTranslationUnit not getting dereferenced correctly
      DEREF_PTR() issue also found in RCUDA.
