1 module javascriptcore.VirtualMachine;
2 
3 private import glib.ConstructionException;
4 private import gobject.ObjectG;
5 private import javascriptcore.c.functions;
6 public  import javascriptcore.c.types;
7 
8 
9 /**
10  * JSCVirtualMachine represents a group of JSCContext<!-- -->s. It allows
11  * concurrent JavaScript execution by creating a different instance of
12  * JSCVirtualMachine in each thread.
13  * 
14  * To create a group of JSCContext<!-- -->s pass the same JSCVirtualMachine
15  * instance to every JSCContext constructor.
16  */
17 public class VirtualMachine : ObjectG
18 {
19 	/** the main Gtk struct */
20 	protected JSCVirtualMachine* jSCVirtualMachine;
21 
22 	/** Get the main Gtk struct */
23 	public JSCVirtualMachine* getVirtualMachineStruct(bool transferOwnership = false)
24 	{
25 		if (transferOwnership)
26 			ownedRef = false;
27 		return jSCVirtualMachine;
28 	}
29 
30 	/** the main Gtk struct as a void* */
31 	protected override void* getStruct()
32 	{
33 		return cast(void*)jSCVirtualMachine;
34 	}
35 
36 	/**
37 	 * Sets our main struct and passes it to the parent class.
38 	 */
39 	public this (JSCVirtualMachine* jSCVirtualMachine, bool ownedRef = false)
40 	{
41 		this.jSCVirtualMachine = jSCVirtualMachine;
42 		super(cast(GObject*)jSCVirtualMachine, ownedRef);
43 	}
44 
45 
46 	/** */
47 	public static GType getType()
48 	{
49 		return jsc_virtual_machine_get_type();
50 	}
51 
52 	/**
53 	 * Create a new #JSCVirtualMachine.
54 	 *
55 	 * Returns: the newly created #JSCVirtualMachine.
56 	 *
57 	 * Throws: ConstructionException GTK+ fails to create the object.
58 	 */
59 	public this()
60 	{
61 		auto __p = jsc_virtual_machine_new();
62 
63 		if(__p is null)
64 		{
65 			throw new ConstructionException("null returned by new");
66 		}
67 
68 		this(cast(JSCVirtualMachine*) __p, true);
69 	}
70 }