Giter Club home page Giter Club logo

cpgf's Introduction

cpgf library

cpgf library is a cross platform C++ library for callback, reflection, serialization and script binding.

It's written in standard C++ and doesn't require any preprocessor or tools.

This project is NOT continued, it will be replaced by substitute projects

There will be substitute projects under development.
If you are looking for C++ reflection library, please check metapp, that's from the same developer of cpgf.
If you are looking for the callback list feature in cpgf, please check eventpp, it's from the same develop of cpgf too.
A metapp based Lua binding project is under development as well.

The problems in cpgf that it can't be continued

1, The project is too ambitious and is too large.

Indeed cpgf is not a single library, it contains many libraries, such as,

  • Callback and callback list
  • Variant
  • Reflection
  • Serialization
  • Lua script binding
  • Python script binding
  • V8 script binding
  • SpiderMonkey script binding
  • Meta data for various libraries
  • Meta data generating tool
  • Tweening library.

Each component is already a very large library by itself. Putting them to a giant cpgf is not manageable even for big software companies.

2, I was too conservative on new technology.

At the time I started the cpgf project, the latest C++ standard was C++03. And C++11 was already drafted, and was partially usable in the compilers. Especially, TR1 was there already.
I chose to stick to C++03, because I wanted my libraries be able to be used in as many as compilers.
That's another big mistake. The different between C++11 and pre-C++11 is nothing like C++03 and pre-03, or between C++14 and C++11. C++11 is a new era of C++.

What will be in the substitute projects

  1. Each project will be small and only focus on one feature. For example, metapp will only focus on reflection feature, there will be no serialization, no script binding, under metapp.
  2. All projects will be using at least C++11. Though C++11 is already old, I feel it's enough for most projects.

Documentations

Documentations

Version

1.6.1

Libraries

  • cpgf reflection -- a library to add reflection feature to C++.

  • cpgf serialization -- a library to save C++ data and objects to persistent storage and then load back. It's based on the reflection library.

  • cpgf script binding -- a script binding engine to bind Lua (5.3, 5.2 and 5.1), Google V8 JavaScript, Python (2.7.3), and Mozilla SpiderMonkey JavaScript to C++. It's based on the reflection library.

  • cpgf callback -- a callback library to implement signal/slot or callback in C++. It's the primary library for other libraries.

  • cpgf meta data collection -- a library with built-in meta data support. Now there are meta data for C++ STL, OpenGL, OpenGLU, OpenGLUT, Box2D physical engine, SFML graphics and multimedia engine and Irrlicht 3D render engine.

  • cpgf meta data generator tool -- a tool writen in Java to automatically generate meta data from Doxygen XML files.

  • cpgf tweening -- a library to implement ease animation in C++.

License

Apache License, Version 2.0 You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Author and owner

Wang Qi, in Beijing, China

Learning the library

Though there are some documentations on the official website, they are far from good. You may understand that developers like coding much more than documenting.

The fastest way to get start with the library is to read the sample code in the folder "samples". The samples cover most features so it's a good kick off.

If you want to read more sample code, read the code in the folder "test". They are for unit test. They are much more difficult to read and use a lot of macros. However, they cover much more functions than the sample code.

A sister project using cpgf

There is a 2D game engine from the cpgf author,

https://github.com/wqking/gincu

The game engine uses cpgf callback, tweening and script binding extensively.

Using the library

  • In the project setting, add an include path pointing to "cpgf/include".
  • Link the source code or link the library in your project.
  • All classes, functions and APIs are in the namespace "cpgf".

Link the source code

To using the library, the easiest way is to just link all .cpp source code under the src and sub folder. However, a build script is also provide to build the code as static library.

Build the library

The library uses CMake as the build system. A makefile is provided to wrap the CMake build. To build the library, open command line terminal, go to folder "build",

The library requires C++ exception and RTTI are enabled.

make PLATFORM

PLATFORM can be one of

nmake mingw linux vc05 vc08 vc10 cb_mingw cb_nmake cb_linux xcode

For detailed PLATFORM information, run "make" without parameter to see the help.

If you are using MSVC, run "nmake" instead of "make".

To build with Lua binding, you must change the variable HAS_LUA and LUA_DIR in build.config.txt to point to the source code of Lua.

To build with Google V8 Javascript binding, you must change the variable HAS_V8 and V8_DIR in build.config.txt to point to the source code of V8.

To build with Python binding, you must change the variable HAS_PYTHON and PYTHON_DIR in build.config.txt to point to the source code of Python.

To build with Mozilla SpiderMonkey binding, you must change the variable HAS_SPIDERMONKEY and SPIDERMONKEY_DIR in build.config.txt to point to the source code of Mozilla SpiderMonkey.

To build the unit test and sample code, feed a second parameter

	make PLATFORM TARGET=TheTarget
TheTarget can be,
TARGET=lib                   Build the library. This is the default if TARGET is omitted.
TARGET=tutorials             Build the tutorials.
TARGET=tests                 Build the unit test.
TARGET=samplereflection      Build the reflection sample application.
TARGET=sampleserialization   Build the serialization sample application.
TARGET=samplelua             Build the Lua binding sample application.
TARGET=sampleopengl          Build the Opengl binding sample application.
TARGET=samplebox2d           Build the Box2D binding sample application.
TARGET=samplesfml            Build the SFML binding sample application.
TARGET=sampleirrlicht        Build the Irrlicht binding sample application.

