@@ -10,8 +10,46 @@ namespace MsieJavaScriptEngine.JsRt.Edge
1010 /// </summary>
1111 internal static class EdgeNativeMethods
1212 {
13+ #region Hosting
14+
15+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
16+ internal static extern JsErrorCode JsParseScript ( string script , JsSourceContext sourceContext ,
17+ string sourceUrl , out EdgeJsValue result ) ;
18+
19+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
20+ internal static extern JsErrorCode JsRunScript ( string script , JsSourceContext sourceContext ,
21+ string sourceUrl , out EdgeJsValue result ) ;
22+
23+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
24+ internal static extern JsErrorCode JsSerializeScript ( string script , byte [ ] buffer , ref ulong bufferSize ) ;
25+
26+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
27+ internal static extern JsErrorCode JsParseSerializedScript ( string script , byte [ ] buffer ,
28+ JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
29+
30+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
31+ internal static extern JsErrorCode JsRunSerializedScript ( string script , byte [ ] buffer ,
32+ JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
33+
34+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
35+ internal static extern JsErrorCode JsGetPropertyIdFromName ( string name , out EdgeJsPropertyId propertyId ) ;
36+
37+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
38+ internal static extern JsErrorCode JsGetPropertyNameFromId ( EdgeJsPropertyId propertyId , out IntPtr buffer ) ;
39+
40+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
41+ internal static extern JsErrorCode JsPointerToString ( string value , UIntPtr stringLength ,
42+ out EdgeJsValue stringValue ) ;
43+
44+ [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
45+ internal static extern JsErrorCode JsStringToPointer ( EdgeJsValue value , out IntPtr stringValue ,
46+ out UIntPtr stringLength ) ;
47+
48+ #endregion
49+
1350 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
14- internal static extern JsErrorCode JsCreateRuntime ( JsRuntimeAttributes attributes , JsThreadServiceCallback threadService , out EdgeJsRuntime runtime ) ;
51+ internal static extern JsErrorCode JsCreateRuntime ( JsRuntimeAttributes attributes ,
52+ JsThreadServiceCallback threadService , out EdgeJsRuntime runtime ) ;
1553
1654 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
1755 internal static extern JsErrorCode JsCollectGarbage ( EdgeJsRuntime handle ) ;
@@ -29,10 +67,12 @@ internal static class EdgeNativeMethods
2967 internal static extern JsErrorCode JsSetRuntimeMemoryLimit ( EdgeJsRuntime runtime , UIntPtr memoryLimit ) ;
3068
3169 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
32- internal static extern JsErrorCode JsSetRuntimeMemoryAllocationCallback ( EdgeJsRuntime runtime , IntPtr callbackState , JsMemoryAllocationCallback allocationCallback ) ;
70+ internal static extern JsErrorCode JsSetRuntimeMemoryAllocationCallback ( EdgeJsRuntime runtime ,
71+ IntPtr callbackState , JsMemoryAllocationCallback allocationCallback ) ;
3372
3473 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
35- internal static extern JsErrorCode JsSetRuntimeBeforeCollectCallback ( EdgeJsRuntime runtime , IntPtr callbackState , JsBeforeCollectCallback beforeCollectCallback ) ;
74+ internal static extern JsErrorCode JsSetRuntimeBeforeCollectCallback ( EdgeJsRuntime runtime ,
75+ IntPtr callbackState , JsBeforeCollectCallback beforeCollectCallback ) ;
3676
3777 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode , EntryPoint = "JsAddRef" ) ]
3878 internal static extern JsErrorCode JsContextAddRef ( EdgeJsContext reference , out uint count ) ;
@@ -64,27 +104,6 @@ internal static class EdgeNativeMethods
64104 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
65105 internal static extern JsErrorCode JsIdle ( out uint nextIdleTick ) ;
66106
67- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
68- internal static extern JsErrorCode JsParseScript ( string script , JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
69-
70- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
71- internal static extern JsErrorCode JsRunScript ( string script , JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
72-
73- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
74- internal static extern JsErrorCode JsSerializeScript ( string script , byte [ ] buffer , ref ulong bufferSize ) ;
75-
76- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
77- internal static extern JsErrorCode JsParseSerializedScript ( string script , byte [ ] buffer , JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
78-
79- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
80- internal static extern JsErrorCode JsRunSerializedScript ( string script , byte [ ] buffer , JsSourceContext sourceContext , string sourceUrl , out EdgeJsValue result ) ;
81-
82- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
83- internal static extern JsErrorCode JsGetPropertyIdFromName ( string name , out EdgeJsPropertyId propertyId ) ;
84-
85- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
86- internal static extern JsErrorCode JsGetPropertyNameFromId ( EdgeJsPropertyId propertyId , out IntPtr buffer ) ;
87-
88107 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
89108 internal static extern JsErrorCode JsGetUndefinedValue ( out EdgeJsValue undefinedValue ) ;
90109
@@ -119,26 +138,25 @@ internal static class EdgeNativeMethods
119138 internal static extern JsErrorCode JsNumberToDouble ( EdgeJsValue value , out double doubleValue ) ;
120139
121140 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
122- internal static extern JsErrorCode JsConvertValueToNumber ( EdgeJsValue value , out EdgeJsValue numberValue ) ;
141+ internal static extern JsErrorCode JsNumberToInt ( EdgeJsValue value , out int intValue ) ;
123142
124143 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
125- internal static extern JsErrorCode JsGetStringLength ( EdgeJsValue sringValue , out int length ) ;
126-
127- [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
128- internal static extern JsErrorCode JsPointerToString ( string value , UIntPtr stringLength , out EdgeJsValue stringValue ) ;
144+ internal static extern JsErrorCode JsConvertValueToNumber ( EdgeJsValue value , out EdgeJsValue numberValue ) ;
129145
130146 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
131- internal static extern JsErrorCode JsStringToPointer ( EdgeJsValue value , out IntPtr stringValue , out UIntPtr stringLength ) ;
147+ internal static extern JsErrorCode JsGetStringLength ( EdgeJsValue sringValue , out int length ) ;
132148
133149 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
134150 internal static extern JsErrorCode JsConvertValueToString ( EdgeJsValue value , out EdgeJsValue stringValue ) ;
135151#if ! NETSTANDARD1_3
136152
137153 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
138- internal static extern JsErrorCode JsVariantToValue ( [ MarshalAs ( UnmanagedType . Struct ) ] ref object var , out EdgeJsValue value ) ;
154+ internal static extern JsErrorCode JsVariantToValue ( [ MarshalAs ( UnmanagedType . Struct ) ] ref object var ,
155+ out EdgeJsValue value ) ;
139156
140157 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
141- internal static extern JsErrorCode JsValueToVariant ( EdgeJsValue obj , [ MarshalAs ( UnmanagedType . Struct ) ] out object var ) ;
158+ internal static extern JsErrorCode JsValueToVariant ( EdgeJsValue obj ,
159+ [ MarshalAs ( UnmanagedType . Struct ) ] out object var ) ;
142160#endif
143161
144162 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
@@ -148,7 +166,8 @@ internal static class EdgeNativeMethods
148166 internal static extern JsErrorCode JsCreateObject ( out EdgeJsValue obj ) ;
149167
150168 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
151- internal static extern JsErrorCode JsCreateExternalObject ( IntPtr data , JsObjectFinalizeCallback finalizeCallback , out EdgeJsValue obj ) ;
169+ internal static extern JsErrorCode JsCreateExternalObject ( IntPtr data ,
170+ JsObjectFinalizeCallback finalizeCallback , out EdgeJsValue obj ) ;
152171
153172 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
154173 internal static extern JsErrorCode JsConvertValueToObject ( EdgeJsValue value , out EdgeJsValue obj ) ;
@@ -166,34 +185,42 @@ internal static class EdgeNativeMethods
166185 internal static extern JsErrorCode JsPreventExtension ( EdgeJsValue obj ) ;
167186
168187 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
169- internal static extern JsErrorCode JsGetProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId , out EdgeJsValue value ) ;
188+ internal static extern JsErrorCode JsGetProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
189+ out EdgeJsValue value ) ;
170190
171191 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
172- internal static extern JsErrorCode JsGetOwnPropertyDescriptor ( EdgeJsValue obj , EdgeJsPropertyId propertyId , out EdgeJsValue propertyDescriptor ) ;
192+ internal static extern JsErrorCode JsGetOwnPropertyDescriptor ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
193+ out EdgeJsValue propertyDescriptor ) ;
173194
174195 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
175196 internal static extern JsErrorCode JsGetOwnPropertyNames ( EdgeJsValue obj , out EdgeJsValue propertyNames ) ;
176197
177198 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
178- internal static extern JsErrorCode JsSetProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId , EdgeJsValue value , bool useStrictRules ) ;
199+ internal static extern JsErrorCode JsSetProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
200+ EdgeJsValue value , bool useStrictRules ) ;
179201
180202 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
181- internal static extern JsErrorCode JsHasProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId , out bool hasProperty ) ;
203+ internal static extern JsErrorCode JsHasProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
204+ out bool hasProperty ) ;
182205
183206 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
184- internal static extern JsErrorCode JsDeleteProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId , bool useStrictRules , out EdgeJsValue result ) ;
207+ internal static extern JsErrorCode JsDeleteProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
208+ bool useStrictRules , out EdgeJsValue result ) ;
185209
186210 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
187- internal static extern JsErrorCode JsDefineProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId , EdgeJsValue propertyDescriptor , out bool result ) ;
211+ internal static extern JsErrorCode JsDefineProperty ( EdgeJsValue obj , EdgeJsPropertyId propertyId ,
212+ EdgeJsValue propertyDescriptor , out bool result ) ;
188213
189214 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
190215 internal static extern JsErrorCode JsHasIndexedProperty ( EdgeJsValue obj , EdgeJsValue index , out bool result ) ;
191216
192217 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
193- internal static extern JsErrorCode JsGetIndexedProperty ( EdgeJsValue obj , EdgeJsValue index , out EdgeJsValue result ) ;
218+ internal static extern JsErrorCode JsGetIndexedProperty ( EdgeJsValue obj , EdgeJsValue index ,
219+ out EdgeJsValue result ) ;
194220
195221 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
196- internal static extern JsErrorCode JsSetIndexedProperty ( EdgeJsValue obj , EdgeJsValue index , EdgeJsValue value ) ;
222+ internal static extern JsErrorCode JsSetIndexedProperty ( EdgeJsValue obj , EdgeJsValue index ,
223+ EdgeJsValue value ) ;
197224
198225 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
199226 internal static extern JsErrorCode JsDeleteIndexedProperty ( EdgeJsValue obj , EdgeJsValue index ) ;
@@ -217,13 +244,16 @@ internal static class EdgeNativeMethods
217244 internal static extern JsErrorCode JsCreateArray ( uint length , out EdgeJsValue result ) ;
218245
219246 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
220- internal static extern JsErrorCode JsCallFunction ( EdgeJsValue function , EdgeJsValue [ ] arguments , ushort argumentCount , out EdgeJsValue result ) ;
247+ internal static extern JsErrorCode JsCallFunction ( EdgeJsValue function , EdgeJsValue [ ] arguments ,
248+ ushort argumentCount , out EdgeJsValue result ) ;
221249
222250 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
223- internal static extern JsErrorCode JsConstructObject ( EdgeJsValue function , EdgeJsValue [ ] arguments , ushort argumentCount , out EdgeJsValue result ) ;
251+ internal static extern JsErrorCode JsConstructObject ( EdgeJsValue function , EdgeJsValue [ ] arguments ,
252+ ushort argumentCount , out EdgeJsValue result ) ;
224253
225254 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
226- internal static extern JsErrorCode JsCreateFunction ( EdgeJsNativeFunction nativeFunction , IntPtr externalData , out EdgeJsValue function ) ;
255+ internal static extern JsErrorCode JsCreateFunction ( EdgeJsNativeFunction nativeFunction ,
256+ IntPtr externalData , out EdgeJsValue function ) ;
227257
228258 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
229259 internal static extern JsErrorCode JsCreateError ( EdgeJsValue message , out EdgeJsValue error ) ;
@@ -262,7 +292,8 @@ internal static class EdgeNativeMethods
262292 internal static extern JsErrorCode JsIsRuntimeExecutionDisabled ( EdgeJsRuntime runtime , out bool isDisabled ) ;
263293
264294 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
265- internal static extern JsErrorCode JsStartProfiling ( IActiveScriptProfilerCallback callback , ProfilerEventMask eventMask , int context ) ;
295+ internal static extern JsErrorCode JsStartProfiling ( IActiveScriptProfilerCallback callback ,
296+ ProfilerEventMask eventMask , int context ) ;
266297
267298 [ DllImport ( DllName . Chakra , CharSet = CharSet . Unicode ) ]
268299 internal static extern JsErrorCode JsStopProfiling ( int reason ) ;
0 commit comments