oracledb 3.0.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/CHANGELOG.md +135 -8
  2. package/README.md +6 -4
  3. package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-abi48-linux-x64.node +0 -0
  6. package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-abi48-win32-x64.node +0 -0
  8. package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
  10. package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-abi57-linux-x64.node +0 -0
  12. package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-abi57-win32-x64.node +0 -0
  14. package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
  15. package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
  16. package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
  17. package/build/Release/oracledb-abi64-linux-x64.node +0 -0
  18. package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
  19. package/build/Release/oracledb-abi64-win32-x64.node +0 -0
  20. package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
  21. package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
  22. package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
  23. package/build/Release/oracledb-abi67-linux-x64.node +0 -0
  24. package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
  25. package/build/Release/oracledb-abi67-win32-x64.node +0 -0
  26. package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
  27. package/lib/connection.js +18 -4
  28. package/lib/oracledb.js +44 -92
  29. package/lib/pool.js +36 -2
  30. package/lib/sodaCollection.js +1 -1
  31. package/lib/sodaDatabase.js +1 -1
  32. package/lib/util.js +82 -5
  33. package/package/README.md +32 -101
  34. package/package/install.js +139 -0
  35. package/package/prunebinaries.js +51 -0
  36. package/package.json +4 -11
  37. package/binding.gyp +0 -162
  38. package/lib/rel.txt +0 -1
  39. package/odpi/.npmignore +0 -4
  40. package/odpi/LICENSE.md +0 -218
  41. package/odpi/README.md +0 -61
  42. package/odpi/embed/README.md +0 -4
  43. package/odpi/embed/dpi.c +0 -50
  44. package/odpi/include/dpi.h +0 -1748
  45. package/odpi/src/dpiConn.c +0 -2089
  46. package/odpi/src/dpiContext.c +0 -296
  47. package/odpi/src/dpiData.c +0 -797
  48. package/odpi/src/dpiDebug.c +0 -184
  49. package/odpi/src/dpiDeqOptions.c +0 -370
  50. package/odpi/src/dpiEnqOptions.c +0 -174
  51. package/odpi/src/dpiEnv.c +0 -189
  52. package/odpi/src/dpiError.c +0 -204
  53. package/odpi/src/dpiErrorMessages.h +0 -86
  54. package/odpi/src/dpiGen.c +0 -303
  55. package/odpi/src/dpiGlobal.c +0 -292
  56. package/odpi/src/dpiHandleList.c +0 -117
  57. package/odpi/src/dpiHandlePool.c +0 -118
  58. package/odpi/src/dpiImpl.h +0 -1707
  59. package/odpi/src/dpiLob.c +0 -506
  60. package/odpi/src/dpiMsgProps.c +0 -386
  61. package/odpi/src/dpiObject.c +0 -897
  62. package/odpi/src/dpiObjectAttr.c +0 -115
  63. package/odpi/src/dpiObjectType.c +0 -326
  64. package/odpi/src/dpiOci.c +0 -3527
  65. package/odpi/src/dpiOracleType.c +0 -492
  66. package/odpi/src/dpiPool.c +0 -549
  67. package/odpi/src/dpiRowid.c +0 -136
  68. package/odpi/src/dpiSodaColl.c +0 -685
  69. package/odpi/src/dpiSodaCollCursor.c +0 -143
  70. package/odpi/src/dpiSodaDb.c +0 -432
  71. package/odpi/src/dpiSodaDoc.c +0 -230
  72. package/odpi/src/dpiSodaDocCursor.c +0 -143
  73. package/odpi/src/dpiStmt.c +0 -1797
  74. package/odpi/src/dpiSubscr.c +0 -674
  75. package/odpi/src/dpiUtils.c +0 -410
  76. package/odpi/src/dpiVar.c +0 -1794
  77. package/package/MAKEPKG.BAT +0 -156
  78. package/package/Makefile +0 -85
  79. package/package/createpackage.js +0 -186
  80. package/package/extractpackage.js +0 -76
  81. package/package/getversion.js +0 -37
  82. package/package/oracledbinstall.js +0 -497
  83. package/package/package.json +0 -54
  84. package/package/util.js +0 -286
  85. package/src/njsCommon.cpp +0 -1055
  86. package/src/njsCommon.h +0 -484
  87. package/src/njsConnection.cpp +0 -2926
  88. package/src/njsConnection.h +0 -227
  89. package/src/njsIntLob.cpp +0 -618
  90. package/src/njsIntLob.h +0 -179
  91. package/src/njsMessages.cpp +0 -122
  92. package/src/njsMessages.h +0 -118
  93. package/src/njsOracle.cpp +0 -1274
  94. package/src/njsOracle.h +0 -237
  95. package/src/njsPool.cpp +0 -482
  96. package/src/njsPool.h +0 -132
  97. package/src/njsResultSet.cpp +0 -478
  98. package/src/njsResultSet.h +0 -120
  99. package/src/njsSodaCollection.cpp +0 -507
  100. package/src/njsSodaCollection.h +0 -128
  101. package/src/njsSodaDatabase.cpp +0 -335
  102. package/src/njsSodaDatabase.h +0 -108
  103. package/src/njsSodaDocCursor.cpp +0 -203
  104. package/src/njsSodaDocCursor.h +0 -94
  105. package/src/njsSodaDocument.cpp +0 -412
  106. package/src/njsSodaDocument.h +0 -105
  107. package/src/njsSodaOperation.cpp +0 -557
  108. package/src/njsSodaOperation.h +0 -123
  109. package/src/njsSubscription.cpp +0 -388
  110. package/src/njsSubscription.h +0 -111
  111. package/src/njsUtils.cpp +0 -158
  112. package/src/njsUtils.h +0 -68