Compatibility -- Tested compilers and OSes

  • Linux (Ubuntu 18.04), GCC 7.3.0
  • Linux (Ubuntu 18.04, LLVM Clang 5.0.2
  • The below cases were based on the old 1.5 version. Since version 1.6, C++11 compiler is required, and VC 2015 and GCC 4.9.1 were tested.
  • Windows XP, Microsoft Visual C++ 2008 Express and Microsoft Visual C++ 2010 Professional
  • Windows XP, MingW GCC 3.4.2, 4.4.0 and 4.5.2
  • Windows XP, Embarcadero C++ Builder 2010
  • Linux (Ubuntu 11.04 in VirtualBox), GCC 4.5.2
  • Linux (Ubuntu 11.04 in VirtualBox), Intel C++ Compiler Composer XE
  • Mac 10.6.8, GCC 4.4.0

Required third party library -- None for the major libraries

  • For Lua binding, Lua library is required.
  • For Google V8 binding, V8 library is required.
  • For Python binding, Python library is required.
  • For Mozilla SpiderMonkey, Mozilla SpiderMonkey is required.
  • If you want to run the unit test, UnitTest++ is required. But usually you don't need to do that.

Contribute to the library

If you like the library and want to contribute to it, here are some most desired work to do

  • Help with the documentation. I'm not a native English speaker, and I also don't like to write documentation.
  • Test the library on more compilers and platforms.

What does cpgf mean?

The original cpgf means Cross Platform Game Framework. It was intended to be game framework that can work on PC and smart phone. But later the author decided to add more fun but non-game features to the library. So now the library is neither for game nor a framework. It's a cross platform library.

cpgf's People

Contributors

codemouse92 avatar krisr avatar svalaskevicius avatar wqking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cpgf's Issues

Script binding design flaw -- method list should not hold object instance

Currently, the methods in a method list are bound to certain instances. This causes the method list has to be reloaded on each call to correct the instances (see function doInvokeMethodList in gbindcommon.cpp), and the logic is also weird.

The solution: the method list should hold class information for each method instead of instance, then on each call, cast the passed-in object instance to correct one. This will decouple method list from instance and reuse any method list information.

I will work on it soon though seems there is a lot of work

possible misprint

I believe that file gsetter.h (include/cpgf/accessor/gsetter.h) has mistake in the line 133 .
Instead of PolicyHasRule<Policy, GMetaRuleGetterExplicitThis>::Result
should be PolicyHasRule<Policy, GMetaRuleSetterExplicitThis>::Result

Tweening Library Small Bug: The target(accessor, fromValue, targetValue) Function Not Working

I think I've found a bug in the Tweening library, specifically with the GTween class.

If I understand correctly, calling GTween.target(accessor, fromValue, targetValue) should explicitly set both the start and end value of the tweening animation. However, the fromValue is ignored. Instead, the start value is determined from the current value of the object that the accessor references, regardless of calling target(accessor, targetValue) or target(access, fromValue, targetValue).

I am able to reproduce this with the following code.

// Initialize the animation
// impl->progressAnimValue = startValue;
impl->progressAnim.target(cpgf::createAccessor(impl.get(), &ProgressBarImpl::progressAnimValue, &ProgressBarImpl::progressAnimValue), startValue, endValue)
    .duration(1.0F)
    .ease(cpgf::LinearEase::easeInOut());
impl->progressAnim.restart();
impl->progressAnim.immediateTick();

impl->progressAnimValue is the floating point value that I am animating. startValue and endValue are the start and end values that should be tweened between. If I leave the line impl->progressAnimValue = startValue commented out, I get unexpected behavior that I can tell is the result of GTween using the current (wrong) value of impl->progressAnimValue as a starting value, instead of usingstartValue. Uncommenting that line of code results in the expected behavior.

Disowning a pointer from cpgf

Hi @wqking,

Sometimes its necessary to "disown" a pointer that is already managed by cpgf (GC-wise), however I cannot find an easy way to do this.

e.g. when implementing a script wrapper, I have:

        if(func)
        {
            return cpgf::fromVariant<QSGNode * >(cpgf::invokeScriptFunction(func.get(), this, __arg0, __arg1));
        }

which invokes a function, that creates an object and returns it. At this point I know that the pointer will be taken over by the framework in C++ and I'd like cpgf not to GC it later.

As the returned GVariant does not contain this information I see several ways of thinking:

  1. find the returned GVariant in the class pool object and set GC to false. The drawback is that at this point I don't have the main ScriptObject to start looking for the glue data, except if I make it global, which wouldn't fit as a generic solution for metagen.
  2. add another method similar to cpgf::invokeScriptFunction which disowns the result at the end. This doesn't require the global object, however it involves lots of changes as this goes down to a specific scripting engine implementation (thats where the ScriptValues are converted to GVariant.
  3. implement disown method in the core library, invokable in the target script. This requires the target script user to know about pointers and call it every time. Its cleaner to leave this to the framework integrators, as at least this specific example is only for the returned values from a custom (script wrapped) method.

Do you have any alternative suggestions? Which of the options would you choose?

Thanks.

Question regarding script object destruction

Hello,

first of all, thank you for that big library with many nice features.

Currently I build a program that exposes some C++ classes to scripts.
During some tests to check if there are memory leaks while using this classes in scripts, I figured out, that destructors of those exposed classes never get called.

if I write a script like:

for x in range(0, 50000):
	obj = ClassObject()
	obj.textattribute = "Hello"
	print("Created object.")

I would expect that python cleans up the objects at some time.
If my class has a destructor with some log outputs, I can see, that the destructor never gets called.

Am I doing something wrong, or is this supposed to be the case, that exposed meta classes destructors aren't registered in script interfaces ?

Regards

How to retrieve a cpgf::GMetaClass when I have only a base class instance?

In languages with reflection support, it is very common to work with a base class types, and access the derived methods and properties. How can I do this with cpgf?
At the moment I only found cpgf::findMetaClass which takes a string. But I have a base object instance, I don't have the actual name...

Possible memory access errors

if an object has been deleted by C++ while its still kept in V8 (and cpgf), the V8 GC will cause cpgf to do invalid reads:

    8 ==27206== Invalid read of size 8                                                                    
    9 ==27206==    at 0x4B3B2B8: cpgf::variant_internal::CastFromVariant<void*, cpgf::VarantCastKeepConstRef>::cast(cpgf::GVariant const&) (in cpgf-build/build/libcpgf.so)
   10 ==27206==    by 0x4B4164E: cpgf::bind_internal::getGlueDataInstance(cpgf::GSharedPointer<cpgf::bind_internal::GGlueData> const&) (in cpgf-build/build/libcpgf.so)
   11 ==27206==    by 0x4BA2DB6: cpgf::bind_internal::GScriptObjectCache<cpgf::GSharedPointer<v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::Object> > > >::                freeScriptObject(cpgf::bind_internal::GGlueDataWrapper*) (in cpgf-build/build/libcpgf.so)
   12 ==27206==    by 0x4B9B7F9: void cpgf::(anonymous namespace)::weakHandleCallback<v8::Object>(v8::Isolate*, v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::             Object> >*, cpgf::bind_internal::GGlueDataWrapper*) (in cpgf-build/build/libcpgf.so)
   13 ==27206==    by 0x4F6009C: v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector, v8::internal::GCTracer*) (in lib/node/deps/v8/out/native/lib.target/libv8.so)
   51 ==27206== Invalid read of size 8                                                                    
   52 ==27206==    at 0x4B3B2B8: cpgf::variant_internal::CastFromVariant<void*, cpgf::VarantCastKeepConstRef>::cast(cpgf::GVariant const&) (in cpgf-build/build/libcpgf.so)
   53 ==27206==    by 0x4B3D458: cpgf::bind_internal::GObjectInstance::~GObjectInstance() (in cpgf-build/build/libcpgf.so)
   54 ==27206==    by 0x4B3DDA8: cpgf::bind_internal::GObjectGlueData::~GObjectGlueData() (in cpgf-build/build/libcpgf.so)
   55 ==27206==    by 0x4B3DD38: cpgf::bind_internal::GObjectGlueData::~GObjectGlueData() (in cpgf-build/build/libcpgf.so)
   56 ==27206==    by 0x4BA3743: cpgf::bind_internal::GGlueDataWrapperImplement<cpgf::GSharedPointer<cpgf::bind_internal::GObjectGlueData> >::~GGlueDataWrapperImplement() (in cpgf-build/build/libcpgf.so)
   57 ==27206==    by 0x4B9B81C: void cpgf::(anonymous namespace)::weakHandleCallback<v8::Object>(v8::Isolate*, v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::             Object> >*, cpgf::bind_internal::GGlueDataWrapper*) (in cpgf-build/build/libcpgf.so)
   58 ==27206==    by 0x4F6009C: v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector, v8::internal::GCTracer*) (in lib/node/deps/v8/out/native/lib.target/libv8.so)
   94 ==27206== Invalid read of size 8                                                                    
   95 ==27206==    at 0x4B3B2B8: cpgf::variant_internal::CastFromVariant<void*, cpgf::VarantCastKeepConstRef>::cast(cpgf::GVariant const&) (in cpgf-build/build/libcpgf.so)
   96 ==27206==    by 0x4B3D6F2: cpgf::bind_internal::GClassPool::objectDestroyed(cpgf::bind_internal::GObjectInstance const*) (in cpgf-build/build/libcpgf.so)
   97 ==27206==    by 0x4B3D4AD: cpgf::bind_internal::GObjectInstance::~GObjectInstance() (in cpgf-build/build/libcpgf.so)
   98 ==27206==    by 0x4B3DDA8: cpgf::bind_internal::GObjectGlueData::~GObjectGlueData() (in cpgf-build/build/libcpgf.so)
   99 ==27206==    by 0x4B3DD38: cpgf::bind_internal::GObjectGlueData::~GObjectGlueData() (in cpgf-build/build/libcpgf.so)
  100 ==27206==    by 0x4BA3743: cpgf::bind_internal::GGlueDataWrapperImplement<cpgf::GSharedPointer<cpgf::bind_internal::GObjectGlueData> >::~GGlueDataWrapperImplement() (in cpgf-build/build/libcpgf.so)
  101 ==27206==    by 0x4B9B81C: void cpgf::(anonymous namespace)::weakHandleCallback<v8::Object>(v8::Isolate*, v8::Persistent<v8::Object, v8::NonCopyablePersistentTraits<v8::             Object> >*, cpgf::bind_internal::GGlueDataWrapper*) (in cpgf-build/build/libcpgf.so)
  102 ==27206==    by 0x4F6009C: v8::internal::GlobalHandles::PostGarbageCollectionProcessing(v8::internal::GarbageCollector, v8::internal::GCTracer*) (in lib/node/deps/v8/out/native/lib.target/libv8.so)

