File: bind.h.rst

package info (click to toggle)
emscripten 2.0.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,440 kB
  • sloc: ansic: 510,324; cpp: 384,763; javascript: 84,341; python: 51,362; sh: 50,019; pascal: 4,159; makefile: 3,409; asm: 2,150; lisp: 1,869; ruby: 488; cs: 142
file content (855 lines) | stat: -rw-r--r-- 25,312 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
.. _bind-h:

===========================
bind.h (under-construction)
===========================

The C++ APIs in `bind.h <https://github.com/emscripten-core/emscripten/blob/master/system/include/emscripten/bind.h>`_ define

Guide documentation for this API can be found in :ref:`Embind`.

.. contents:: Table of Contents
    :local:
    :depth: 1

How to use this API
===================


Defines
-------


.. cpp:namespace: emscripten

.. cpp:function:: EMSCRIPTEN_BINDINGS(name)

   This define is used to bind C++ classes, functions and other constructs to
   JavaScript. It is used differently depending on the construct being mapped
   — see the :ref:`embind guide <embind>` for examples.

   :param name: This is a label to mark a group of related bindings (for example ``EMSCRIPTEN_BINDINGS(physics)``, ``EMSCRIPTEN_BINDINGS(components)``, etc.)



.. cpp:type:: sharing_policy

   .. cpp:type:: sharing_policy::NONE

   .. cpp:type:: sharing_policy::INTRUSIVE

   .. cpp:type:: sharing_policy::BY_EMVAL


.. _bind-h-policies:

Policies
========

Currently only :cpp:type:`allow_raw_pointers` policy is supported.
Eventually we hope to implement `Boost.Python-like raw pointer policies
<https://wiki.python.org/moin/boost.python/CallPolicy>`_ for managing
object ownership.

.. cpp:type:: arg

   .. cpp:member:: static int index

      .. code-block:: cpp

         // Prototype
         static constexpr int index


.. cpp:type:: ret_val

   .. cpp:member:: static int index

      .. code-block:: cpp

         // Prototype
         static constexpr int index


.. cpp:type:: allow_raw_pointers

   This policy is used to whitelist raw pointers.

   .. cpp:type:: Transform::type


.. cpp:type:: allow_raw_pointer

   .. code-block: cpp

      // Prototype
      template<typename Slot>
      struct allow_raw_pointer : public allow_raw_pointers


select_overload and select_const
======================================


.. cpp:function:: typename std::add_pointer<Signature>::type select_overload(typename std::add_pointer<Signature>::type fn)

   .. code-block:: cpp

      // Prototype
      template<typename Signature>
      typename std::add_pointer<Signature>::type select_overload(typename std::add_pointer<Signature>::type fn)

   :param typename std\:\:add_pointer<Signature>::type fn

.. cpp:function:: typename internal::MemberFunctionType<ClassType, Signature>::type select_overload()

   .. code-block:: cpp

      // Prototype
      template<typename Signature, typename ClassType>
      typename internal::MemberFunctionType<ClassType, Signature>::type select_overload(Signature (ClassType::*fn))

   :param Signature (ClassType::\*fn)

.. cpp:function:: auto select_const()

   .. code-block:: cpp

      // Prototype
      template<typename ClassType, typename ReturnType, typename... Args>
      auto select_const(ReturnType (ClassType::*method)(Args...) const)

   :param ReturnType (ClassType::\*method)(Args...) const


.. cpp:function:: typename internal::CalculateLambdaSignature<LambdaType>::type optional_override(const LambdaType& fp)

   .. code-block:: cpp

      // Prototype
      template<typename LambdaType>
      typename internal::CalculateLambdaSignature<LambdaType>::type optional_override(const LambdaType& fp)

   :param const LambdaType& fp


Functions
=============

.. cpp:function:: void* __getDynamicPointerType(void* p)


   :param void* p


.. cpp:function:: void function()

   .. code-block:: cpp

      //prototype
      template<typename ReturnType, typename... Args, typename... Policies>
      void function(const char* name, ReturnType (*fn)(Args...), Policies...)

   Registers a function to export to JavaScript. This is called from within
   an :cpp:func:`EMSCRIPTEN_BINDINGS` block.

   For example to export the function ``lerp()``

   .. code:: cpp

      // quick_example.cpp
      #include <emscripten/bind.h>

      using namespace emscripten;

      float lerp(float a, float b, float t) {
         return (1 - t) * a + t * b;
      }

      EMSCRIPTEN_BINDINGS(my_module) {
         function("lerp", &lerp);
      }



   :param const char* name: The name of the function to export (e.g. ``"lerp"``).
   :param ReturnType (\*fn)(Args...): Function pointer address for the exported function (e.g. ``&lerp``).
   :param Policies...: |policies-argument|



Value tuples
==============

.. cpp:class:: value_array : public internal::noncopyable

   .. cpp:type:: class_type

      A typedef of ``ClassType``, the typename of the templated type for the class.


   .. cpp:function:: value_array(const char* name)

      Constructor.

      :param const char* name


   .. cpp:function:: ~value_array()

      Destructor.


   .. cpp:function:: value_array& element(ElementType InstanceType::*field)

      :param ElementType InstanceType::\*field: Note that ``ElementType`` and ``InstanceType`` are typenames (templated types).


   .. cpp:function:: value_array& element(Getter getter, Setter setter)

      :param Getter getter. Note that ``Getter`` is a typename (templated type).
      :param Setter setter. Note that ``Setter`` is a typename (templated type).


   .. cpp:function:: value_array& element(index<Index>)

      :param index<Index>:Note that ``Index`` is an integer template parameter.





Value structs
=============

.. cpp:class:: value_object : public internal::noncopyable

   .. cpp:type:: class_type

      A typedef of ``ClassType``, the typename of the templated type for the class.


   .. cpp:function:: value_object(const char* name)

      Constructor.

      :param const char* name


   .. cpp:function:: ~value_object()

      Destructor.


   .. cpp:function:: value_object& field(const char* fieldName, FieldType InstanceType::*field)

      :param const char* fieldName.
      :param FieldType InstanceType\:\:\*field.



   .. cpp:function:: value_object& field(const char* fieldName, Getter getter, Setter setter)

      :param const char* fieldName.
      :param Getter getter. Note that ``Getter`` is a typename (templated type).
      :param Setter setter. Note that ``Setter`` is a typename (templated type).


   .. cpp:function:: value_object& field(const char* fieldName, index<Index>)

      :param const char* fieldName.
      :param index<Index>. Note that ``Index`` is an integer template parameter.


Smart pointers
==============


.. cpp:type:: default_smart_ptr_trait

   .. code-block:: cpp

      //prototype
      template<typename PointerType>
      struct default_smart_ptr_trait

   .. cpp:function:: static sharing_policy get_sharing_policy()


   .. cpp:function:: static void* share(void* v)

      :param void* v


   .. cpp:function:: static PointerType* construct_null()

      :returns: Note that the ``PointerType`` returned is a typename (templated type).



.. cpp:type:: smart_ptr_trait

   .. code-block:: cpp

      //prototype
      template<typename PointerType>
      struct smart_ptr_trait : public default_smart_ptr_trait<PointerType>

   .. cpp:type:: PointerType::element_type element_type

      .. code-block:: cpp

         //prototype
         typedef typename PointerType::element_type element_type;


      A typedef for the PointerType::element_type, where ``PointerType`` is a typename (templated type).


   .. cpp:function:: static element_type* get(const PointerType& ptr)

      :param const PointerType& ptr: Note that ``PointerType`` is a typename (templated type)



.. cpp:type:: template<typename PointeeType> smart_ptr_trait<std::shared_ptr<PointeeType>>

   .. code-block:: cpp

      //prototype
      template<typename PointeeType>
      struct smart_ptr_trait<std::shared_ptr<PointeeType>>

   .. cpp:type:: PointerType

      A typedef to std::shared_ptr<PointeeType>, where ``PointeeType`` is a typename (templated type).

   .. cpp:type:: element_type

      A typedef for the ``PointerType::element_type``.


   .. cpp:function:: static element_type* get(const PointerType& ptr)

      :param const PointerType& ptr

   .. cpp:function:: static sharing_policy get_sharing_policy()


   .. cpp:function:: static std::shared_ptr<PointeeType>* share(PointeeType* p, internal::EM_VAL v)

      :param PointeeType* p: Note that ``PointeeType`` is a typename (templated type).
      :param internal\:\:EM_VAL v:


   .. cpp:function:: static PointerType* construct_null()



Classes
=======


.. cpp:class:: wrapper : public T, public internal::WrapperBase

   .. code-block:: cpp

      //prototype
      template<typename T>
      class wrapper : public T, public internal::WrapperBase

   .. cpp:type:: class_type

      A typedef of ``T``, the typename of the templated type for the class.


   .. cpp:function:: wrapper(val&& wrapped, Args&&... args)

      .. code-block:: cpp

         //prototype
         template<typename... Args>
         explicit wrapper(val&& wrapped, Args&&... args)
           : T(std::forward<Args>(args)...)
           , wrapped(std::forward<val>(wrapped))

      Constructor.

      :param val&& wrapped
      :param Args&&... args: Note that ``Args`` is a typename (templated type).


   .. cpp:function:: ~wrapper()

      Destructor.


   .. cpp:function:: ReturnType call(const char* name, Args&&... args) const

      Constructor.

      :param const char* name
      :param Args&&... args: Note that ``Args`` is a typename (templated type).
      :returns: Note that ``ReturnType`` is a typename (templated type).


.. cpp:function:: EMSCRIPTEN_WRAPPER(T)

   :param T


.. cpp:type:: base

   .. cpp:type:: class_type

      A typedef of ``BaseClass``, the typename of the templated type for the class.


   .. cpp:function:: static void verify()

      Note, is templated function which takes typename ``ClassType``.


   .. cpp:function:: static internal::TYPEID get()


      .. code-block:: cpp

         template<typename ClassType>
         using Upcaster = BaseClass* (*)(ClassType*);

         template<typename ClassType>
         using Downcaster = ClassType* (*)(BaseClass*);


   .. cpp:function:: static Upcaster<ClassType> getUpcaster()

      .. code-block:: cpp

         //prototype
         template<typename ClassType>
         static Upcaster<ClassType> getUpcaster()


   .. cpp:function:: static Downcaster<ClassType> getDowncaster()

      .. code-block:: cpp

         //prototype
         template<typename ClassType>
         static Downcaster<ClassType> getDowncaster()


   .. cpp:function:: static To* convertPointer(From* ptr)

      .. code-block:: cpp

         //prototype
         template<typename From, typename To>
         static To* convertPointer(From* ptr)

      :param From* ptr



.. cpp:type:: pure_virtual

   .. cpp:type:: Transform

      Note that this is a templated struct taking typename parameter ``InputType`` and integer ``Index``.

      .. cpp:type:: type

         This is a typdef to the parent struct typename parameter ``InputType``.


.. cpp:type:: constructor

   Note that this is a template struct taking typename ``... ConstructorArgs``.



