Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add OSystem class to ale preset #551

Closed
jimdunn opened this issue Apr 11, 2018 · 7 comments
Closed

Unable to add OSystem class to ale preset #551

jimdunn opened this issue Apr 11, 2018 · 7 comments

Comments

@jimdunn
Copy link

jimdunn commented Apr 11, 2018

Hiya,
The ALEInterface class has an OSystem member called theOSystem (std::unique_ptr<OSystem> theOSystem;) that is skipped in .../org/bytedeco/javacpp/presets/ale.java. I've been trying to "unskip" it, but I've been unable to get it working. (I want to try to set the colourPalette which can apparently be done through theOSystem.)
After staring a some of the other presets, I've come up with this

@Properties(
    value = {
        @Platform(value = {"linux-x86", "macosx", "windows"},
                  compiler = "cpp11",
                  define = {"UNIQUE_PTR_NAMESPACE std"},
                  link = "ale",
                  include = {"emucore/m6502/src/bspf/src/bspf.hxx", "emucore/Event.hxx", "common/Constants.h",
                             "emucore/OSystem.hxx",
                             "common/ColourPalette.hpp", "common/ScreenExporter.hpp", "environment/ale_ram.hpp",
                             "environment/ale_screen.hpp", "environment/ale_state.hpp", "ale_interface.hpp"}),
        @Platform(value = "linux-x86",     preload = "SDL-1.2@.0", preloadpath = {"/usr/lib32/", "/usr/lib/"}),
        @Platform(value = "linux-x86_64",  preload = "SDL-1.2@.0", preloadpath = {"/usr/lib64/", "/usr/lib/"}),
        @Platform(value = "macosx-x86_64", preload = "SDL-1.2@.0", preloadpath = "/usr/local/lib/"),
        @Platform(value = "windows-x86",    preload = {"SDL", "libale"}, preloadpath = "/mingw32/bin/"),
        @Platform(value = "windows-x86_64", preload = {"SDL", "libale"}, preloadpath = "/mingw64/bin")},
    target = "org.bytedeco.javacpp.ale")
public class ale implements InfoMapper {
    public void map(InfoMap infoMap) {
        infoMap.put(new Info("BSPF_strcasecmp", "BSPF_strncasecmp", "BSPF_snprintf", "BSPF_vsnprintf").cppTypes())
               .put(new Info("std::unique_ptr<OSystem>").annotations("@UniquePtr").pointerTypes("OSystem").define())
               .put(new Info("ALEState::reset",
                             "OSystem::Resolution",
                             "OSystem::supportedResolutions",
                             "OSystem::debugger","OSystem::cheat",
                             "OSystem::settings", "OSystem::sound","OSystem::attach", "OSystem::console",
                             "OSystem::rng","OSystem::saveState", "OSystem::loadState","OSystem::p_display_screen",
                             "ALEInterface::theSettings", "ALEInterface::romSettings", "ALEInterface::environment",
                             "ALEInterface::createOSystem","ALEInterface::loadSettings").skip());
    }
}

but I'm getting this error

javacpp-presets/ale/target/classes/org/bytedeco/javacpp/jniale.cpp:2169:21: error: object of type 'std::__1::unique_ptr<OSystem,
      std::__1::default_delete<OSystem> >' cannot be assigned because its copy assignment operator is implicitly deleted
    ptr->theOSystem = adapter0;
                    ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2394:3: note: copy assignment operator is implicitly deleted because
      'unique_ptr<OSystem, std::__1::default_delete<OSystem> >' has a user-declared move constructor
  unique_ptr(unique_ptr&& __u) noexcept
  ^

It's been a while since I've done any C++ so I'm a bit flummoxed by this. It's not really a big deal since everything else has been working quite well, but if I'm missing something simple or obvious I'd appreciate a bit of assistance.
Thanks!

@saudet
Copy link
Member

saudet commented Apr 11, 2018

Try to prepend "const" like this:

.put(new Info("const std::unique_ptr<OSystem>").annotations("@UniquePtr").pointerTypes("OSystem").define())

@jimdunn
Copy link
Author

jimdunn commented Apr 11, 2018

Unfortunately, I get the same error with that change.

@saudet
Copy link
Member

saudet commented Apr 11, 2018 via email

@jimdunn
Copy link
Author

jimdunn commented Apr 12, 2018

I am using 1.4.2-SNAPSHOT. I even reverted to 1.4.1 for the heck of it and got the same result.

javacpp-presets/ale/cppbuild/macosx-x86_64/include/ -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/include/darwin /Users/jim/Dropbox/repos/javacpp-presets/ale/target/classes/org/bytedeco/javacpp/jniale.cpp /Users/jim/Dropbox/repos/javacpp-presets/ale/target/classes/jnijavacpp.cpp -march=x86-64 -m64 -O3 -std=c++11 -Wl,-rpath,@loader_path/. -Wall -fPIC -dynamiclib -undefined dynamic_lookup -o libjniale.dylib -L/Users/jim/Dropbox/repos/javacpp-presets/ale/cppbuild/macosx-x86_64/lib/ -Wl,-rpath,/Users/jim/Dropbox/repos/javacpp-presets/ale/cppbuild/macosx-x86_64/lib/ -lale -framework JavaVM
/Users/jim/Dropbox/repos/javacpp-presets/ale/target/classes/org/bytedeco/javacpp/jniale.cpp:1137:21: error: object of type 'std::__1::unique_ptr<OSystem,
      std::__1::default_delete<OSystem> >' cannot be assigned because its copy assignment operator is implicitly deleted
    ptr->theOSystem = adapter0;
                    ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/memory:2394:3: note: copy assignment operator is implicitly deleted because
      'unique_ptr<OSystem, std::__1::default_delete<OSystem> >' has a user-declared move constructor
  unique_ptr(unique_ptr&& __u) noexcept
  ^
1 error generated.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:24 min
[INFO] Finished at: 2018-04-11T19:56:47-07:00
[INFO] Final Memory: 25M/82M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.bytedeco:javacpp:1.4.2-SNAPSHOT:build (javacpp.compiler) on project ale: Execution javacpp.compiler of goal org.bytedeco:javacpp:1.4.2-SNAPSHOT:build failed: Process exited with an error: 1 -> [Help 1]

I basically followed the steps here. I ran the cppbuild.sh script and after modifying the configuration file I did mvn clean install --projects .,ale in the javacpp-presets directory. Perhaps I am missing a step.

@saudet
Copy link
Member

saudet commented Apr 12, 2018

Great, thanks for confirming. So, I'll have to look into this...

@saudet
Copy link
Member

saudet commented Apr 28, 2018

I've thought about that and we probably don't want to use a std::unique_ptr here, because doing so would "move" the pointer out of ALEInterface. Instead I've added a call to theOSystem.get() to let use just the value of the pointer. Let me know if you have any issues with that! Thanks

@saudet saudet added enhancement and removed bug labels Apr 29, 2018
@jimdunn
Copy link
Author

jimdunn commented May 1, 2018

Just tried it out and it works great! Thanks for the help with this.

@jimdunn jimdunn closed this as completed May 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants