mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
Merge pull request #12362 from alalek:fix_js_headers
This commit is contained in:
commit
af769e4ec8
@ -56,7 +56,7 @@ add_custom_command(
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/embindgen.py
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/templates.py
|
||||
DEPENDS ${scripts_hdr_parser}
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
|
||||
#(not needed - generated by CMake) DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
|
||||
DEPENDS ${opencv_hdrs}
|
||||
DEPENDS ${JS_HELPER})
|
||||
|
||||
|
@ -68,15 +68,10 @@
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//M*/
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
#include "opencv2/video/background_segm.hpp"
|
||||
#include "opencv2/objdetect.hpp"
|
||||
#include "opencv2/dnn.hpp"
|
||||
|
||||
#include <emscripten/bind.h>
|
||||
|
||||
@INCLUDES@
|
||||
|
||||
using namespace emscripten;
|
||||
using namespace cv;
|
||||
using namespace dnn;
|
||||
|
@ -733,12 +733,14 @@ class JSWrapperGenerator(object):
|
||||
|
||||
def gen(self, dst_file, src_files, core_bindings):
|
||||
# step 1: scan the headers and extract classes, enums and functions
|
||||
headers = []
|
||||
for hdr in src_files:
|
||||
decls = self.parser.parse(hdr)
|
||||
# print(hdr);
|
||||
# self.print_decls(decls);
|
||||
if len(decls) == 0:
|
||||
continue
|
||||
headers.append(hdr[hdr.rindex('opencv2/'):])
|
||||
for decl in decls:
|
||||
name = decl[0]
|
||||
type = name[:name.find(" ")]
|
||||
@ -890,6 +892,9 @@ class JSWrapperGenerator(object):
|
||||
with open(core_bindings) as f:
|
||||
ret = f.read()
|
||||
|
||||
header_includes = '\n'.join(['#include "{}"'.format(hdr) for hdr in headers])
|
||||
ret = ret.replace('@INCLUDES@', header_includes)
|
||||
|
||||
defis = '\n'.join(self.wrapper_funcs)
|
||||
ret += wrapper_codes_template.substitute(ns=wrapper_namespace, defs=defis)
|
||||
ret += emscripten_binding_template.substitute(binding_name='testBinding', bindings=''.join(self.bindings))
|
||||
|
Loading…
Reference in New Issue
Block a user