CPGF should /not/ try to read the address just yet, it should only use it as:
a) hash for the cache lookups, (not accessing the mem location itself)
b) pass to the object life manager, again, simply as a value (in my case the object life manager will know that C++ has deleted the object)

Is there a reason why CastFromVariant is trying to read it?

Setting properties to script objects

the new version (currently yet unreleased develop HEAD) disallows setting script object properties that are not defined in the C++ class.

while this new functionality is correct, persisting object data is still a required functional that I've used for these distinct purposes:

  1. when overriding a c++ class in js, persisting data purely used in the new js code of that class
  2. setting object dependencies for GC not to delete them.

1st case could be supported by adding specific functionality in the shared wrapper class, although I am not sure yet how to implement support for 2nd usage nicely.

Exposing std::string to scripts

Hi,

What's the best way to go about building meta data for std::string and exposing it to scripts? I noticed you've already built meta data for stl vectors and arrays, so I'm curious if you have done anything special for strings?

When I try to do the following:

GDefineMetaClass<std::string>
      ::define("STLString")
      ._method("c_str", (typename std::string::value_type* (std::string::*)(void) const)&std::string::c_str);

I get this linker error:

Undefined symbols for architecture x86_64:
  "std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::c_str() const", referenced from:

All I really need is the ability to call c_str() so I can compare them to lua strings easily. I'm working around it for now by defining a function that takes a std::string and returns a const char*, and exposing that function as a global. I'm sorry if this is not the right place to post this type of question.

Attempting to expose templated global functions fails

Hi Again,

I'm trying to expose glm functions for vectors via cpgf. GLM uses templated inline functions. When I attempt to do this:

GDefineMetaGlobal()
      ._method("cross", (glm::vec3(glm::vec3 const &, glm::vec3 const &))&glm::cross)
      ._method("someOtherFunc", &someOtherFunc);

It compiles fine with Apple's build chain but cross is not exposed and someOtherFunc is also not exposed. If I remove the "cross" line then "someOtherFunc" is successfully exposed. It seems that anytime I try to expose a templated glm method the rest of my methods are ignored. The only work around I've found so far is to define my own non-templated overloaded methods for glm and expose those instead. I'd like to avoid that workaround if possible since it's a lot of work.

Please let me know if there is a better forum for this type of question (when I'm not sure if it's a bug or a support request).

Thanks,
Kris

compile cpgf 1.5.6 sampleserialization Failed under visual c++ 2010 sp1!

