Generating bindings for 3.10

Hi,

I have a function in CCSprite to generate sprites with a base64 string. I added it at the class sprite on PATH_TO_ENGINE/cocos/2d/CCSprite.{cpp,h}.
Then I executed PATH_TO_ENGINE/tools/tojs/genbindings.py.
The script says that everything went ok and the date of the files at PATH_TO_ENGINE/cocos/scripting/js-bindings/auto is the right date. Meaning that it’s the modification date of these files is the date that I executed the script but my new function is not present on the autogenerated files.

This is something that I’ve done in 3.3, 3.4, 3.5 and 3.6.1 and everything went ok. I do not know if something changed or if there is some config that file that I should tweak. Any help is welcome.

Here I show my function:

CCSprite.cpp:

#include "base/base64.h"

...

Sprite* Sprite::createWithBase64(const std::string& filename)
{   
    int len = 0;
    unsigned char *buffer;

    len = base64Decode((unsigned char*)filename.c_str(), (unsigned int)filename.length(), &buffer);
    Image *img = new Image();
    bool ok = img->initWithImageData(buffer,len); 
    //dbgprint("filename:::%s with length:::%i", filename.c_str(), filename.length());
    free(buffer);
    if(!ok) {
        //dbgprint("ERROR CREATING IMAGE WITH BASE64");
        return nullptr;
    }
    Texture2D* texture = new Texture2D();
    texture->initWithImage(img);
    img->release();
    Sprite* sprite = new Sprite();
    if(sprite && sprite->initWithTexture(texture)){
        texture->release();
        sprite->autorelease();
        return sprite;
    }
    //dbgprint("ERROR CREATING SPRITE WITH BASE64");
    CC_SAFE_DELETE(sprite);
    return nullptr;
}
CCSprite.h:

static Sprite* createWithBase64(const std::string& filename);

@slackmoehrle, do you know something about this? Or someone to ask?
I want to port our games to the new engine but this is being a stopper right now.

I’ve tried in windows and in mac. I am using android-ndk-r9b.

I think @ricardo was recently working on bindings. He might know how…

1 Like

I’ve been looking more carefully when the script generates the bindings and there is a warning: “You dont have the C version of NameMapper installed!” but the script ends correctly.

@alexgg
If I understood correctly, you want to automatically generate bindings for one methods. Is that correct ?

If so, you have to follow these steps:

My suggestion in case you only want one method to be bound to JS, just do it manually.
Hare manually bindings many methods, for example:

@ricardo @slackmoehrle

Finally we found the issue. It seems that the new version there is some kind of names depending on the class that the generator skips. One of this patterns are “create” functions so our function was not created for this reason. We changed the name and everything worked just fine.

The patterns can be found in cocos2d-x-3.10\tools\tojs inside every .ini