package/src/njsCommon.cpp DELETED
@@ -1,1055 +0,0 @@
1
- /* Copyright (c) 2015, 2018, Oracle and/or its affiliates.
2
- All rights reserved. */
3
-
4
- /******************************************************************************
5
- *
6
- * You may not use the identified files except in compliance with the Apache
7
- * License, Version 2.0 (the "License.")
8
- *
9
- * You may obtain a copy of the License at
10
- * http://www.apache.org/licenses/LICENSE-2.0.
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- *
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- *
19
- * This file uses NAN:
20
- *
21
- * Copyright (c) 2015 NAN contributors
22
- *
23
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
24
- *
25
- * Permission is hereby granted, free of charge, to any person obtaining
26
- * a copy of this software and associated documentation files (the
27
- * "Software"), to deal in the Software without restriction, including
28
- * without limitation the rights to use, copy, modify, merge, publish,
29
- * distribute, sublicense, and/or sell copies of the Software, and to
30
- * permit persons to whom the Software is furnished to do so, subject to
31
- * the following conditions:
32
- *
33
- * The above copyright notice and this permission notice shall be
34
- * included in all copies or substantial portions of the Software.
35
- *
36
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
40
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
41
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
42
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43
- *
44
- * NAME
45
- * njsCommon.cpp
46
- *
47
- * DESCRIPTION
48
- * Implementation of common classes used throughout driver.
49
- *
50
- *****************************************************************************/
51
-
52
- #include "njsCommon.h"
53
- #include "njsOracle.h"
54
- #include "njsIntLob.h"
55
- #include "njsSodaDocument.h"
56
- #include "njsSubscription.h"
57
- #include "njsUtils.h"
58
-
59
- using namespace node;
60
- using namespace std;
61
- using namespace v8;
62
-
63
- //-----------------------------------------------------------------------------
64
- // njsVariableBuffer::~njsVariableBuffer()
65
- // Destructor.
66
- //-----------------------------------------------------------------------------
67
- njsVariableBuffer::~njsVariableBuffer()
68
- {
69
- if (lobs) {
70
- delete [] lobs;
71
- lobs = NULL;
72
- }
73
- dpiVarData = NULL;
74
- }
75
-
76
-
77
- //-----------------------------------------------------------------------------
78
- // njsVariable::~njsVariable()
79
- // Destructor.
80
- //-----------------------------------------------------------------------------
81
- njsVariable::~njsVariable()
82
- {
83
- if (dpiVarHandle) {
84
- dpiVar_release(dpiVarHandle);
85
- dpiVarHandle = NULL;
86
- }
87
- if (dmlReturningBuffers) {
88
- delete [] dmlReturningBuffers;
89
- dmlReturningBuffers = NULL;
90
- }
91
- if (queryVars) {
92
- delete [] queryVars;
93
- queryVars = NULL;
94
- }
95
- }
96
-
97
-
98
- //-----------------------------------------------------------------------------
99
- // njsVariable::DataType()
100
- // Return the data type that is being used by the variable. This is an
101
- // enumeration that is publicly available in the oracledb module.
102
- //-----------------------------------------------------------------------------
103
- njsDataType njsVariable::DataType()
104
- {
105
- switch (varTypeNum) {
106
- case DPI_ORACLE_TYPE_VARCHAR:
107
- case DPI_ORACLE_TYPE_NVARCHAR:
108
- case DPI_ORACLE_TYPE_CHAR:
109
- case DPI_ORACLE_TYPE_NCHAR:
110
- case DPI_ORACLE_TYPE_ROWID:
111
- case DPI_ORACLE_TYPE_LONG_VARCHAR:
112
- return NJS_DATATYPE_STR;
113
- case DPI_ORACLE_TYPE_RAW:
114
- case DPI_ORACLE_TYPE_LONG_RAW:
115
- return NJS_DATATYPE_BUFFER;
116
- case DPI_ORACLE_TYPE_NATIVE_FLOAT:
117
- case DPI_ORACLE_TYPE_NATIVE_DOUBLE:
118
- case DPI_ORACLE_TYPE_NATIVE_INT:
119
- case DPI_ORACLE_TYPE_NUMBER:
120
- return NJS_DATATYPE_NUM;
121
- case DPI_ORACLE_TYPE_DATE:
122
- case DPI_ORACLE_TYPE_TIMESTAMP:
123
- case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
124
- case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
125
- return NJS_DATATYPE_DATE;
126
- case DPI_ORACLE_TYPE_CLOB:
127
- case DPI_ORACLE_TYPE_NCLOB:
128
- return NJS_DATATYPE_CLOB;
129
- case DPI_ORACLE_TYPE_BLOB:
130
- return NJS_DATATYPE_BLOB;
131
- default:
132
- break;
133
- }
134
- return NJS_DATATYPE_UNKNOWN;
135
- }
136
-
137
-
138
- //-----------------------------------------------------------------------------
139
- // njsVariable::DBType()
140
- // Return the database data type that the variable represents. This is an
141
- // enumeration that is publicly available in the oracledb module.
142
- //-----------------------------------------------------------------------------
143
- njsDBType njsVariable::DBType()
144
- {
145
- switch (dbTypeNum) {
146
- case DPI_ORACLE_TYPE_VARCHAR:
147
- return NJS_DB_TYPE_VARCHAR;
148
- case DPI_ORACLE_TYPE_NVARCHAR:
149
- return NJS_DB_TYPE_NVARCHAR;
150
- case DPI_ORACLE_TYPE_CHAR:
151
- return NJS_DB_TYPE_CHAR;
152
- case DPI_ORACLE_TYPE_NCHAR:
153
- return NJS_DB_TYPE_NCHAR;
154
- case DPI_ORACLE_TYPE_ROWID:
155
- return NJS_DB_TYPE_ROWID;
156
- case DPI_ORACLE_TYPE_RAW:
157
- return NJS_DB_TYPE_RAW;
158
- case DPI_ORACLE_TYPE_NATIVE_FLOAT:
159
- return NJS_DB_TYPE_BINARY_FLOAT;
160
- case DPI_ORACLE_TYPE_NATIVE_DOUBLE:
161
- return NJS_DB_TYPE_BINARY_DOUBLE;
162
- case DPI_ORACLE_TYPE_NATIVE_INT:
163
- case DPI_ORACLE_TYPE_NUMBER:
164
- return NJS_DB_TYPE_NUMBER;
165
- case DPI_ORACLE_TYPE_DATE:
166
- return NJS_DB_TYPE_DATE;
167
- case DPI_ORACLE_TYPE_TIMESTAMP:
168
- return NJS_DB_TYPE_TIMESTAMP;
169
- case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
170
- return NJS_DB_TYPE_TIMESTAMP_TZ;
171
- case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
172
- return NJS_DB_TYPE_TIMESTAMP_LTZ;
173
- case DPI_ORACLE_TYPE_CLOB:
174
- return NJS_DB_TYPE_CLOB;
175
- case DPI_ORACLE_TYPE_NCLOB:
176
- return NJS_DB_TYPE_NCLOB;
177
- case DPI_ORACLE_TYPE_BLOB:
178
- return NJS_DB_TYPE_BLOB;
179
- case DPI_ORACLE_TYPE_LONG_VARCHAR:
180
- return NJS_DB_TYPE_LONG;
181
- case DPI_ORACLE_TYPE_LONG_RAW:
182
- return NJS_DB_TYPE_LONG_RAW;
183
- default:
184
- break;
185
- }
186
- return NJS_DB_TYPE_UNKNOWN;
187
- }
188
-
189
-
190
- //-----------------------------------------------------------------------------
191
- // njsBaton::~njsBaton()
192
- // Destructor.
193
- //-----------------------------------------------------------------------------
194
- njsBaton::~njsBaton()
195
- {
196
- jsCallback.Reset();
197
- jsCallingObj.Reset();
198
- jsOracledb.Reset();
199
- jsSubscription.Reset();
200
- jsBuffer.Reset();
201
- ClearAsyncData();
202
- }
203
-
204
-
205
- //-----------------------------------------------------------------------------
206
- // njsBaton::CheckJSException()
207
- // Check for a JavaScript exception in the TryCatch variable. If one is
208
- // found, acquire the message and store it in the baton error so that it will
209
- // be propagated to the callback, then reset the exception so that it will not
210
- // be raised in JavaScript once the C++ method has completed its work.
211
- //-----------------------------------------------------------------------------
212
- void njsBaton::CheckJSException(Nan::TryCatch *tryCatch)
213
- {
214
- if (tryCatch->HasCaught()) {
215
- Local<String> message = tryCatch->Message()->Get();
216
- Nan::Utf8String v8str(message->ToString());
217
- error = std::string(*v8str, static_cast<size_t>(v8str.length()));
218
- tryCatch->Reset();
219
- }
220
- }
221
-
222
-
223
- //-----------------------------------------------------------------------------
224
- // njsBaton::ClearAsyncData()
225
- // Clear the baton of everything except for the JavaScript references which
226
- // must be reset in the main thread.
227
- //-----------------------------------------------------------------------------
228
- void njsBaton::ClearAsyncData()
229
- {
230
- if (dpiPoolHandle) {
231
- dpiPool_release(dpiPoolHandle);
232
- dpiPoolHandle = NULL;
233
- }
234
- if (dpiConnHandle) {
235
- dpiConn_release(dpiConnHandle);
236
- dpiConnHandle = NULL;
237
- }
238
- if (dpiStmtHandle) {
239
- dpiStmt_release(dpiStmtHandle);
240
- dpiStmtHandle = NULL;
241
- }
242
- if (dpiLobHandle) {
243
- dpiLob_release(dpiLobHandle);
244
- dpiLobHandle = NULL;
245
- }
246
- if (dpiSubscrHandle) {
247
- dpiSubscr_release(dpiSubscrHandle);
248
- dpiSubscrHandle = NULL;
249
- }
250
- if (sodaCollNames) {
251
- dpiSodaDb_freeCollectionNames(dpiSodaDbHandle, sodaCollNames);
252
- delete sodaCollNames;
253
- sodaCollNames = NULL;
254
- }
255
- if (dpiSodaDbHandle) {
256
- dpiSodaDb_release(dpiSodaDbHandle);
257
- dpiSodaDbHandle = NULL;
258
- }
259
- if (dpiSodaCollHandle) {
260
- dpiSodaColl_release(dpiSodaCollHandle);
261
- dpiSodaCollHandle = NULL;
262
- }
263
- if (dpiSodaDocHandle) {
264
- dpiSodaDoc_release(dpiSodaDocHandle);
265
- dpiSodaDocHandle = NULL;
266
- }
267
- if (dpiSodaDocCursorHandle) {
268
- dpiSodaDocCursor_release(dpiSodaDocCursorHandle);
269
- dpiSodaDocCursorHandle = NULL;
270
- }
271
- if (bindVars) {
272
- delete [] bindVars;
273
- bindVars = NULL;
274
- numBindVars = 0;
275
- }
276
- if (protoILob) {
277
- delete protoILob;
278
- protoILob = NULL;
279
- }
280
- if (queryVars) {
281
- delete [] queryVars;
282
- queryVars = NULL;
283
- numQueryVars = 0;
284
- }
285
- if (fetchInfo) {
286
- delete [] fetchInfo;
287
- fetchInfo = NULL;
288
- numFetchInfo = 0;
289
- }
290
- if (fetchAsStringTypes) {
291
- delete [] fetchAsStringTypes;
292
- fetchAsStringTypes = NULL;
293
- numFetchAsStringTypes = 0;
294
- }
295
- if (fetchAsBufferTypes) {
296
- delete [] fetchAsBufferTypes;
297
- fetchAsBufferTypes = NULL;
298
- numFetchAsBufferTypes = 0;
299
- }
300
- if (batchErrorInfos) {
301
- delete [] batchErrorInfos;
302
- batchErrorInfos = NULL;
303
- numBatchErrorInfos = 0;
304
- }
305
- if (sodaOperOptions) {
306
- if (sodaOperOptions->keys) {
307
- delete sodaOperOptions->keys;
308
- sodaOperOptions->keys = NULL;
309
- }
310
- if (sodaOperOptions->keyLengths) {
311
- delete sodaOperOptions->keyLengths;
312
- sodaOperOptions->keyLengths = NULL;
313
- }
314
- delete sodaOperOptions;
315
- sodaOperOptions = NULL;
316
- }
317
- }
318
-
319
-
320
- //-----------------------------------------------------------------------------
321
- // njsBaton::GetOracledb()
322
- // Return the Oracledb object stored in the baton as a JS object.
323
- //-----------------------------------------------------------------------------
324
- njsOracledb *njsBaton::GetOracledb()
325
- {
326
- Nan::HandleScope scope;
327
- Local<Object> obj = Nan::New(jsOracledb);
328
- return Nan::ObjectWrap::Unwrap<njsOracledb>(obj);
329
- }
330
-
331
-
332
- //-----------------------------------------------------------------------------
333
- // njsBaton::AsyncWorkCallback()
334
- // Callback used during asynchronous processing that takes place on a
335
- // separate thread. This simply calls the assigned routine directly, passing
336
- // the baton -- but only if an error has not already taken place. Blocking
337
- // calls should be made here.
338
- //-----------------------------------------------------------------------------
339
- void njsBaton::AsyncWorkCallback(uv_work_t *req)
340
- {
341
- njsBaton *baton = (njsBaton*) req->data;
342
- if (baton->error.empty())
343
- baton->workCallback(baton);
344
- }
345
-
346
-
347
- //-----------------------------------------------------------------------------
348
- // njsBaton::AsyncAfterWorkCallback()
349
- // Callback used during asynchronous processing that takes place on the main
350
- // thread after the work on the separate thread has been completed. Blocking
351
- // calls should be avoided. The baton is destroyed after the assigned routine
352
- // is called. Exceptions are caught and a fatal exception is raised in such
353
- // cases.
354
- //-----------------------------------------------------------------------------
355
- void njsBaton::AsyncAfterWorkCallback(uv_work_t *req, int status)
356
- {
357
- Nan::HandleScope scope;
358
- njsBaton *baton = (njsBaton*) req->data;
359
- Nan::TryCatch tc;
360
- Local<Value> *callbackArgs = new Local<Value>[baton->numCallbackArgs];
361
- unsigned int i, numCallbackArgs = baton->numCallbackArgs;
362
- Local<Object> errorObj;
363
-
364
- // set all parameters but the first as undefined; the first parameter is
365
- // always expected to be the error and should be null
366
- callbackArgs[0] = Nan::Null();
367
- for (i = 1; i < numCallbackArgs; i++)
368
- callbackArgs[i] = Nan::Undefined();
369
-
370
- // if no error so far, call the after work callback, if needed
371
- if (baton->error.empty() && baton->afterWorkCallback)
372
- baton->afterWorkCallback(baton, callbackArgs);
373
-
374
- // if we have an error, set it as the first parameter
375
- // reset all remaining parameters as undefined
376
- if (!baton->error.empty()) {
377
- callbackArgs[0] = v8::Exception::Error(Nan::New<v8::String>(
378
- baton->error).ToLocalChecked());
379
- if (baton->dpiError) {
380
- errorObj = callbackArgs[0]->ToObject();
381
- Nan::Set(errorObj,
382
- Nan::New<v8::String>("errorNum").ToLocalChecked(),
383
- Nan::New<v8::Number>(baton->errorInfo.code));
384
- Nan::Set(errorObj, Nan::New<v8::String>("offset").ToLocalChecked(),
385
- Nan::New<v8::Number>(baton->errorInfo.offset));
386
- }
387
- for (i = 1; i < numCallbackArgs; i++)
388
- callbackArgs[i] = Nan::Undefined();
389
- }
390
-
391
- // if this baton is considered the active baton, clear it
392
- if (baton->callingObj && baton == baton->callingObj->activeBaton)
393
- baton->callingObj->activeBaton = NULL;
394
-
395
- // delete the baton before the callback is made so any unnecessary
396
- // ODPI-C handles are released as soon as possible
397
- Local<Function> callback = Nan::New<Function>(baton->jsCallback);
398
- delete baton;
399
-
400
- // make JS callback
401
- Nan::AsyncResource *asyncResource =
402
- new Nan::AsyncResource("node-oracledb");
403
- asyncResource->runInAsyncScope(Nan::GetCurrentContext()->Global(),
404
- callback, static_cast<int>(numCallbackArgs), callbackArgs);
405
- delete asyncResource;
406
-
407
- // we no longer need the callback args
408
- delete [] callbackArgs;
409
-
410
- // raise fatal exception if an exception was caught
411
- if (tc.HasCaught())
412
- Nan::FatalException(tc);
413
- }
414
-
415
-
416
- //-----------------------------------------------------------------------------
417
- // njsBaton::GetDPIError()
418
- // Gets the error information from DPI and stores it in the baton. It then
419
- // clears all information from the baton. This is done here so that there are
420
- // no possible race conditions when errors take place.
421
- //-----------------------------------------------------------------------------
422
- void njsBaton::GetDPIError(void)
423
- {
424
- dpiContext_getError(njsOracledb::GetDPIContext(), &errorInfo);
425
- if (errorInfo.code == 1406) {
426
- error = njsMessages::Get(errInsufficientBufferForBinds);
427
- } else {
428
- error = std::string(errorInfo.message, errorInfo.messageLength);
429
- dpiError = true;
430
- }
431
- ClearAsyncData();
432
- }
433
-
434
-
435
- //-----------------------------------------------------------------------------
436
- // njsBaton::SetDPIConnHandle()
437
- // Set the DPI connection handle. This adds a reference to the DPI connection
438
- // which will be released in the destructor.
439
- //-----------------------------------------------------------------------------
440
- void njsBaton::SetDPIConnHandle(dpiConn *handle)
441
- {
442
- if (dpiConn_addRef(handle) < 0) {
443
- GetDPIError();
444
- } else {
445
- dpiConnHandle = handle;
446
- }
447
- }
448
-
449
-
450
- //-----------------------------------------------------------------------------
451
- // njsBaton::SetDPIPoolHandle()
452
- // Set the DPI pool handle. This adds a reference to the DPI pool
453
- // which will be released in the destructor.
454
- //-----------------------------------------------------------------------------
455
- void njsBaton::SetDPIPoolHandle(dpiPool *handle)
456
- {
457
- if (dpiPool_addRef(handle) < 0) {
458
- GetDPIError();
459
- } else {
460
- dpiPoolHandle = handle;
461
- }
462
- }
463
-
464
-
465
- //-----------------------------------------------------------------------------
466
- // njsBaton::SetDPIStmtHandle()
467
- // Set the DPI statement handle. This adds a reference to the DPI statement
468
- // which will be released in the destructor.
469
- //-----------------------------------------------------------------------------
470
- void njsBaton::SetDPIStmtHandle(dpiStmt *handle)
471
- {
472
- if (dpiStmt_addRef(handle) < 0) {
473
- GetDPIError();
474
- } else {
475
- dpiStmtHandle = handle;
476
- }
477
- }
478
-
479
-
480
- //-----------------------------------------------------------------------------
481
- // njsBaton::SetDPILobHandle()
482
- // Set the DPI statement handle. This adds a reference to the DPI LOB which
483
- // will be released in the destructor.
484
- //-----------------------------------------------------------------------------
485
- void njsBaton::SetDPILobHandle(dpiLob *handle)
486
- {
487
- if (dpiLob_addRef(handle) < 0) {
488
- GetDPIError();
489
- } else {
490
- dpiLobHandle = handle;
491
- }
492
- }
493
-
494
-
495
- //-----------------------------------------------------------------------------
496
- // njsBaton::SetDPISubscrHandle()
497
- // Set the DPI subscription handle. This adds a reference to the DPI
498
- // subscription which will be released in the destructor.
499
- //-----------------------------------------------------------------------------
500
- void njsBaton::SetDPISubscrHandle(dpiSubscr *handle)
501
- {
502
- if (dpiSubscr_addRef(handle) < 0) {
503
- GetDPIError();
504
- } else {
505
- dpiSubscrHandle = handle;
506
- }
507
- }
508
-
509
-
510
- //-----------------------------------------------------------------------------
511
- // njsBaton::SetDPISodaDbHandle()
512
- // Set the DPI SODA database handle. This adds a reference to the DPI SODA
513
- // database which will be released in the destructor.
514
- //-----------------------------------------------------------------------------
515
- void njsBaton::SetDPISodaDbHandle(dpiSodaDb *handle)
516
- {
517
- if (dpiSodaDb_addRef(handle) < 0) {
518
- GetDPIError();
519
- } else {
520
- dpiSodaDbHandle = handle;
521
- }
522
- }
523
-
524
-
525
- //-----------------------------------------------------------------------------
526
- // njsBaton::SetDPISodaCollHandle()
527
- // Set the DPI SODA collection handle. This adds a reference to the DPI
528
- // SODA collection which will be released in the destructor.
529
- //-----------------------------------------------------------------------------
530
- void njsBaton::SetDPISodaCollHandle(dpiSodaColl *handle)
531
- {
532
- if (dpiSodaColl_addRef(handle) < 0) {
533
- GetDPIError();
534
- } else {
535
- dpiSodaCollHandle = handle;
536
- }
537
- }
538
-
539
-
540
- //-----------------------------------------------------------------------------
541
- // njsBaotn::SetDPISodaDocHandle()
542
- // Set the DPI SODA document handle. This adds a reference to the DPI SODA
543
- // document, which will be released in the destructor.
544
- //-----------------------------------------------------------------------------
545
- void njsBaton::SetDPISodaDocHandle(dpiSodaDoc *handle)
546
- {
547
- if (dpiSodaDoc_addRef(handle) < 0) {
548
- GetDPIError();
549
- } else {
550
- dpiSodaDocHandle = handle;
551
- }
552
- }
553
-
554
-
555
- //-----------------------------------------------------------------------------
556
- // njsBaton::SetDPISodaDocCursorHandle()
557
- // Set the DPI SODA document cursor handle. This adds a reference to the DPI
558
- // SODA document cursor, which will be released in the destructor.
559
- //-----------------------------------------------------------------------------
560
- void njsBaton::SetDPISodaDocCursorHandle(dpiSodaDocCursor *handle)
561
- {
562
- if (dpiSodaDocCursor_addRef(handle) < 0) {
563
- GetDPIError();
564
- } else {
565
- dpiSodaDocCursorHandle = handle;
566
- }
567
- }
568
-
569
-
570
- //-----------------------------------------------------------------------------
571
- // njsBaton::GetBoolFromJSON()
572
- // Gets a boolean value from the JSON object for the given key, if possible.
573
- // If undefined, leave value alone. Index is the argument index in the caller.
574
- // It is unused in this method as any argument passed is converted to a boolean
575
- // value and no error is raised; the method signature remains the same, though,
576
- // to match the equivalent string and unsigned integer methods.
577
- //-----------------------------------------------------------------------------
578
- bool njsBaton::GetBoolFromJSON(Local<Object> obj, const char *key, int index,
579
- bool *value)
580
- {
581
- Nan::HandleScope scope;
582
- Local<Value> jsValue;
583
-
584
- if (!error.empty())
585
- return false;
586
-
587
- MaybeLocal<Value> mval = Nan::Get (obj, Nan::New(key).ToLocalChecked());
588
- if(!mval.ToLocal(&jsValue))
589
- return false;
590
-
591
- /* Undefined implies value not provided or equivalent */
592
- if (!jsValue->IsUndefined()) {
593
- if(jsValue->IsBoolean()) {
594
- *value = jsValue->ToBoolean()->Value();
595
- } else {
596
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
597
- index + 1);
598
- return false;
599
- }
600
- }
601
-
602
- return true;
603
- }
604
-
605
-
606
- //-----------------------------------------------------------------------------
607
- // njsBaton::GetFunctionFromJSON()
608
- // Gets a function from the JSON object for the given key, if possible. If
609
- // undefined, leave value alone and do not set error; otherwise, set error.
610
- // Index is the argument index in the caller.
611
- //-----------------------------------------------------------------------------
612
- bool njsBaton::GetFunctionFromJSON(Local<Object> obj, const char *key,
613
- int index, Local<Function> *value)
614
- {
615
- Nan::EscapableHandleScope scope;
616
- Local<Value> jsValue;
617
-
618
- if (!error.empty())
619
- return false;
620
- MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
621
- if (!mval.ToLocal(&jsValue))
622
- return false;
623
- if (jsValue->IsFunction()) {
624
- *value = scope.Escape(jsValue.As<Function>());
625
- return true;
626
- } else if (jsValue->IsUndefined()) {
627
- return true;
628
- }
629
- error = njsMessages::Get(errInvalidPropertyTypeInParam, key, index + 1);
630
- return false;
631
- }
632
-
633
-
634
- //-----------------------------------------------------------------------------
635
- // njsBaton::GetIntFromJSON()
636
- // Gets a signed integer value from the JSON object for the given key, if
637
- // possible. If undefined, leave value alone and do not set error; otherwise,
638
- // set error. Index is the argument index in the caller.
639
- //-----------------------------------------------------------------------------
640
- bool njsBaton::GetIntFromJSON(Local<Object> obj, const char *key,
641
- int index, int32_t *value)
642
- {
643
- return njsUtils::GetIntFromJSON(obj, key, index, value, error);
644
- }
645
-
646
-
647
- //-----------------------------------------------------------------------------
648
- // njsBaton::GetPositiveIntFromJSON()
649
- // Gets a positive integer value from the JSON object for the given key, if
650
- // possible. If undefined, leave value alone and do not set error; otherwise,
651
- // set error. Index is the argument index in the caller.
652
- //-----------------------------------------------------------------------------
653
- bool njsBaton::GetPositiveIntFromJSON(Local<Object> obj, const char *key,
654
- int index, uint32_t *value)
655
- {
656
- uint32_t tempValue = *value;
657
-
658
- if (!GetUnsignedIntFromJSON(obj, key, index, &tempValue))
659
- return false;
660
- if (tempValue == 0) {
661
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
662
- index + 1);
663
- return false;
664
- }
665
- *value = tempValue;
666
- return true;
667
- }
668
-
669
-
670
- //-----------------------------------------------------------------------------
671
- // njsBaton::GetStringFromJSON()
672
- // Gets a string value from the JSON object for the given key, if possible.
673
- // If null or undefined, leave value alone and do not set error; otherwise, set
674
- // error. Index is the argument index in the caller.
675
- //-----------------------------------------------------------------------------
676
- bool njsBaton::GetStringFromJSON(Local<Object> obj, const char *key, int index,
677
- string &value)
678
- {
679
- return njsUtils::GetStringFromJSON(obj, key, index, value, error);
680
- }
681
-
682
-
683
- //-----------------------------------------------------------------------------
684
- // njsBaton::GetUnsignedIntFromJSON()
685
- // Gets an unsigned integer value from the JSON object for the given key, if
686
- // possible. If undefined, leave value alone and do not set error; otherwise,
687
- // set error. Index is the argument index in the caller.
688
- //-----------------------------------------------------------------------------
689
- bool njsBaton::GetUnsignedIntFromJSON(Local<Object> obj, const char *key,
690
- int index, uint32_t *value)
691
- {
692
- Nan::HandleScope scope;
693
- Local<Value> jsValue;
694
-
695
- if (!error.empty())
696
- return false;
697
-
698
- MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
699
- if (!mval.ToLocal(&jsValue))
700
- return false;
701
- if (jsValue->IsUint32()) {
702
- *value = Nan::To<uint32_t>(jsValue).FromJust();
703
- return true;
704
- } else if (jsValue->IsUndefined()) {
705
- return true;
706
- } else if (jsValue->IsNumber() || jsValue->IsNull()) {
707
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
708
- index + 1);
709
- return false;
710
- } else {
711
- error = njsMessages::Get(errInvalidPropertyTypeInParam, key,
712
- index + 1);
713
- return false;
714
- }
715
- }
716
-
717
-
718
- //-----------------------------------------------------------------------------
719
- // njsBaton::GetSodaDocument()
720
- // Examines the passed object. If it is a buffer object, a new SODA document
721
- // is created; otherwise, it is an existing SODA document object and the
722
- // reference to it is retained on the baton (this is checked in Javascript).
723
- //-----------------------------------------------------------------------------
724
- bool njsBaton::GetSodaDocument(Local<Object> obj, dpiSodaDb *db)
725
- {
726
- if (Buffer::HasInstance(obj)) {
727
- if (dpiSodaDb_createDocument(db, NULL, 0,
728
- Buffer::Data(obj), Buffer::Length(obj), NULL, 0,
729
- DPI_SODA_FLAGS_DEFAULT, &dpiSodaDocHandle) < 0) {
730
- GetDPIError();
731
- return false;
732
- }
733
- } else {
734
- njsSodaDocument *doc = Nan::ObjectWrap::Unwrap<njsSodaDocument>(obj);
735
- SetDPISodaDocHandle(doc->GetDPISodaDocHandle());
736
- }
737
- return true;
738
- }
739
-
740
-
741
- //-----------------------------------------------------------------------------
742
- // njsBaton::GetNumOutBinds()
743
- // Return the number of in/out and out binds created by the baton.
744
- //-----------------------------------------------------------------------------
745
- uint32_t njsBaton::GetNumOutBinds()
746
- {
747
- uint32_t numOutBinds = 0;
748
-
749
- for (uint32_t i = 0; i < numBindVars; i++) {
750
- if (bindVars[i].bindDir != NJS_BIND_IN)
751
- numOutBinds++;
752
- }
753
- return numOutBinds;
754
- }
755
-
756
-
757
- //-----------------------------------------------------------------------------
758
- // njsBaton::QueueWork()
759
- // Queue work on a separate thread. The baton is passed as context. If an
760
- // error has already taken place, the work is not queued on a separate thread;
761
- // instead, the after work method is called directly. If an error takes place
762
- // while queuing the work, a JS exception is raised.
763
- //-----------------------------------------------------------------------------
764
- void njsBaton::QueueWork(const char *methodName,
765
- void (*workCallback)(njsBaton*),
766
- void (*afterWorkCallback)(njsBaton*, Local<Value>[]),
767
- unsigned int numCallbackArgs)
768
- {
769
- this->methodName = methodName;
770
- this->workCallback = workCallback;
771
- this->afterWorkCallback = afterWorkCallback;
772
- this->numCallbackArgs = numCallbackArgs;
773
- if (uv_queue_work(uv_default_loop(), &req, AsyncWorkCallback,
774
- AsyncAfterWorkCallback)) {
775
- delete this;
776
- string errMsg = njsMessages::Get(errInternalError, "uv_queue_work",
777
- methodName);
778
- Nan::ThrowError(errMsg.c_str());
779
- }
780
- }
781
-
782
-
783
- //-----------------------------------------------------------------------------
784
- // njsCommon::CreateBaton()
785
- // Creates a baton for use in asynchronous methods. In each of these cases
786
- // the last argument passed in from JS is expected to be a JS callback. NULL is
787
- // returned and an exception raised for JS if this is not the case.
788
- //-----------------------------------------------------------------------------
789
- njsBaton *njsCommon::CreateBaton(Nan::NAN_METHOD_ARGS_TYPE args)
790
- {
791
- Nan::HandleScope scope;
792
- Local<Function> callback;
793
- njsBaton *baton;
794
-
795
- if (!args.Length() || !args[(args.Length() - 1)]->IsFunction()) {
796
- string errMsg = njsMessages::Get(errMissingCallback);
797
- Nan::ThrowError(errMsg.c_str());
798
- return NULL;
799
- }
800
- callback = Local<Function>::Cast(args[args.Length() - 1]);
801
- baton = new njsBaton(callback, args.Holder());
802
- if (!IsValid()) {
803
- njsErrorType errNum = GetInvalidErrorType();
804
- baton->error = njsMessages::Get(errNum);
805
- }
806
- return baton;
807
- }
808
-
809
-
810
- //-----------------------------------------------------------------------------
811
- // njsCommon::GetObjectArg()
812
- // Gets an object from the list of arguments. If the argument is not an
813
- // object, an error is raised and false is returned.
814
- //-----------------------------------------------------------------------------
815
- bool njsCommon::GetObjectArg(Nan::NAN_METHOD_ARGS_TYPE args,
816
- int index, Local<Object> &value)
817
- {
818
- Nan::EscapableHandleScope scope;
819
- if (!args[index]->IsObject()) {
820
- string errMsg = njsMessages::Get(errInvalidParameterType, index + 1);
821
- Nan::ThrowError(errMsg.c_str());
822
- return false;
823
- }
824
- value = scope.Escape(args[index]->ToObject());
825
- return true;
826
- }
827
-
828
-
829
- //-----------------------------------------------------------------------------
830
- // njsCommon::GetStringArg()
831
- // Gets a string from the list of arguments. If the argument is not a
832
- // string, an error is raised and false is returned.
833
- //-----------------------------------------------------------------------------
834
- bool njsCommon::GetStringArg(Nan::NAN_METHOD_ARGS_TYPE args,
835
- int index, std::string &value)
836
- {
837
- Nan::HandleScope scope;
838
- if (!args[index]->IsString()) {
839
- string errMsg = njsMessages::Get(errInvalidParameterType, index + 1);
840
- Nan::ThrowError(errMsg.c_str());
841
- return false;
842
- }
843
- Nan::Utf8String utf8str(args[index]->ToString());
844
- value = std::string(*utf8str, static_cast<size_t>(utf8str.length()));
845
- return true;
846
- }
847
-
848
-
849
- //-----------------------------------------------------------------------------
850
- // njsCommon::GetUnsignedIntArg()
851
- // Gets a unsigned integer from the list of arguments. If the argument is not
852
- // a string, an error is raised and false is returned.
853
- //-----------------------------------------------------------------------------
854
- bool njsCommon::GetUnsignedIntArg(Nan::NAN_METHOD_ARGS_TYPE args,
855
- int index, uint32_t *value)
856
- {
857
- if (!args[index]->IsUint32()) {
858
- string errMsg = njsMessages::Get(errInvalidParameterType, index + 1);
859
- Nan::ThrowError(errMsg.c_str());
860
- return false;
861
- }
862
- *value = Nan::To<uint32_t>(args[index]).FromJust();
863
- return true;
864
- }
865
-
866
-
867
- //-----------------------------------------------------------------------------
868
- // njsCommon::SetPropBool()
869
- // Sets a property to a boolean value. If the value is not a boolean, an
870
- // error is raised and false is returned.
871
- //-----------------------------------------------------------------------------
872
- bool njsCommon::SetPropBool(Local<Value> value, bool *valuePtr,
873
- const char *name)
874
- {
875
- if (!value->IsBoolean()) {
876
- string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
877
- Nan::ThrowError(errMsg.c_str());
878
- return false;
879
- }
880
- *valuePtr = value->ToBoolean()->Value();
881
- return true;
882
- }
883
-
884
-
885
- //-----------------------------------------------------------------------------
886
- // njsCommon::SetPropInt()
887
- // Sets a property to an integer value. If the value is not an integer, an
888
- // error is raised and false is returned.
889
- //-----------------------------------------------------------------------------
890
- bool njsCommon::SetPropInt(Local<Value> value, int32_t *valuePtr,
891
- const char *name)
892
- {
893
- if (!value->IsInt32()) {
894
- string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
895
- Nan::ThrowError(errMsg.c_str());
896
- return false;
897
- }
898
- *valuePtr = Nan::To<int32_t>(value).FromJust();
899
- return true;
900
- }
901
-
902
-
903
- //-----------------------------------------------------------------------------
904
- // njsCommon::SetPropPositiveInt()
905
- // Sets a property to a positive integer value. If the value is not a
906
- // positive integer, an error is raised and false is returned.
907
- //-----------------------------------------------------------------------------
908
- bool njsCommon::SetPropPositiveInt(Local<Value> value, uint32_t *valuePtr,
909
- const char *name)
910
- {
911
- uint32_t tempValue = *valuePtr;
912
-
913
- if (!SetPropUnsignedInt(value, &tempValue, name))
914
- return false;
915
- if (tempValue == 0) {
916
- string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
917
- Nan::ThrowError(errMsg.c_str());
918
- return false;
919
- }
920
- *valuePtr = tempValue;
921
- return true;
922
- }
923
-
924
-
925
- //-----------------------------------------------------------------------------
926
- // njsCommon::SetPropString()
927
- // Sets a property to a string value. If the value is not a string, an error
928
- // is raised and false is returned.
929
- //-----------------------------------------------------------------------------
930
- bool njsCommon::SetPropString(Local<Value> value, std::string *valuePtr,
931
- const char *name)
932
- {
933
- if (!value->IsString()) {
934
- string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
935
- Nan::ThrowError(errMsg.c_str());
936
- return false;
937
- }
938
- Nan::Utf8String utfstr(value->ToString());
939
- *valuePtr = std::string(*utfstr, static_cast<size_t>(utfstr.length()));
940
- return true;
941
- }
942
-
943
-
944
- //-----------------------------------------------------------------------------
945
- // njsCommon::SetPropUnsignedInt()
946
- // Sets a property to an unsigned integer value. If the value is not an
947
- // unsigned integer, an error is raised and false is returned.
948
- //-----------------------------------------------------------------------------
949
- bool njsCommon::SetPropUnsignedInt(Local<Value> value, uint32_t *valuePtr,
950
- const char *name)
951
- {
952
- if (!value->IsUint32()) {
953
- string errMsg = njsMessages::Get(errInvalidPropertyValue, name);
954
- Nan::ThrowError(errMsg.c_str());
955
- return false;
956
- }
957
- *valuePtr = Nan::To<uint32_t>(value).FromJust();
958
- return true;
959
- }
960
-
961
-
962
- //-----------------------------------------------------------------------------
963
- // njsCommon::Validate()
964
- // Validates the pointer is not NULL and that it refers to a valid object.
965
- // If not, an exception is raised in JS.
966
- //-----------------------------------------------------------------------------
967
- bool njsCommon::Validate(njsCommon *obj, bool checkValid)
968
- {
969
- string errMsg;
970
-
971
- if (!obj) {
972
- errMsg = njsMessages::Get(errInvalidJSObject);
973
- Nan::ThrowError(errMsg.c_str());
974
- return false;
975
- }
976
- if (checkValid && !obj->IsValid()) {
977
- njsErrorType errNum = obj->GetInvalidErrorType();
978
- errMsg = njsMessages::Get(errNum);
979
- Nan::ThrowError(errMsg.c_str());
980
- return false;
981
- }
982
- return true;
983
- }
984
-
985
-
986
- //-----------------------------------------------------------------------------
987
- // njsCommon::ValidateGetter()
988
- // Ensures that the JS caller is valid and returns the C++ object. NULL is
989
- // returned and an exception raised in JS if this is not true.
990
- //-----------------------------------------------------------------------------
991
- njsCommon *njsCommon::ValidateGetter(Nan::NAN_GETTER_ARGS_TYPE args)
992
- {
993
- njsCommon *obj;
994
-
995
- obj = Nan::ObjectWrap::Unwrap<njsCommon>(args.Holder());
996
- if (!Validate(obj, false)) // no exception for invalid object
997
- return NULL;
998
- return obj;
999
- }
1000
-
1001
-
1002
- //-----------------------------------------------------------------------------
1003
- // njsCommon::ValidateSetter()
1004
- // Ensures that the JS caller is valid and returns the C++ object. NULL is
1005
- // returned and an exception raised in JS if this is not true.
1006
- //-----------------------------------------------------------------------------
1007
- njsCommon *njsCommon::ValidateSetter(Nan::NAN_SETTER_ARGS_TYPE args)
1008
- {
1009
- njsCommon *obj;
1010
-
1011
- obj = Nan::ObjectWrap::Unwrap<njsCommon>(args.Holder());
1012
- if (!Validate(obj, true)) // raise exception for invalid object
1013
- return NULL;
1014
- return obj;
1015
- }
1016
-
1017
-
1018
- //-----------------------------------------------------------------------------
1019
- // njsCommon::ValidateArgs()
1020
- // Validates the correct number of arguments have been passed from JS and
1021
- // that the caller is valid. NULL is returned and an exception raised in JS if
1022
- // any of these things are not true.
1023
- //-----------------------------------------------------------------------------
1024
- njsCommon *njsCommon::ValidateArgs(Nan::NAN_METHOD_ARGS_TYPE args,
1025
- int minArgs, int maxArgs)
1026
- {
1027
- njsCommon *obj;
1028
- string errMsg;
1029
-
1030
- obj = Nan::ObjectWrap::Unwrap<njsCommon>(args.Holder());
1031
- if (!obj) {
1032
- errMsg = njsMessages::Get(errInvalidJSObject);
1033
- Nan::ThrowError(errMsg.c_str());
1034
- return NULL;
1035
- }
1036
- if (args.Length() < minArgs || args.Length() > maxArgs) {
1037
- errMsg = njsMessages::Get(errInvalidNumberOfParameters);
1038
- Nan::ThrowError(errMsg.c_str());
1039
- return NULL;
1040
- }
1041
-
1042
- return obj;
1043
- }
1044
-
1045
-
1046
- //-----------------------------------------------------------------------------
1047
- // njsCommon::PropertyIsReadOnly()
1048
- // Raises an exception indicating that the given property is read only.
1049
- //-----------------------------------------------------------------------------
1050
- void njsCommon::PropertyIsReadOnly(const char *name)
1051
- {
1052
- std::string errMsg = njsMessages::Get(errReadOnly, name);
1053
- Nan::ThrowError(errMsg.c_str());
1054
- }
1055
-