What exactly is the purpose of the external keyword in Kotlin?
I guess it's for JNI like native in Java, but I can't seem to find any actual reference or documentation on this.
Indeed, it's an equivalent of Java's native. It's currently missing from the documentation but there's an issue to add it.
According to documentation:
external marks a declaration as implemented not in Kotlin (accessible through JNI or in JavaScript)
Related
Is it possible to stub every instance of a class in C++ using GTest/GMock like RSpec has with any_instance? Read the docs but couldn't find anything on it.
Thanks.
Short answer: No. There is no such built-in functionality in gtest/gmock.
Long answer: There is no way to impose certain behavior on an arbitrary C++ class, especially those in C++ standard library (C++ equivalent of Ruby core library). These are two fundamentally different languages. Ruby is a "message oriented" language, all objects respond to messages. Such concept does not exist in C++, so there is not way to achieve the behavior you desire.
I would like to use the C++ API of a project from Node and I can't change the C++ code.
I looked at node-ffi but it doesn't seems to be able to work with C++ namespace and classes.
Do you know any other way?
SWIG can wrap c++ for many scripting languages, including javascript/nodejs. See http://www.swig.org/Doc3.0/Javascript.html
are there any documentation on clojure built-in java method?
for example, .toUpperCase from java.lang.String and .indexOf from clojure.lang.PersistantVector.
Is there anyway I can find useful java method without looking at the source code?
As others have pointed out, you can get the java.* and javax.* documentation online pretty easily as it is part of core Java.
For the clojure.*, your best reference is the source. Even so, I'd recommend not relying on it since this code should really be considered an implementation detail of Clojure. You have no guarantee that the functionality won't change in future versions of Clojure and break any code that depends on it.
How about the Java API? All of Java's classes and methods are listed there. That covers all of the "clojure built-in java methods".
On the other hand, Clojure's classes are documented in here, Clojure's API. You have to learn to distinguish between Clojure's classes and Java's classes. All packages starting with java.* or javax.* belong to Java and are documented in the first link. The packages starting with clojure.* are from Clojure, you'll find their documentation in the second link.
If the package for the class starts with java or javax then you can look it up in the Java documentation on Oracle's website.
For Clojure implementation classes (where the package name starts with clojure) you are probably stuck with looking at the source code. There is documentation for the intended API (the Clojure language) but not for the Java classes implementing it. You may be able to find some articles (like this one) depending on if what you're looking for is something a blogger has taken an interest in.
Is ther any equivalent to wsdl2java that will take a WSDL file and generate scala stubs for the server and/or client?
I googled, but either there isn't or my google-fu is weak.
scalaxb has some support for this, but it's still very much experimental and it's still client-side only. The only reliable techniques I've seen for handling the server side is either to generate the Java code via
wsdl2java or other tools and then wrap that in Scala or, possibly, to use annotations to generate the WSDL from the Scala code. The later option is likely to lead to some pain, though, as you learn where Scala does and does not map readily to Java conventions.
Not sure if it is what you want, but have you looked at http://scalaxb.org/wsdl-support?
Looking at this old thread it seems possible to create custom mapping templates:
http://www.mail-archive.com/axis-user#ws.apache.org/msg35857.html
Maybe you could use wsdl2java tool with custom templates creating Scala code?
Thinking one can try to combine wsdl2avro and avro4s
I am an experienced C/C++ developer but I am a novice in Ruby.
How can I call a C++ function from with in Ruby?
You have 3 possibilities :
1) Ruby is able to load libraries. Even if it is a bit tricky, you can decide to write your own loader and bind your C++ library in Ruby.
This is done using what is called an extension module. You will find a comprehensive tutorial here: http://www.rubyinside.com/how-to-create-a-ruby-extension-in-c-in-under-5-minutes-100.html
2) You can use a tool that will generate the Ruby wrapper around your C++ library. Look at SWIG for example (http://www.swig.org/).
You just have to create a file in a swig-specific syntax and provide it to SWIG. It will then be able to generate the wrapper for many languages, Ruby included.
3) You can choose to use a middleware, such as CORBA/ICE/whatever. It may be a bit overkill if you only want to call some C++ functions, but it will allow you to remote call the functions, or "hide" a grid behind the middleware.
To call C++ code from Ruby, you will likely want to build an extension.
If you are an experienced C++ developer, you may feel comfortable with Rice:
https://github.com/jasonroelofs/rice
It uses C++ metaprogramming techniques to simplify writing extensions.
If you were calling into C, you could also use ffi. Calling C++ code is a little more complicated than calling C code due to name mangling and exceptions.
I believe the questioner is asking how to call C++ from with in Ruby, if so then the for simple C/C++ RubyInline1 is by the far the simplest solution.
Alternatively if you need to call more substatntial C++ code, you can build a ruby extension. Here is a good tutorial
You need to wrap your c++ code in a C interface and then bind those C functions to ruby methods using rb_define_method()
alternatively you can use SWIG, as Aurelien said.