1>------ 已启动生成: 项目: sampleserialization, 配置: Release Win32 ------
1>生成启动时间为 2018/6/14 21:41:12。
1>InitializeBuildStatus:
1> 正在对“sampleserialization.dir\Release\sampleserialization.unsuccessfulbuild”执行 Touch 任务。
1>CustomBuild:
1> 所有输出均为最新。
1>ClCompile:
1> object.cpp
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(503): error C2664: “check”: 不能将参数 1 从“MyData”转换为“bool”
1> 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(617): 参见对正在编译的类 模板 实例化“cpgf::IsConvertible<From,To>”的引用
1> with
1> [
1> From=MyData,
1> To=int
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(19): 参见对正在编译的类 模板 实例化“cpgf::IsEnum”的引用
1> with
1> [
1> T=MyData
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gvartypedata_p.h(119): 参见对正在编译的类 模板 实例化“cpgf::GEnableIfResult<C,T>”的引用
1> with
1> [
1> C=cpgf::IsEnum,
1> T=void
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gvartypedata.h(185): 参见对正在编译的类 模板 实例化“cpgf::variant_internal::DeduceVariantType”的引用
1> with
1> [
1> T=MyData
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(188): 参见对正在编译的函数 模板 实例化“void cpgf::deduceVariantType(cpgf::GVarTypeData &,bool)”的引用
1> with
1> [
1> FT=MyData
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(152): 参见对正在编译的函数 模板 实例化“cpgf::GVariant cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::doGet(const void *) const”的引用
1> with
1> [
1> OT=MyObject,
1> FT=MyData,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(151): 编译类 模板 成员函数“cpgf::GVariant cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::virtualGet(const void *,const void )”时
1> with
1> [
1> OT=MyObject,
1> FT=MyData,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gmetafield.h(20): 参见对正在编译的类 模板 实例化“cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>”的引用
1> with
1> [
1> OT=MyObject,
1> FT=MyData,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gmetadefine.h(269): 参见对正在编译的函数 模板 实例化“cpgf::GMetaField::GMetaField<MyObject,MyData,cpgf::MakePolicy<>>(const char ,FT MyObject:: ,const Policy &)”的引用
1> with
1> [
1> FT=MyData,
1> Policy=cpgf::MakePolicy<>
1> ]
1> ....\samples\serialization\object.cpp(108): 参见对正在编译的函数 模板 实例化“cpgf::GDefineMetaField cpgf::GDefineMetaCommon<ClassT,DerivedType>::_field<MyDataMyObject::
>(const char ,FT)”的引用
1> with
1> [
1> BaseType=cpgf::GDefineMetaClass,
1> ClassT=MyObject,
1> DerivedType=cpgf::GDefineMetaClass,
1> FT=MyData MyObject::

1> ]
1> ....\samples\serialization\object.cpp(232): 参见对正在编译的函数 模板 实例化“void register_MyObjectcpgf::GDefineMetaGlobal(D)”的引用
1> with
1> [
1> D=cpgf::GDefineMetaGlobal
1> ]
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(503): error C2866: “cpgf::IsConvertible<From,To>::Result”: 托管类型的常量静态数据成员必须在声明时初始化
1> with
1> [
1> From=MyData,
1> To=int
1> ]
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(617): error C2057: 应输入常量表达式
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(19): error C2975: “unnamed-parameter”:“cpgf::GEnableIf”的模板参数无效,应为编译时常量表达式
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(9) : 参见“unnamed-parameter”的声明
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(503): error C2664: “check”: 不能将参数 1 从“const MyData”转换为“bool”
1> 没有可用于执行该转换的用户定义的转换运算符,或者无法调用该运算符
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(19): 参见对正在编译的类 模板 实例化“cpgf::IsConvertible<From,To,Enabled>”的引用
1> with
1> [
1> From=const MyData &,
1> To=const cpgf::IObject &,
1> Enabled=void
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gvartypedata.h(185): 参见对正在编译的类 模板 实例化“cpgf::GEnableIfResult<C,T>”的引用
1> with
1> [
1> C=cpgf::IsConvertible<const MyData &,const cpgf::IObject &,void>,
1> T=void
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(188): 参见对正在编译的函数 模板 实例化“void cpgf::deduceVariantType(cpgf::GVarTypeData &,bool)”的引用
1> with
1> [
1> FT=MyData *
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(152): 参见对正在编译的函数 模板 实例化“cpgf::GVariant cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::doGet(const void *) const”的引用
1> with
1> [
1> OT=MyObject,
1> FT=MyData *,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetafield_p.h(151): 编译类 模板 成员函数“cpgf::GVariant cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::virtualGet(const void *,const void *)”时
1> with
1> [
1> OT=MyObject,
1> FT=MyData ,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gmetafield.h(20): 参见对正在编译的类 模板 实例化“cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>”的引用
1> with
1> [
1> OT=MyObject,
1> FT=MyData ,
1> Policy=cpgf::MakePolicy<>
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gmetadefine.h(269): 参见对正在编译的函数 模板 实例化“cpgf::GMetaField::GMetaField<MyObject,MyData
,cpgf::MakePolicy<>>(const char ,FT MyObject:: ,const Policy &)”的引用
1> with
1> [
1> FT=MyData ,
1> Policy=cpgf::MakePolicy<>
1> ]
1> ....\samples\serialization\object.cpp(109): 参见对正在编译的函数 模板 实例化“cpgf::GDefineMetaField cpgf::GDefineMetaCommon<ClassT,DerivedType>::_field<MyData
MyObject::
>(const char *,FT)”的引用
1> with
1> [
1> BaseType=cpgf::GDefineMetaClass,
1> ClassT=MyObject,
1> DerivedType=cpgf::GDefineMetaClass,
1> FT=MyData MyObject::
1> ]
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(503): error C2866: “cpgf::IsConvertible<From,To,Enabled>::Result”: 托管类型的常量静态数据成员必须在声明时初始化
1> with
1> [
1> From=const MyData &,
1> To=const cpgf::IObject &,
1> Enabled=void
1> ]
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(19): error C2975: “unnamed-parameter”:“cpgf::GEnableIf”的模板参数无效,应为编译时常量表达式
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(9) : 参见“unnamed-parameter”的声明
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(503): error C2070: “void”: 非法的 sizeof 操作数
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gtypetraits.h(617): 参见对正在编译的类 模板 实例化“cpgf::IsConvertible<From,To>”的引用
1> with
1> [
1> From=MyData *,
1> To=int
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/genableif.h(19): 参见对正在编译的类 模板 实例化“cpgf::IsEnum”的引用
1> with
1> [
1> T=MyData *
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gvartypedata_p.h(119): 参见对正在编译的类 模板 实例化“cpgf::GEnableIfResult<C,T>”的引用
1> with
1> [
1> C=cpgf::IsEnum<MyData *>,
1> T=void
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gvartypedata.h(185): 参见对正在编译的类 模板 实例化“cpgf::variant_internal::DeduceVariantType”的引用
1> with
1> [
1> T=MyData *
1> ]
1>
1>生成失败。

Crash on Unload of library

Hello,

last days, I updated my version of cpgf to the latest master and since then, I get a crash on linux if the application unloads the lib (so after exit(0)).

I did some tracing and found the commit, which is causing the problem for me:
6c8c096 (Replaced cpgf shared pointers with C++ ones.)

Additional informations:

  • Since the crash happens, if the lib unloads, it has to be some static variable, which gets unloaded.
  • If I don't load a script in my code, the crash happens anyway.
  • If I don't call GDefineMetaClass in my code, the crash is gone.

Let me know, if you need any further informations.

Regards

Incorrectly deducing a member function's constness when creating properties

I am registering an Eigen::Matrix which has a const and non const member function called "data".
When I register data via the two function pointers, I get two properties both called data, but neither of them are flagged as const.
I am checking constness with:
method->getItemType().isConstFunction()

I believe this is due to the meta_internal::createPropertyType<Getter, Setter, Policy>() not deducing the constness of the function correctly in the GMetaProperty constructor.

compile cpgf 1.5.6 samplereflection Failed under visual c++ 2010 sp1!

1>------ 已启动生成: 项目: samplereflection, 配置: Release Win32 ------
1>生成启动时间为 2018/6/14 21:37:02。
1>InitializeBuildStatus:
1> 正在对“samplereflection.dir\Release\samplereflection.unsuccessfulbuild”执行 Touch 任务。
1>CustomBuild:
1> 所有输出均为最新。
1>ClCompile:
1> property.cpp
1>D:\reflection\cpgf-1.5.6\build..\include\cpgf/accessor/ggetter.h(157): error C2248: “TestNoncopyable::TestNoncopyable”: 无法访问 private 成员(在“TestNoncopyable”类中声明)
1> d:\reflection\cpgf-1.5.6\samples\reflection\reflect_common.h(85) : 参见“TestNoncopyable::TestNoncopyable”的声明
1> d:\reflection\cpgf-1.5.6\samples\reflection\reflect_common.h(65) : 参见“TestNoncopyable”的声明
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/accessor/ggetter.h(156): 编译类 模板 成员函数“TestNoncopyable cpgf::GInstanceGetter<RawGetter,Policy>::get(const void ) const”时
1> with
1> [
1> RawGetter=TestNoncopyable anonymous-namespace'::TestObject::* , 1> Policy=cpgf::MakePolicy<cpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite> 1> ] 1> D:\reflection\cpgf-1.5.6\build\..\include\cpgf/private/gmetaproperty_p.h(30): 参见对正在编译的类 模板 实例化“cpgf::GInstanceGetter<RawGetter,Policy>”的引用 1> with 1> [ 1> RawGetter=TestNoncopyable anonymous-namespace'::TestObject::
,
1> Policy=cpgf::MakePolicycpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/private/gmetaproperty_p.h(177): 参见对正在编译的类 模板 实例化“cpgf::meta_internal::GMetaGetter<Getter,Policy>”的引用
1> with
1> [
1> Getter=TestNoncopyable anonymous-namespace'::TestObject::* , 1> Policy=cpgf::MakePolicy<cpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite> 1> ] 1> D:\reflection\cpgf-1.5.6\build\..\include\cpgf/gmetaproperty.h(20): 参见对正在编译的类 模板 实例化“cpgf::meta_internal::GMetaPropertyData<Getter,Setter,Policy>”的引用 1> with 1> [ 1> Getter=TestNoncopyable anonymous-namespace'::TestObject::* ,
1> Setter=int,
1> Policy=cpgf::MakePolicycpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite
1> ]
1> D:\reflection\cpgf-1.5.6\build..\include\cpgf/gmetadefine.h(293): 参见对正在编译的函数 模板 实例化“cpgf::GMetaProperty::GMetaProperty<Getter,Setter,Policy>(const char ,const Getter &,const Setter &,const Policy &)”的引用
1> with
1> [
1> Getter=TestNoncopyable anonymous-namespace'::TestObject::* , 1> Setter=int, 1> Policy=cpgf::MakePolicy<cpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite> 1> ] 1> ..\..\samples\reflection\property.cpp(67): 参见对正在编译的函数 模板 实例化“cpgf::GDefineMetaProperty<BaseType> cpgf::GDefineMetaCommon<ClassT,DerivedType>::_property<TestNoncopyableanonymous-namespace'::TestObject::
,int,cpgf::MakePolicy<T0,T1>>(const char ,const Getter &,const Setter &,const Policy &)”的引用
1> with
1> [
1> BaseType=cpgf::GDefineMetaClass<anonymous-namespace'::TestObject>, 1> ClassT=anonymous-namespace'::TestObject,
1> DerivedType=cpgf::GDefineMetaClass<anonymous-namespace'::TestObject>, 1> T0=cpgf::GMetaRuleForbidRead, 1> T1=cpgf::GMetaRuleForbidWrite, 1> Getter=TestNoncopyable anonymous-namespace'::TestObject::
,
1> Setter=int,
1> Policy=cpgf::MakePolicycpgf::GMetaRuleForbidRead,cpgf::GMetaRuleForbidWrite
1> ]
1>
1>生成失败。

Missing destroyInplace() on GMetaFundamental

A compiler warning is thrown (Clang) because the GMetaFundamental class (gmetafundamental.h) is marked final and derived from the abstract GMetaTypedItem class (gmetacommon.h), but unlike all other such derived classes, it does not override the abstract function destroyInPlace().

One of the following changes is needed:

(1) GMetaFundamental::destroyInPlace() be defined,

(2) GMetaTypedItem::destroyInPlace() be made non-abstract (not recommended), or

(3) GMetaFundamental is made non-final.

Can't fugure it out :\

Hi!

May you help me to figure out how to preserve object script state?
Use cases:

local button = ui::find("button");
button.script_property = "test me"; -- pure script/LUA property

local same_button_as_above = ui::find("button");
print(button.script_property); -- property not found or NIL

I partially solved this with ugly "getScriptState" function but ... it's ugly. :)
May be you have any ideas how to do it in more elegant way using cpgf?

My classes are (simplified):

namspace ui {
class ScriptObject{ /* some helper stuff here */};
class BaseWidget : public ScriptObject { /* ... */};
class Button : public BaseWidget {/* ...*/};

BaseWidget * find(const char* widget_name);
}

Thanks!

PS: http://www.cpgf.org/document/inherit-cpp-class-from-script.html - only works for C++ objects created in script code, right?

double underscore defines in header

It is my understanding that your use of double underscores in the defines is not standard conformant.

http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier

"Each name that contains a double underscore (_ _) or begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use."

Basically such user defined tags as include guards are just disasters waiting to happen. #pragma once is much safer and almost unanimously supported.

http://en.wikipedia.org/wiki/Pragma_once

compile times very long

I have not checked the exact cause, but even in debug mode the compile times for meta classes are very long. I suspect that a good part of this comes from the simulation of variadic templates with the macros in gpp.h.

define MAX_BASE_COUNT 20

define GPP_MAX_LIMIT 60

define G_MAX_ARITY 30

So the question is: Are there any plans to provide a version that uses variadic templates?

Is it possible to compile cpgf to dll project?

I have multiple dlls. Each dll is a plugin. Every dll needs to register itself using cpgf so that their classes/functions can be reflected.
If cpgf is static linked by each dll, then each dll should have a copy of cpgf, they cannot share a same cpgf instance
The only solution I know is to make cpgf as a dll. so that every plugin can share same cpgf instance.
So my question is

  • Is compile cpgf to dll project the only solution (to share same cpgf instance)?
  • Is it possible to compile cpgf to dll project? Is it supported already

how to put GCallback into GCallbackList?

typedef cpgf::GCallbackList<void (int, int)> EventHandler;

void RegisterCallback(const GCallback<void (int, int)>& callback)
{
    EventHandler.add(callback);    // <--------------- this can not compile
}

unresolved compiler warnings

cpgf/src/scriptbind/gv8bind.cpp: In function ‘v8::Handle<v8::Value> cpgf::{anonymous}::helperBindValue(const GContextPointer&, const cpgf::GScriptValue&)’:
cpgf/src/scriptbind/gv8bind.cpp:752:8: warning: enumeration value ‘typeScriptObject’ not handled in switch [-Wswitch]
cpgf/src/scriptbind/gv8bind.cpp:752:8: warning: enumeration value ‘typeScriptFunction’ not handled in switch [-Wswitch]
cpgf/src/scriptbind/gv8bind.cpp:752:8: warning: enumeration value ‘typeScriptArray’ not handled in switch [-Wswitch]
cpgf/src/thirdparty/jsoncpp/json_reader.cpp: In member function ‘bool Json::Reader::decodeNumber(Json::Reader::Token&)’:
cpgf/src/thirdparty/jsoncpp/json_reader.cpp:577:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
[100%] Building CXX object CMakeFiles/lib.dircpgf/src/thirdparty/jsoncpp/json_value.cpp.o
cpgf/src/thirdparty/jsoncpp/json_value.cpp: In copy constructor ‘Json::Value::CZString::CZString(const Json::Value::CZString&)’:
cpgf/src/thirdparty/jsoncpp/json_value.cpp:166:34: warning: enumeral and non-enumeral type in conditional expression [enabled by default]

Still alive?

The code looks extremely nice and browsing the samples, it seems that it offers solid functionality.
I need to save object to json and it seems to be able to that.
So is it wise to use this in a new project ?
Thank you

why reload methodlist when invoking?

hi @wqking ,
reading the code, I find it will reload methodlist in doInvokeMethodList of gbindcommon.cpp. Though there is some comments, I cannot understand what is the case the "this" pointer may change.

python tests are outputting errors

while the tests pass, these and similar errors are printed during the execution:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't assign value to enumerator, method, or class.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
RuntimeError: Can't find matched method to invoke

I've confirmed they are still being printed in 735838d commit, didn't go further back in the history

A question regarding script binding performance

Hi,

I've used luabind for script binding and then found cpgf and it seems so great, because I always planned to add reflection to my game engine.

But there is a little question regarding the performance.

First, I made a benchmark to test the FindMetaMethod+Invoke scenario on i5-3570K for this class:

class Test
{
public:
  int func(int a, int b)
  {
    return a + b;
  }
};
  1. luabind
luabind::module(state)
[
  luabind::class_<Test>("Test")
    .def(constructor<>())
    .def("func", &Test::func)
];
local obj = Test()
for i = 1, 10000000 do
    obj:func(1, 2)
end

This code took 1580ms.

  1. cpgf
cpgf::GDefineMetaClass<Test>
  ::define("Test")
  ._method("func", &CpgfTest::func);

Test obj;
cpgf::GMetaClass* t = cpgf::findMetaClass("Test");
for (int i = 0; i < 10000000; ++i)
{
    cpgf::GMetaMethod* m = t->getMethod("func");
    cpgf::fromVariant<int>(m->invoke(&obj, 1, 2));
}

This code took 1135ms, so it's even faster than luabind and I'm happy.

  1. cpgf+lua

Modified samples/scriptbind/luabind/constructor.cpp sample - added similar TestObject::func method and bencmarked the last line from next code:

TestLuaContext context;
GScopedInterface<IMetaClass> metaClass(context.getService()->findClassByName("testscript::TestObject"));
context.getBinding()->bindClass("TestObject", metaClass.get());
context.doString("a = TestObject()\nfor i = 1, 1000000 do a.func(1, 2) end\n");

This code took 61332ms, 38 times slower than luabind. I hope I mistaken somewhere.
Please help, because I would like very much to use your excellent library

Failed compile cpgf 1.6.1 with v8 libs under visual c++ 2015

Сompiler cannot find some objects as the necessary files are apparently missing:
.\cpgf\src\scriptbind\gv8bind.cpp(61): error C2504: 'GShareFromBase': base class undefined .\cpgf\src\scriptbind\gv8bind.cpp(172): error C2504: 'GUserData': base class undefined

Can metagen support all c++ syntax?

Hi @wqking, can metagen support all c++ syntax, such as macro, multiple inheritance etc?

Can I use it to generate meta data from any C++ library or moudle without any worries?

Anything I should know about using metagen?

Memory leakage detected with MFC library

#include <afxwin.h>         // MFC core and standard components
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
GDefineMetaClass<BodyDeviceModel, DeviceModelBase>
::declare("BodyDeviceModel")
._field("w", &BodyDeviceModel::w)
._field("h", &BodyDeviceModel::h)
;

When running the code above with VS2010, memory leakage is reported. I am not sure if this is a real problem or just a false alarm.

Detected memory leaks!
Dumping objects ->
{523} normal block at 0x00000000020682B0, 80 bytes long.
 Data: <  `             > 01 00 60 00 CD CD CD CD C0 82 06 02 00 00 00 00 
{522} normal block at 0x0000000002068210, 48 bytes long.
 Data: <                > 10 82 06 02 00 00 00 00 10 82 06 02 00 00 00 00 
{521} normal block at 0x0000000002068190, 16 bytes long.
......

Reflection of constructor

Hi,

I'm trying to reflect a simple class as you can see in the complete example in the pastebin link (should compile when an appropriate project is set up). Here, I want to reflect a method and the constructor of class MyController. This is done in static void reflect(Define define). Reflection of methods works fine under Linux and Windows, but the reflection of the (non default) constructor does not compile on Linux using GCC 4.8.2. Here something seems to be different in template syntax between Windows and Linux compiler.
The error is very generic: "expected primary-expression before 'void'" (in line 61)

What is the correct syntax for reflecting this constructor?

http://pastebin.com/pqJiEcL1

Thanks a lot in advance.

Regards
Sebastian

build failed under linux (ubuntu)

Can't figure out how to build the library. What am I doing wrong?
My system is Ubuntu 12.04 LTS, gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3

selivanov@mail3> cd src/cpgf/build
selivanov@mail3> cmake .
-- Build as debug.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/selivanov/src/cpgf/build

selivanov@mail3> make linux TARGET=lib

-- Build as debug.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/selivanov/src/cpgf/build
make[1]: Вход в каталог `/home/selivanov/src/cpgf/build/temp_cache_linux'
make[1]: *** Нет правила для сборки цели `lib'.  Останов.
make[1]: Выход из каталога `/home/selivanov/src/cpgf/build/temp_cache_linux'
make: *** [linux] Ошибка 2

Clean the branches

Hi Sarunas,

There are 3 branches created by you. Can you check to merge or delete them to make the branches cleaner?

Thanks

Compiler error from simple code?

I change a01_reflect_to_global.cpp and add a simple funtion "nt test(int *& param) const ":
class Point
{
public:
Point() : x(0), y(0) {
}

Point(int x, int y) : x(x), y(y) {
}

void extend(int scale) {
    x *= scale;
    y *= scale;
}

int getArea() const {
    return x * y;
}
int test(int *& param) const {
    param = NULL;
}

public:
int x;
int y;
};
2> a01_reflect_to_global.cpp
2>E:\Engine\cpgf-develop\include\cpgf/private/gmetainvoke_p.h(180): error C2664: “int cpgf::callback_internal::GCallbackAgent_1<int,int *&>::operator ()(int &) const”: 无法将参数 1 从“int *”转换为“int &”
2> E:\Engine\cpgf-develop\include\cpgf/private/gmetainvoke_p.h(180): 编译类 模板 成员函数“cpgf::GVariant cpgf::meta_internal::GMetaInvokeHelper<cpgf::GCallback<int (P0)>,cpgf::GFunctionTraits,1,int,Policy,false,false>::invoke(void *,const CT &,const cpgf::GVariant *const *,size_t)”时
2> with
2> [
2> P0=int *&
2> , Signature=int (int *&)
2> ,

When I compile project "sampleirrlicht", there are some error just like this one. It seems there is a bug when parameters are something like "Type *&"(reference to pointer). Or am I miss anything?

Can't register boost::function as field or function argument

Trying to register boost::function < void() > class field using ._field(name, field) and getting compilation error inside G_STATIC_CONSTANT(bool, Result = (IsSameType<From, To>::Result || (sizeof(check(from)) == sizeof(typetraits_internal::YesType)))) from CastVariantSelector:

Libs\boost\boost/function/function_template.hpp(153): error C2064: term does not evaluate to a function taking 0 arguments
          Libs\boost\boost/function/function_template.hpp(147) : while compiling class template member function 'void boost::detail::function::void_function_obj_invoker0<FunctionObj,R>::invoke(boost::detail::function::function_buffer &)'
          with
          [
              FunctionObj=float
  ,            R=void
          ]
          Libs\boost\boost/function/function_template.hpp(934) : see reference to function template instantiation 'void boost::detail::function::void_function_obj_invoker0<FunctionObj,R>::invoke(boost::detail::function::function_buffer &)' being compiled
          with
          [
              FunctionObj=float
  ,            R=void
          ]
          Libs\boost\boost/function/function_template.hpp(934) : see reference to class template instantiation 'boost::detail::function::void_function_obj_invoker0<FunctionObj,R>' being compiled
          with
          [
              FunctionObj=float
  ,            R=void
          ]
          Libs\boost\boost/function/function_template.hpp(722) : see reference to function template instantiation 'void boost::function0<R>::assign_to<Functor>(Functor)' being compiled
          with
          [
              R=void
  ,            Functor=float
          ]
          Libs\boost\boost/function/function_template.hpp(722) : see reference to function template instantiation 'void boost::function0<R>::assign_to<Functor>(Functor)' being compiled
          with
          [
              R=void
  ,            Functor=float
          ]
          Libs\boost\boost/function/function_template.hpp(1072) : see reference to function template instantiation 'boost::function0<R>::function0<From>(Functor,int)' being compiled
          with
          [
              R=void
  ,            From=float
  ,            Functor=float
          ]
          Libs\boost\boost/function/function_template.hpp(1072) : see reference to function template instantiation 'boost::function0<R>::function0<From>(Functor,int)' being compiled
          with
          [
              R=void
  ,            From=float
  ,            Functor=float
          ]
          Libs\cpgf\include\cpgf/gtypetraits.h(503) : see reference to function template instantiation 'boost::function<void (void)>::function<From>(Functor,int)' being compiled
          with
          [
              From=float
  ,            Functor=float
          ]
          Libs\cpgf\include\cpgf/private/gvariant_p.h(69) : see reference to function template instantiation 'boost::function<void (void)>::function<From>(Functor,int)' being compiled
          with
          [
              From=float
  ,            Functor=float
          ]
          Libs\cpgf\include\cpgf/genableif.h(57) : see reference to class template instantiation 'cpgf::IsConvertible<From,To,void>' being compiled
          with
          [
              From=float
  ,            To=boost::function<void (void)>
          ]
          Libs\cpgf\include\cpgf/genableif.h(19) : see reference to class template instantiation 'cpgf::GOrResult<cpgf::IsConvertible<From,To,void>,cpgf::GAndResult<cpgf::IsEnum<From>,cpgf::IsConvertible<int,To,void>,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult>,cpgf::GAndResult<cpgf::IsEnum<boost::function<void (void)>>,cpgf::IsConvertible<From,int,void>,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult>,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult>' being compiled
          with
          [
              From=float
  ,            To=boost::function<void (void)>
          ]
          Libs\cpgf\include\cpgf/private/gvariant_p.h(133) : see reference to class template instantiation 'cpgf::GEnableIfResult<cpgf::GOrResult<cpgf::IsConvertible<From,To,void>,cpgf::GAndResult<cpgf::IsEnum<From>,cpgf::IsConvertible<int,To,void>,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult>,cpgf::GAndResult<cpgf::IsEnum<boost::function<void (void)>>,cpgf::IsConvertible<From,int,void>,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult,cpgf::GTrueResult>,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult,cpgf::GFalseResult>,void>' being compiled
          with
          [
              From=float
  ,            To=boost::function<void (void)>
          ]
          Libs\cpgf\include\cpgf/private/gvariant_p.h(826) : see reference to class template instantiation 'cpgf::variant_internal::CastVariantHelper<float,boost::function<void (void)>,void>' being compiled
          Libs\cpgf\include\cpgf/private/gvariant_p.h(781) : while compiling class template member function 'boost::function<void (void)> cpgf::variant_internal::CastFromVariant<FT,cpgf::VarantCastKeepConstRef>::cast(const cpgf::GVariant &)'
          with
          [
              FT=F_Void
          ]
          Libs\cpgf\include\cpgf/gvariant.h(212) : see reference to function template instantiation 'boost::function<void (void)> cpgf::variant_internal::CastFromVariant<FT,cpgf::VarantCastKeepConstRef>::cast(const cpgf::GVariant &)' being compiled
          with
          [
              FT=F_Void
          ]
          Libs\cpgf\include\cpgf/private/gmetafield_p.h(201) : see reference to class template instantiation 'cpgf::variant_internal::CastFromVariant<FT,cpgf::VarantCastKeepConstRef>' being compiled
          with
          [
              FT=F_Void
          ]
          Libs\cpgf\include\cpgf/private/gmetafield_p.h(156) : see reference to function template instantiation 'void cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::doSet<void>(void *,const cpgf::GVariant &) const' being compiled
          with
          [
              OT=Dao::Application
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Libs\cpgf\include\cpgf/private/gmetafield_p.h(156) : see reference to function template instantiation 'void cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::doSet<void>(void *,const cpgf::GVariant &) const' being compiled
          with
          [
              OT=Dao::Application
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Libs\cpgf\include\cpgf/private/gmetafield_p.h(155) : while compiling class template member function 'void cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::virtualSet(const void *,void *,const cpgf::GVariant &)'
          with
          [
              OT=Dao::Application
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Libs\cpgf\include\cpgf/private/gmetafield_p.h(180) : see reference to function template instantiation 'void cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>::virtualSet(const void *,void *,const cpgf::GVariant &)' being compiled
          with
          [
              OT=Dao::Application
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Libs\cpgf\include\cpgf/gmetafield.h(20) : see reference to class template instantiation 'cpgf::meta_internal::GMetaFieldDataMember<OT,FT,Policy>' being compiled
          with
          [
              OT=Dao::Application
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Libs\cpgf\include\cpgf/gmetadefine.h(270) : see reference to function template instantiation 'cpgf::GMetaField::GMetaField<Dao::Application,F,cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>>(const char *,FT Dao::Application::* ,const Policy &)' being compiled
          with
          [
              F=F_Void
  ,            FT=F_Void
  ,            Policy=cpgf::MakePolicy<cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType,cpgf::GNullType>
          ]
          Reflection/Reflection.h(457) : see reference to function template instantiation 'cpgf::GDefineMetaField<DerivedType> cpgf::GDefineMetaCommon<ClassType,DerivedType>::_field<FDao::Application::* >(const char *,FT)' being compiled
          with
          [
              DerivedType=cpgf::GDefineMetaClass<Dao::Application,void,void>
  ,            ClassType=Dao::Application
  ,            F=F_Void
  ,            FT=F_Void Dao::Application::* 
          ]
          Reflection/Reflection.h(457) : see reference to function template instantiation 'cpgf::GDefineMetaField<DerivedType> cpgf::GDefineMetaCommon<ClassType,DerivedType>::_field<FDao::Application::* >(const char *,FT)' being compiled
          with
          [
              DerivedType=cpgf::GDefineMetaClass<Dao::Application,void,void>
  ,            ClassType=Dao::Application
  ,            F=F_Void
  ,            FT=F_Void Dao::Application::* 
          ]
          Application.cpp(858) : see reference to function template instantiation 'Dao::Reflection::Class<Dao::Application,luabind::detail::unspecified> &Dao::Reflection::Class<Dao::Application,luabind::detail::unspecified>::Property<F_Void>(const char *,F Dao::Application::* )' being compiled
          with
          [
              F=F_Void
          ]
          Application.cpp(893) : see reference to function template instantiation 'Dao::Reflection::Class<Dao::Application,luabind::detail::unspecified> &Dao::Reflection::Class<Dao::Application,luabind::detail::unspecified>::Property<F_Void>(const char *,F Dao::Application::* )' being compiled
          with
          [
              F=F_Void
          ]

Undefined Behavior on gcallback

Dereferencing a null pointer is undefined behavior, and yet it is done twice in gcallback.h. (This advisory came from Clang).

gcallback.h::135

return (T)(*(typename std::conditional<std::is_void<T>::value, int, T>::type *)0);

.../cpgf/build/../include/cpgf/gcallback.h:135:14: warning: binding dereferenced null pointer to reference has undefined behavior
[-Wnull-dereference]

.../cpgf/build/../include/cpgf/gcallback.h:135:14: warning: indirection of non-volatile null pointer will be deleted, not trap
[-Wnull-dereference]


Also, something similar here flags on the IDE.

gcallback.h::144

return *(T *)0;

Is the library multi thread safe?

as titled, if I call functions in multi thread environment, eg find a class by name, create class instance, invoke member function, must I lock the meta class / meta service?
thanks

why cannot be overloaded

I used qtjs to animation work,but when i try to generation meta for qquickanimation,there is a error:
In file included from ../../../metagen/build/QtQml/src/meta_qtqml_qquickanimation_p.cpp:33:0:
../../../metagen/build/QtQml/include/meta_qtqml_qquickanimation_p.h:827:29: error: ‘QAbstractAnimationJob* qt_metadata::QQuickColorAnimationWrapper::transition(QQuickStateActions&, QQmlProperties&, QQuickAbstractAnimation::TransitionDirection, QObject_)’ cannot be overloaded
QAbstractAnimationJob * transition(QQuickStateActions & actions, QQmlProperties & modified, TransitionDirection direction, QObject * defaultTarget = 0)
^
../../../metagen/build/QtQml/include/meta_qtqml_qquickanimation_p.h:749:29: error: with ‘QAbstractAnimationJob_ qt_metadata::QQuickColorAnimationWrapper::transition(QQuickStateActions&, QQmlProperties&, QQuickAbstractAnimation::TransitionDirection, QObject*)’
QAbstractAnimationJob * transition(QQuickStateActions & actions, QQmlProperties & modified, QQuickAbstractAnimation::TransitionDirection direction, QObject * defaultTarget = 0)

luaToScriptValue breaks functions with upvalues

There is some code in the case statement that handles lua functions in luaToScriptValue which attempts to inspect the upvalue. I'm not sure why it's there or what it is supposed to accomplish, but it seems to break function passing from lua to C++ because luaToScriptValue ends up storing a ref to the upvalue instead of the function (presumably because the upvalue is left on the top of the stack?). I've commented this code out in my copy of cpgf for now and would be happy to submit a patch.

Perhaps this is some debugging code and I should not be using the development branch?

test build fails if configured for the new spidermonkey (and its enabled)

tried building for both xulrunner-27.0.1 and mozjs-24.2.0 - the build fails with errors like:

.../dev/cpgf/test/scriptbind/bind_common.cpp:447:34: error: ‘JSOPTION_METHODJIT’ was not declared in this scope
.../dev/cpgf/test/scriptbind/bind_common.cpp:447:52: error: ‘JS_SetOptions’ was not declared in this scope
.../dev/cpgf/test/scriptbind/bind_common.cpp:448:50: error: ‘JS_SetVersion’ was not declared in this scope
.../dev/cpgf/test/scriptbind/bind_common.cpp: In member function ‘bool testscript::TestScriptContextSpiderMonkey::executeString(const char*, bool) const’:
.../dev/cpgf/test/scriptbind/bind_common.cpp:521:3: error: ‘JSBool’ was not declared in this scope
.../dev/cpgf/test/scriptbind/bind_common.cpp:521:10: error: expected ‘;’ before ‘success’
.../dev/cpgf/test/scriptbind/bind_common.cpp:522:10: error: ‘success’ was not declared in this scope
.../dev/cpgf/test/scriptbind/bind_common.cpp:522:21: error: ‘JS_TRUE’ was not declared in this scope

How to get results from char* modifying methods ?

Hello,

I tried to call a c function that modifies a string that is passed by char*.
Is it possible, to get the result in a python script using that function ?

GDefineMetaGlobal()
._method("mysql_real_escape_string", &mysql_real_escape_string)

MySQL function header is:

unsigned long
mysql_real_escape_string(
              MYSQL *mysql,
              char *to,const char *from,
              unsigned long length);

I'm calling this function with the following python script, but the string passed as to is not changed from the function call.

escapedLoginname = str("")
originalLoginname = str("HelloWorld")
i = mysql_real_escape_string(handle, escapedLoginname, originalLoginname, len(originalLoginname))

I also tried to use the cpgf Byte Array. But I don't know a way to get a python string out of an cpgf Byte Array.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.