.. cpp:class:: class_

   Note that this is a templated class with typename parameters ``ClassType`` and ``BaseSpecifier``.

   .. cpp:type:: class_type

      A typedef of ``ClassType`` (a typename for the class).


   .. cpp:type:: base_specifier

      A typedef of ``BaseSpecifier`` (a typename for the class).


   .. cpp:type:: HELPNEEDEDHERE

      ::

         class_() = delete;


   .. cpp:function:: explicit class_(const char* name)

      .. code-block:: cpp

         //prototype
         EMSCRIPTEN_ALWAYS_INLINE explicit class_(const char* name)


      Constructor.

      :param const char* name


   .. cpp:function:: const class_& smart_ptr(const char* name) const

      .. code-block:: cpp

         //prototype
         template<typename PointerType>
         EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr(const char* name) const

      :param const char* name.
      :returns: |class_-function-returns|


      .. _embind-class-zero-argument-constructor:

   .. cpp:function:: const class_& constructor() const

      .. code-block:: cpp

         //prototype
         template<typename... ConstructorArgs, typename... Policies>
         EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Policies... policies) const

      Zero-argument form of the class constructor. This invokes the natural constructor with the arguments specified in the template. See :ref:`embind-external-constructors` for more information.

      :param Policies... policies: |policies-argument|
      :returns: |class_-function-returns|

      .. _embind-class-function-pointer-constructor:


   .. cpp:function:: const class_& constructor(Callable callable, Policies...) const

      .. code-block:: cpp

         //prototype
         template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>
         EMSCRIPTEN_ALWAYS_INLINE const class_& constructor(Callable callable, Policies...) const

      Class constructor for objects that use a factory function to create the object.  This method will accept either a function pointer, ``std::function``
      object or function object which will return a newly constructed object.  When the ``Callable`` is a function object the function signature must be
      explicitly specified in the ``Signature`` template parameter in the format ``ReturnType (Args...)``.  For ``Callable`` types other than function objects
      the method signature will be deduced.

      The following are all valid calls to ``constructor``:

      .. code-block:: cpp

         using namespace std::placeholders;
         myClass1.constructor(&my_factory);
         myClass2.constructor(std::function<ClassType2(float, float)>(&class2_factory));
         myClass3.constructor<ClassType3(const val&)>(std::bind(Class3Functor(), _1));

      See :ref:`embind-external-constructors` for more information.


      :param Callable callable Note that ``Callable`` may be either a member function pointer, function pointer, ``std::function`` or function object.
      :param Policies... policies: |policies-argument|
      :returns: |class_-function-returns|


   .. cpp:function:: const class_& smart_ptr_constructor() const

      .. code-block:: cpp

         //prototype
         template<typename SmartPtr, typename... Args, typename... Policies>
         EMSCRIPTEN_ALWAYS_INLINE const class_& smart_ptr_constructor(const char* smartPtrName, SmartPtr (*factory)(Args...), Policies...) const

      :param const char* smartPtrName
      :param SmartPtr (\*factory)(Args...)
      :param Policies... policies: |policies-argument|
      :returns: |class_-function-returns|


   .. cpp:function:: const class_& allow_subclass() const

      .. code-block:: cpp

         //prototype
          template<typename WrapperType, typename PointerType, typename... ConstructorArgs>
         EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(
           const char* wrapperClassName,
           const char* pointerName,
           ::emscripten::constructor<ConstructorArgs...> = ::emscripten::constructor<>()
         ) const

      :param const char* wrapperClassName
      :param const char* pointerName
      :param emscripten\:\:constructor<ConstructorArgs...> constructor)
      :returns: |class_-function-returns|


   .. cpp:function:: const class_& allow_subclass(const char* wrapperClassName, ::emscripten::constructor<ConstructorArgs...> constructor) const

      .. code-block:: cpp

         //prototype
         template<typename WrapperType, typename... ConstructorArgs>
         EMSCRIPTEN_ALWAYS_INLINE const class_& allow_subclass(
           const char* wrapperClassName,
           ::emscripten::constructor<ConstructorArgs...> constructor = ::emscripten::constructor<>()
         ) const

      :param const char* wrapperClassName
      :param \:\:emscripten\:\:constructor<ConstructorArgs...> constructor)

      :returns: |class_-function-returns|


   .. cpp:function:: const class_& function() const

      .. code-block:: cpp

         //prototype
         template<typename Signature = internal::DeduceArgumentsTag, typename Callable, typename... Policies>
         EMSCRIPTEN_ALWAYS_INLINE const class_& function(const char* methodName, Callable callable, Policies...) const

      This method is for declaring a method belonging to a class.

      On the JavaScript side this is a function that gets bound as a property of the prototype. For example ``.function("myClassMember", &MyClass::myClassMember)``
      would bind ``myClassMember`` to ``MyClass.prototype.myClassMember`` in the JavaScript.  This method will accept either a pointer-to-member-function, function
      pointer, ``std::function`` object or function object.  When the ``Callable`` is not a pointer-to-member-function it must accept the ``ClassType`` as the first
      (``this``) parameter.  When the ``Callable`` is a function object the function signature must be explicitly specified in the ``Signature`` template parameter
      in the format ``ReturnType (Args...)``.  For ``Callable`` types other than function objects the method signature will be deduced.

      The following are all valid calls to ``function``:

      .. code-block:: cpp

         using namespace std::placeholders;
         myClass.function("myClassMember", &MyClass::myClassMember)
             .function("myFreeFunction", &my_free_function)
             .function("myStdFunction", std::function<float(ClassType&, float, float)>(&my_function))
             .function<val(const MyClass&)>("myFunctor", std::bind(&my_functor_taking_this, _1));


      :param const char* methodName
      :param Callable callable Note that ``Callable`` may be either a member function pointer, function pointer, ``std::function`` or function object.
      :param typename... Policies: |policies-argument|
      :returns: |class_-function-returns|


   .. cpp:function:: const class_& property() const

      .. code-block:: cpp

         //prototype
         template<typename FieldType, typename = typename std::enable_if<!std::is_function<FieldType>::value>::type>
         EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, const FieldType ClassType::*field) const

      :param const char* fieldName
      :param const FieldType ClassType\:\:\*field

      :returns: |class_-function-returns|


   .. cpp:function:: const class_& property(const char* fieldName, FieldType ClassType::*field) const

      .. code-block:: cpp

         //prototype
         template<typename FieldType, typename = typename std::enable_if<!std::is_function<FieldType>::value>::type>
         EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, FieldType ClassType::*field) const

      :param const char* fieldName
      :param FieldType ClassType\:\:\*field

      :returns: |class_-function-returns|


   .. cpp:function:: const class_& property(const char* fieldName, Getter getter) const

      .. code-block:: cpp

         //prototype
         template<typename PropertyType = internal::DeduceArgumentsTag, typename Getter>
         EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter) const;

      Declare a read-only property with the specified ``fieldName`` on the class using the specified ``getter`` to retrieve the property
      value.  ``Getter`` may be either a class method, a function, a ``std::function`` or a function object.  When ``Getter``
      is not pointer-to-member-function, it must accept an instance of the ``ClassType`` as the ``this`` argument.  When
      ``Getter`` is a function object, the property type must be specified as a template parameter as it cannot be deduced,
      e.g.: ``myClass.property<int>("myIntProperty", MyIntGetterFunctor());``

      :param const char* fieldName
      :param Getter getter Note that ``Getter`` is a function template typename.
      :returns: |class_-function-returns|


   .. cpp:function:: const class_& property(const char* fieldName, Getter getter, Setter setter) const

      .. code-block:: cpp

         //prototype
         template<typename PropertyType = internal::DeduceArgumentsTag, typename Getter, typename Setter>
         EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, Getter getter, Setter setter) const

      This is a function template taking typenames ``Setter`` and ``Getter``: ``template<typename Getter, typename Setter>``
      which declares a read-write property with the specified ``fieldName`` on the class. ``Getter`` and ``Setter`` may be either a
      class method, a function, a ``std::function`` or a function object.  When ``Getter`` or ``Setter`` is not pointer-to-member-function,
      it must accept an instance of the ``ClassType`` as the ``this`` argument. When ``Getter`` or ``Setter`` is a function object, the
      property type must be specified as a template parameter as it cannot be deduced, e.g.:
      ``myClass.property<int>("myIntProperty", MyIntGetterFunctor(), MyIntSetterFunctor());``

      :param const char* fieldName
      :param Getter getter: Note that ``Getter`` is a function template typename.
      :param Setter setter: Note that ``Setter`` is a function template typename.
      :returns: |class_-function-returns|

   .. cpp:function:: const class_& class_function() const

      .. code-block:: cpp

         //prototype
         template<typename ReturnType, typename... Args, typename... Policies>
         EMSCRIPTEN_ALWAYS_INLINE const class_& class_function(const char* methodName, ReturnType (*classMethod)(Args...), Policies...) const

      This method is for declaring a static function belonging to a class.

      On the JavaScript side this is a function that gets bound as a property
      of the constructor. For example ``.class_function("myStaticFunction",
      &MyClass::myStaticFunction)`` binds ``myStaticFunction`` to
      ``MyClass.myStaticFunction``.

      :param const char* methodName
      :param ReturnType (\*classMethod)(Args...)
      :param Policies...: |policies-argument|
      :returns: |class_-function-returns|

   .. cpp:function:: const class_& class_property(const char* fieldName, FieldType *field) const

      .. code-block:: cpp

         //prototype
         template<typename FieldType>
         EMSCRIPTEN_ALWAYS_INLINE const class_& property(const char* fieldName, FieldType *field) const

      :param const char* fieldNam
      :param FieldType ClassType\:\:\*field

      :returns: |class_-function-returns|





