Module Stdlib.Obj

Contents

Instructions: Use this module in your project

In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:

  1. Add the following to your project's dependencies/CMakeLists.txt:

    Copy
    DkSDKProject_DeclareAvailable(ocaml
        CONSTRAINT "= 4.14.0"
        FINDLIBS str unix runtime_events threads dynlink)
    DkSDKProject_MakeAvailable(ocaml)
  2. Add the Findlib::ocaml library to any desired targets in src/*/CMakeLists.txt:

    Copy
    target_link_libraries(YourPackage_YourLibraryName
         # ... existing libraries, if any ...
         Findlib::ocaml)
  3. Click your IDE's Build button

Not using DkSDK?

FIRST, do one or all of the following:

  1. Run:

    Copy
    opam install ocaml.4.14.0
  2. Edit your dune-project and add:

    Copy
    (package
      (name YourExistingPackage)
      (depends
      ; ... existing dependenices ...
      (ocaml (>= 4.14.0))))

    Then run:

    Copy
    dune build *.opam # if this fails, run: dune build
  3. Edit your <package>.opam file and add:

    Copy
    depends: [
      # ... existing dependencies ...
      "ocaml" {>= "4.14.0"}
    ]

    Then run:

    Copy
    opam install . --deps-only

FINALLY, add the library to any desired (library)and/or (executable) targets in your **/dune files:

Copy
(library
  (name YourLibrary)
  ; ... existing library options ...
  (libraries
    ; ... existing libraries ...
    ))

(executable
  (name YourExecutable)
  ; ... existing executable options ...
  (libraries
    ; ... existing libraries ...
    ))
type t
type raw_data`` = nativeint
valrepr :'a -> t
valobj :t -> 'a
valmagic :'a -> 'b
valis_block :t -> bool
valis_int :t -> bool
valtag :t -> int
valsize :t -> int
valreachable_words :t -> int

Computes the total size (in words, including the headers) of all heap blocks accessible from the argument. Statically allocated blocks are excluded, unless the runtime system was configured with --disable-naked-pointers.

  • since 4.04
valfield :t ->``int-> t
valset_field :t ->``int-> t -> unit

When using flambda:

set_field MUST NOT be called on immutable blocks. (Blocks allocated in C stubs, or with new_block below, are always considered mutable.)

The same goes for set_double_field and set_tag. However, for set_tag, in the case of immutable blocks where the middle-end optimizers never see code that discriminates on their tag (for example records), the operation should be safe. Such uses are nonetheless discouraged.

For experts only: set_field et al can be made safe by first wrapping the block in Sys.opaque_identity, so any information about its contents will not be propagated.

valset_tag :t ->``int-> unit
  • deprecated Use with_tag instead.
valdouble_field :t ->``int-> float
valset_double_field :t ->``int->``float-> unit
valraw_field :t ->``int-> raw_data
valset_raw_field :t ->``int-> raw_data -> unit
valnew_block : ``int->``int-> t
valdup :t -> t
valtruncate :t ->``int-> unit
  • deprecated
valadd_offset :t -> Int32.t -> t
valwith_tag : ``int-> t -> t
val first_non_constant_constructor_tag : int
val last_non_constant_constructor_tag : int
val lazy_tag : int
val closure_tag : int
val object_tag : int
val infix_tag : int
val forward_tag : int
val no_scan_tag : int
val abstract_tag : int
val string_tag : int
val double_tag : int
val double_array_tag : int
val custom_tag : int
val final_tag : int
  • deprecated Replaced by custom_tag.
val int_tag : int
val out_of_heap_tag : int
val unaligned_tag : int
module Closure:sig...end
module Extension_constructor:sig...end
valextension_constructor :'a -> extension_constructor
  • deprecated use Obj.Extension_constructor.of_val
valextension_name : ``extension_constructor-> string
  • deprecated use Obj.Extension_constructor.name
valextension_id : ``extension_constructor-> int
  • deprecated use Obj.Extension_constructor.id
module Ephemeron:sig...end

Ephemeron with arbitrary arity and untyped