javaClassDescriptor.h
Go to the documentation of this file.
1 /*
2  @copyright Russell Standish 2000-2013
3  @author Russell Standish
4  This file is part of Classdesc
5 
6  Open source licensed under the MIT license. See LICENSE for details.
7 */
8 
12 #ifndef JAVACLASSDESCRIPTOR_H
13 #define JAVACLASSDESCRIPTOR_H
14 #include <string>
15 #include "function.h"
16 #include "classdesc.h"
17 #include <exception>
18 
19 namespace classdesc
20 {
21  struct sig_error: public std::exception
22  {
23  const char* what() const throw() {return "Invalid java signature";}
24  };
25 
27  template <class T> struct Descriptor;// {static std::string d();};
28 
29  template <> struct Descriptor<void> {static std::string d() {return "V";}};
30  template <> struct Descriptor<bool> {static std::string d() {return "Z";}};
31  template <> struct Descriptor<signed char> {static std::string d() {return "C";}};
32  template <> struct Descriptor<unsigned char> {static std::string d() {return "C";}};
33  template <> struct Descriptor<short> {static std::string d() {return "S";}};
34  template <> struct Descriptor<unsigned short> {static std::string d() {return "S";}};
35  template <> struct Descriptor<int> {static std::string d() {return "I";}};
36  template <> struct Descriptor<unsigned int> {static std::string d() {return "I";}};
37  template <> struct Descriptor<long> {static std::string d() {
38  if (sizeof(long)==sizeof(int)) return "I";
39  else return "J";}};
40  template <> struct Descriptor<unsigned long> {static std::string d() {
41  if (sizeof(long)==sizeof(int)) return "I";
42  else return "J";}};
43 #ifdef HAVE_LONGLONG
44  template <> struct Descriptor<long long> {static std::string d() {return "J";}};
45  template <> struct Descriptor<unsigned long long> {static std::string d() {return "J";}};
46 #endif
47  template <> struct Descriptor<float> {static std::string d() {return "F";}};
48  template <> struct Descriptor<double> {static std::string d() {return "D";}};
49 
50  template <> struct Descriptor<std::string> {static std::string d() {return "Ljava/lang/String;";}};
51 
52  template <class T> struct Descriptor<const T>
53  {static std::string d() {return Descriptor<T>::d();}};
54 
55  template <class T> struct Descriptor<T&>
56  {static std::string d() {return Descriptor<T>::d();}};
57 
58  template <class T> struct Descriptor<const T&>
59  {static std::string d() {return Descriptor<T>::d();}};
60 
61  template <class F, int i> struct arg_desc;
62 
67  template <class F>
68  struct arg_desc<F,0>
69  {
70  static std::string d() {return std::string();}
71  };
72 
73  template <class F, int i>
74  struct arg_desc
75  {
76  static std::string d() {
78  }
79  };
80 
82  template <class F>
83  std::string arg_description(F f)
85 
86  template <class M>
87  typename enable_if<functional::is_function<M>, std::string>::T
88  descriptor(dummy<0> d=0)
89  {
90  return std::string("(") + arg_desc<M, functional::Arity<M>::V>::d() +
92  }
93 
94  // return Java signature string for type T
95  template <class S>
96  typename enable_if<is_fundamental<S>, std::string>::T
97  descriptor(dummy<2> d=0) {return Descriptor<S>::d();}
98 
99 
100 }
101 #endif
Metaprogramming support for processing functions of multiple arguments.
Descriptor object.
Definition: javaClassDescriptor.h:27
std::string arg_description(F f)
Return a concatenated string of argument descriptors.
Definition: javaClassDescriptor.h:83
Definition: graph.h:537
Definition: javaClassDescriptor.h:61
Definition: javaClassDescriptor.h:21
Contains definitions related to classdesc functionality.
Definition: arrays.h:2514
controlled template specialisation: stolen from boost::enable_if.
Definition: classdesc.h:249
Definition: classdesc.h:266