Vectors
=======

.. cpp:function:: class_<std::vector<T>> register_vector(const char* name)

   .. code-block:: cpp

      //prototype
      template<typename T>
      class_<std::vector<T>> register_vector(const char* name)

   A function to register a ``std::vector<T>``.

   :param const char* name


Maps
====

.. cpp:function::  class_<std::map<K, V>> register_map(const char* name)

   .. code-block:: cpp

      //prototype
      template<typename K, typename V>
      class_<std::map<K, V>> register_map(const char* name)

   A function to register a ``std::map<K, V>``.

   :param const char* name



Enums
=====


.. cpp:class:: enum_

   .. code-block:: cpp

      //prototype
      template<typename EnumType>
      class enum_

   Registers an enum to export to JavaScript. This is called from within an
   :cpp:func:`EMSCRIPTEN_BINDINGS` block and works with both C++98 enums
   and C++11 "enum classes". See :ref:`embind-enums` for more information.


   .. cpp:type:: enum_type

      A typedef of ``EnumType`` (a typename for the class).


   .. cpp:function::  enum_(const char* name)

      Constructor.

      :param const char* name


   .. cpp:function::  enum_& value(const char* name, EnumType value)

      Registers an enum value.

      :param const char* name: The name of the enumerated value.
      :param EnumType value: The type of the enumerated value.
      :returns: A reference to the current object. This allows chaining of multiple enum values in the :cpp:func:`EMSCRIPTEN_BINDINGS` block.



Constants
=========

.. cpp:function:: void constant(const char* name, const ConstantType& v)

   .. code-block:: cpp

      //prototype
      template<typename ConstantType>
      void constant(const char* name, const ConstantType& v)

   Registers a constant to export to JavaScript. This is called from within
   an :cpp:func:`EMSCRIPTEN_BINDINGS` block.

   .. code:: cpp

      EMSCRIPTEN_BINDINGS(my_constant_example) {
        constant("SOME_CONSTANT", SOME_CONSTANT);
      }

   :param const char* name: The name of the constant.
   :param const ConstantType& v: The constant type. This can be any type known to *embind*.





.. COMMENT (not rendered): Following values are common to many functions, and currently only updated in one place (here).
.. COMMENT (not rendered): These can be properly replaced if required either wholesale or on an individual basis.

.. |policies-argument| replace:: :ref:`Policy <bind-h-policies>` for managing raw pointer object ownership. Currently must be :cpp:type:`allow_raw_pointers`.
.. |class_-function-returns| replace:: A ``const`` reference to the current object. This allows chaining of the :cpp:class:`class_` functions that define the binding in the :cpp:func:`EMSCRIPTEN_BINDINGS` block.