c++ static methods and inheritance in templates with overloading -


it's first post here, have looked answer days, have ask. complex construction. embed spidermonkey javascript engine in illustrator plugin. illustrator has complicate , inconsistent api. in case have call method having short type parameter:

namespace ai { ... typedef signed short    int16; ... }; 

the method referred pointer in struct:

struct aidocumentsuite { ...     aiapi aierr (*getdocumentrulerunits) ( ai::int16 *units ); ... }; 

but, enum source of parameter:

enum aidocumentrulerunitvalue {     kunknownunits = 0,     /** inches */     kinchesunits,     /** centimeters */     kcentimetersunits,     /** points */     kpointsunits,     /** picas */     kpicasunits,     /** millimeters */     kmillimetersunits,     /** pixels */     kpixelsunits,     /** q units */     kqunits }; 

i have wrapped these in classes in order have javascript objects managed spidermonkey. have following working call somewhere in code (a bit simplified, cleaned of tests verifications):

ai::int16 aidocumentrulerunitvalue; aierr aierr = saidocument->getdocumentrulerunits(&aidocumentrulerunitvalue);  ...              if (!jsaidocumentrulerunitvalue::fromaiobject<jsaidocumentrulerunitvalue>(cx, &aidocumentrulerunitvalue, value))                 return false;  ...             jsproperty::setproperty(cx, &obj, "value", value, true);  ... 

my issue fromaiobject.

i have template base class:

template<typename t> class jsbasedataclass : public jsbaseclass { public: ...      template <typename jst> static bool fromaiobject(jscontext *cx, t* aiobj, jsobject*& obj)     { ... return true;     } } 

and derived class:

class jsaidocumentrulerunitvalue : public jsbasedataclass<aidocumentrulerunitvalue> { public: ...     template <typename jst> static bool fromaiobject(jscontext *cx, ai::int16* aiint16, jsobject*& obj)     {         aidocumentrulerunitvalue aidocumentrulerunitvalue = static_cast<aidocumentrulerunitvalue>(*aiint16);          return jsenumdataclass<jsbaseclass>::fromaiobject<jsaidocumentrulerunitvalue>(cx, &aidocumentrulerunitvalue, obj);     }  ... } 

now, issue: if write in latter one:

jsaidocumentrulerunitvalue::fromaiobject<jsaidocumentrulerunitvalue>(cx, &aidocumentrulerunitvalue, obj); 

it try call method in derived class (with parameter of type ai::int16 = signed short).

if method in derived class wouldn't exist, call method parent class, regardless type of second parameter.

i wish able suitable method based on parameters. make me having copy in each derived class of both methods (if necessary, or @ least copy of default one).

what doing wrong or how make them behave in non static method overloading inheritance?

thank you.

do that.

class base { public:     static void method(std::string someparam); }  class derived : public base { public:     using base::method;     static void method(int param); } 

the point using using keyword making base class's functions visible.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -