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
@@ -1,388 +0,0 @@
1
- /* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
2
-
3
- /******************************************************************************
4
- *
5
- * You may not use the identified files except in compliance with the Apache
6
- * License, Version 2.0 (the "License.")
7
- *
8
- * You may obtain a copy of the License at
9
- * http://www.apache.org/licenses/LICENSE-2.0.
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- *
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * This file uses NAN:
19
- *
20
- * Copyright (c) 2015 NAN contributors
21
- *
22
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining
25
- * a copy of this software and associated documentation files (the
26
- * "Software"), to deal in the Software without restriction, including
27
- * without limitation the rights to use, copy, modify, merge, publish,
28
- * distribute, sublicense, and/or sell copies of the Software, and to
29
- * permit persons to whom the Software is furnished to do so, subject to
30
- * the following conditions:
31
- *
32
- * The above copyright notice and this permission notice shall be
33
- * included in all copies or substantial portions of the Software.
34
- *
35
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
- *
43
- * NAME
44
- * njsSubscription.cpp
45
- *
46
- * DESCRIPTION
47
- * Subscription class implementation.
48
- *
49
- *****************************************************************************/
50
-
51
- #include "njsSubscription.h"
52
- #include "njsOracle.h"
53
-
54
- using namespace std;
55
- using namespace node;
56
- using namespace v8;
57
-
58
- // peristent ResultSet class handle
59
- Nan::Persistent<FunctionTemplate> njsSubscription::subscriptionTemplate_s;
60
-
61
- //-----------------------------------------------------------------------------
62
- // njsSubscription::~njsSubscription()
63
- // Destructor. If notifications have been started (noted by the presence of a
64
- // subscription handle) then notifications will be stopped.
65
- //-----------------------------------------------------------------------------
66
- njsSubscription::~njsSubscription()
67
- {
68
- if (dpiSubscrHandle)
69
- StopNotifications();
70
- }
71
-
72
-
73
- //-----------------------------------------------------------------------------
74
- // njsSubscription::ProcessNotification()
75
- // This method is called inside the event loop in the JavaScript main thread.
76
- // It works together with the EventHandler() method and lets that function
77
- // know when its work is complete by "waiting" for the barrier.
78
- //-----------------------------------------------------------------------------
79
- void njsSubscription::ProcessNotification(uv_async_t *handle)
80
- {
81
- njsSubscription *subscription = (njsSubscription*) handle->data;
82
- Nan::HandleScope scope;
83
-
84
- Local<Function> callback = Nan::New<Function>(subscription->jsCallback);
85
- Local<Value> callbackArgs[1];
86
- callbackArgs[0] = subscription->CreateMessage(subscription->message);
87
- Nan::AsyncResource *asyncResource =
88
- new Nan::AsyncResource("node-oracledb:SubscrCallback");
89
- asyncResource->runInAsyncScope(Nan::GetCurrentContext()->Global(),
90
- callback, 1, callbackArgs);
91
- delete asyncResource;
92
- if (!subscription->message->registered)
93
- subscription->StopNotifications();
94
- subscription->WaitOnBarrier();
95
- }
96
-
97
-
98
- //-----------------------------------------------------------------------------
99
- // njsSubscription::WaitOnBarrier()
100
- // Wait on barrier to ensure that only one message is being processed at a
101
- // time.
102
- //-----------------------------------------------------------------------------
103
- void njsSubscription::WaitOnBarrier()
104
- {
105
- if (uv_barrier_wait(&barrier) > 0) {
106
- uv_barrier_destroy(&barrier);
107
- message = NULL;
108
- }
109
- }
110
-
111
-
112
- //-----------------------------------------------------------------------------
113
- // njsSubscription::Init()
114
- // Initialization function of Subscription class. Maps functions and
115
- // properties from JS to C++.
116
- //-----------------------------------------------------------------------------
117
- void njsSubscription::Init(Local<Object> target)
118
- {
119
- Nan::HandleScope scope;
120
- Local<FunctionTemplate> temp = Nan::New<FunctionTemplate>(New);
121
-
122
- temp->InstanceTemplate()->SetInternalFieldCount(1);
123
- temp->SetClassName(Nan::New<v8::String>("Subscription").ToLocalChecked());
124
-
125
- subscriptionTemplate_s.Reset(temp);
126
- Nan::Set(target, Nan::New<v8::String>("Subscription").ToLocalChecked(),
127
- temp->GetFunction());
128
- }
129
-
130
-
131
- //-----------------------------------------------------------------------------
132
- // njsSubscription::CreateMessage()
133
- // Create message object that will be passed to the callback.
134
- //-----------------------------------------------------------------------------
135
- Local<Object> njsSubscription::CreateMessage(dpiSubscrMessage *message)
136
- {
137
- Nan::EscapableHandleScope scope;
138
- Local<Object> messageObj = Nan::New<Object>();
139
- Local<Value> temp;
140
-
141
- // set type, database name, transaction id and registered flag
142
- Nan::Set(messageObj, Nan::New<String>("type").ToLocalChecked(),
143
- Nan::New<Integer>(message->eventType));
144
- if (message->dbNameLength > 0) {
145
- temp = Nan::New<String>(message->dbName,
146
- message->dbNameLength).ToLocalChecked();
147
- Nan::Set(messageObj, Nan::New<String>("dbName").ToLocalChecked(),
148
- temp);
149
- }
150
- if (message->txIdLength > 0) {
151
- temp = Nan::CopyBuffer((char*) message->txId,
152
- message->txIdLength).ToLocalChecked();
153
- Nan::Set(messageObj, Nan::New<String>("txId").ToLocalChecked(), temp);
154
- }
155
- Nan::Set(messageObj, Nan::New<String>("registered").ToLocalChecked(),
156
- Nan::New<Boolean>(message->registered));
157
-
158
- // set tables, if applicable
159
- if (message->numTables > 0) {
160
- Local<Array> arr = Nan::New<Array>(message->numTables);
161
- Local<Object> element;
162
- for (uint32_t i = 0; i < message->numTables; i++) {
163
- element = CreateMessageTable(&message->tables[i]);
164
- Nan::Set(arr, i, element);
165
- }
166
- Nan::Set(messageObj, Nan::New<String>("tables").ToLocalChecked(), arr);
167
- }
168
-
169
- // set queries, if applicable
170
- if (message->numQueries > 0) {
171
- Local<Array> arr = Nan::New<Array>(message->numQueries);
172
- Local<Object> element;
173
- for (uint32_t i = 0; i < message->numQueries; i++) {
174
- element = CreateMessageQuery(&message->queries[i]);
175
- Nan::Set(arr, i, element);
176
- }
177
- Nan::Set(messageObj, Nan::New<String>("queries").ToLocalChecked(),
178
- arr);
179
- }
180
-
181
- // set queue name, if applicable
182
- if (message->queueNameLength > 0) {
183
- temp = Nan::New<String>(message->queueName,
184
- message->queueNameLength).ToLocalChecked();
185
- Nan::Set(messageObj, Nan::New<String>("queueName").ToLocalChecked(),
186
- temp);
187
- }
188
-
189
- // set consumer name, if applicable
190
- if (message->consumerNameLength > 0) {
191
- temp = Nan::New<String>(message->consumerName,
192
- message->consumerNameLength).ToLocalChecked();
193
- Nan::Set(messageObj, Nan::New<String>("consumerName").ToLocalChecked(),
194
- temp);
195
- }
196
-
197
- return scope.Escape(messageObj);
198
- }
199
-
200
-
201
- //-----------------------------------------------------------------------------
202
- // njsSubscription::CreateMessageQuery()
203
- // Create message query object that will be passed to the callback.
204
- //-----------------------------------------------------------------------------
205
- Local<Object> njsSubscription::CreateMessageQuery(
206
- dpiSubscrMessageQuery *query)
207
- {
208
- Nan::EscapableHandleScope scope;
209
- Local<Object> queryObj = Nan::New<Object>();
210
-
211
- // set tables, if applicable
212
- if (query->numTables > 0) {
213
- Local<Array> arr = Nan::New<Array>(query->numTables);
214
- Local<Object> element;
215
- for (uint32_t i = 0; i < query->numTables; i++) {
216
- element = CreateMessageTable(&query->tables[i]);
217
- Nan::Set(arr, i, element);
218
- }
219
- Nan::Set(queryObj, Nan::New<String>("tables").ToLocalChecked(), arr);
220
- }
221
-
222
- return scope.Escape(queryObj);
223
- }
224
-
225
-
226
- //-----------------------------------------------------------------------------
227
- // njsSubscription::CreateMessageRow()
228
- // Create message row object that will be passed to the callback.
229
- //-----------------------------------------------------------------------------
230
- Local<Object> njsSubscription::CreateMessageRow( dpiSubscrMessageRow *row)
231
- {
232
- Nan::EscapableHandleScope scope;
233
- Local<Object> rowObj = Nan::New<Object>();
234
- Local<Value> temp;
235
-
236
- // set operation and rowid
237
- Nan::Set(rowObj, Nan::New<String>("operation").ToLocalChecked(),
238
- Nan::New<Integer>(row->operation));
239
- temp = Nan::New<String>(row->rowid, row->rowidLength).ToLocalChecked();
240
- Nan::Set(rowObj, Nan::New<String>("rowid").ToLocalChecked(), temp);
241
-
242
- return scope.Escape(rowObj);
243
- }
244
-
245
-
246
- //-----------------------------------------------------------------------------
247
- // njsSubscription::CreateMessageTable()
248
- // Create message table object that will be passed to the callback.
249
- //-----------------------------------------------------------------------------
250
- Local<Object> njsSubscription::CreateMessageTable(
251
- dpiSubscrMessageTable *table)
252
- {
253
- Nan::EscapableHandleScope scope;
254
- Local<Object> tableObj = Nan::New<Object>();
255
- Local<Value> temp;
256
-
257
- // set operation and name
258
- Nan::Set(tableObj, Nan::New<String>("operation").ToLocalChecked(),
259
- Nan::New<Integer>(table->operation));
260
- temp = Nan::New<String>(table->name, table->nameLength).ToLocalChecked();
261
- Nan::Set(tableObj, Nan::New<String>("name").ToLocalChecked(), temp);
262
-
263
- // set rows, if applicable
264
- if (table->numRows > 0) {
265
- Local<Array> arr = Nan::New<Array>(table->numRows);
266
- Local<Object> element;
267
- for (uint32_t i = 0; i < table->numRows; i++) {
268
- element = CreateMessageRow(&table->rows[i]);
269
- Nan::Set(arr, i, element);
270
- }
271
- Nan::Set(tableObj, Nan::New<String>("rows").ToLocalChecked(), arr);
272
- }
273
-
274
- return scope.Escape(tableObj);
275
- }
276
-
277
-
278
- //-----------------------------------------------------------------------------
279
- // njsSubscription::Create()
280
- // Create a new subscription object.
281
- //-----------------------------------------------------------------------------
282
- Local<Object> njsSubscription::Create()
283
- {
284
- Nan::EscapableHandleScope scope;
285
- Local<Function> func = Nan::GetFunction(Nan::New<FunctionTemplate>(
286
- subscriptionTemplate_s)).ToLocalChecked();
287
- Local<Object> obj = Nan::NewInstance(func).ToLocalChecked();
288
- return scope.Escape(obj);
289
- }
290
-
291
-
292
- //-----------------------------------------------------------------------------
293
- // njsSubscription::StartNotifications()
294
- // Start sending notifications to the supplied callback. An async handle is
295
- // created to ensure the event loop doesn't terminate until the subscription is
296
- // deregistered in some way (either directly via unsubscribe() or indirectly
297
- // via the timeout attribute or the quality of service flag that tells a
298
- // subscription to deregister after the first notification has been received).
299
- //-----------------------------------------------------------------------------
300
- void njsSubscription::StartNotifications(njsBaton *baton)
301
- {
302
- if (this->name.empty()) {
303
- this->name = baton->name;
304
- uv_mutex_init(&this->mutex);
305
- uv_async_init(uv_default_loop(), &this->async, ProcessNotification);
306
- this->async.data = this;
307
- this->dpiSubscrHandle = baton->dpiSubscrHandle;
308
- baton->dpiSubscrHandle = NULL;
309
- baton->subscription = NULL;
310
- Local<Value> subscriptionObj = Nan::New(baton->jsSubscription);
311
- njsOracledb::SetSubscription(baton->name, subscriptionObj);
312
- }
313
- }
314
-
315
-
316
- //-----------------------------------------------------------------------------
317
- // njsSubscription::StopNotifications()
318
- // Stop sending notifications to the supplied callback. This happens when the
319
- // subscription is deregistered, either directly via a call to unsubscribe()
320
- // or indirectly via the timeout attribute or the quality of service flag that
321
- // tells a subscription to deregister after the first notification has been
322
- // received.
323
- //-----------------------------------------------------------------------------
324
- void njsSubscription::StopNotifications()
325
- {
326
- uv_close(reinterpret_cast<uv_handle_t*>(&async), OnStopNotifications);
327
- }
328
-
329
-
330
- //-----------------------------------------------------------------------------
331
- // njsSubscription::OnStopNotifications()
332
- // This method is called when the subscription is deregistered. It is called
333
- // in the main thread and is used to perform any clean up that is necessary.
334
- //-----------------------------------------------------------------------------
335
- void njsSubscription::OnStopNotifications(uv_handle_t *handle)
336
- {
337
- Nan::HandleScope scope;
338
- njsSubscription *subscription = (njsSubscription*) handle->data;
339
- if (subscription->dpiSubscrHandle) {
340
- dpiSubscr_release(subscription->dpiSubscrHandle);
341
- subscription->dpiSubscrHandle = NULL;
342
- }
343
- uv_mutex_destroy(&subscription->mutex);
344
- subscription->jsCallback.Reset();
345
- njsOracledb::ClearSubscription(subscription->name);
346
- }
347
-
348
-
349
- //-----------------------------------------------------------------------------
350
- // njsSubscription::EventHandler()
351
- // This method is called by the ODPI-C subscription every time an event is
352
- // received and is called from outside the event loop in a thread that
353
- // Javascript does not know anything about. Since multiple calls to
354
- // uv_async_send() result in only one call to the posted callback, at least
355
- // until after the callback has completed, a barrier is used. This barrier
356
- // ensures that uv_async_send() isn't called again until after the message has
357
- // been successfully processed by the event loop. Note as well that the
358
- // presence of the OPDI-C subscription handle indicates the subscription is
359
- // actually ready to receive notifications. There is a short period of time
360
- // when the subscription is registered but not yet ready to receive
361
- // notifications.
362
- //-----------------------------------------------------------------------------
363
- void njsSubscription::EventHandler(njsSubscription *subscription,
364
- dpiSubscrMessage *incomingMessage)
365
- {
366
- if (subscription->dpiSubscrHandle) {
367
- uv_mutex_lock(&subscription->mutex);
368
- uv_barrier_init(&subscription->barrier, 2);
369
- subscription->message = incomingMessage;
370
- uv_async_send(&subscription->async);
371
- subscription->WaitOnBarrier();
372
- uv_mutex_unlock(&subscription->mutex);
373
- }
374
- }
375
-
376
-
377
- //-----------------------------------------------------------------------------
378
- // njsSubscription::New()
379
- // Create new object accesible from JS. This is always called from within
380
- // njsSubscription::Create() and never from any external JS.
381
- //-----------------------------------------------------------------------------
382
- NAN_METHOD(njsSubscription::New)
383
- {
384
- njsSubscription *subscription = new njsSubscription();
385
- subscription->Wrap(info.Holder());
386
- info.GetReturnValue().Set(info.Holder());
387
- }
388
-
@@ -1,111 +0,0 @@
1
- /* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
2
-
3
- /******************************************************************************
4
- *
5
- * You may not use the identified files except in compliance with the Apache
6
- * License, Version 2.0 (the "License.")
7
- *
8
- * You may obtain a copy of the License at
9
- * http://www.apache.org/licenses/LICENSE-2.0.
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- *
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * This file uses NAN:
19
- *
20
- * Copyright (c) 2015 NAN contributors
21
- *
22
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining
25
- * a copy of this software and associated documentation files (the
26
- * "Software"), to deal in the Software without restriction, including
27
- * without limitation the rights to use, copy, modify, merge, publish,
28
- * distribute, sublicense, and/or sell copies of the Software, and to
29
- * permit persons to whom the Software is furnished to do so, subject to
30
- * the following conditions:
31
- *
32
- * The above copyright notice and this permission notice shall be
33
- * included in all copies or substantial portions of the Software.
34
- *
35
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
- *
43
- * NAME
44
- * njsSubscription.h
45
- *
46
- * DESCRIPTION
47
- * Subscription class
48
- *
49
- *****************************************************************************/
50
-
51
- #ifndef __NJSSUBSCRIPTION_H__
52
- #define __NJSSUBSCRIPTION_H__
53
-
54
- #include "njsCommon.h"
55
-
56
- using namespace v8;
57
- using namespace node;
58
-
59
- //-----------------------------------------------------------------------------
60
- // njsSubscription
61
- // Class exposed to JS for handling subscriptions.
62
- //-----------------------------------------------------------------------------
63
- class njsSubscription: public njsCommon {
64
- public:
65
-
66
- static void Init(Local<Object> target);
67
- bool IsValid() const { return true; };
68
- njsErrorType GetInvalidErrorType() const { return errInvalidSubscription; }
69
- static Local<Object> Create();
70
- dpiSubscrNamespace GetNamespace() const { return subscrNamespace; }
71
- void SetNamespace(dpiSubscrNamespace ns) { subscrNamespace = ns; }
72
- void SetCallback(Local<Function> callback) { jsCallback.Reset(callback); }
73
- void SetDPISubscrHandle(njsBaton *baton)
74
- { baton->SetDPISubscrHandle(dpiSubscrHandle); }
75
- void StartNotifications(njsBaton *baton);
76
- void StopNotifications();
77
-
78
- // event handler
79
- static void EventHandler(njsSubscription *subscription,
80
- dpiSubscrMessage *message);
81
-
82
- private:
83
-
84
- njsSubscription() : dpiSubscrHandle(NULL), message(NULL) {}
85
- ~njsSubscription();
86
-
87
- Local<Object> CreateMessage(dpiSubscrMessage *message);
88
- Local<Object> CreateMessageQuery(dpiSubscrMessageQuery *query);
89
- Local<Object> CreateMessageRow(dpiSubscrMessageRow *row);
90
- Local<Object> CreateMessageTable(dpiSubscrMessageTable *table);
91
-
92
- static void ProcessNotification(uv_async_t *handle);
93
- static void OnStopNotifications(uv_handle_t *handle);
94
- void WaitOnBarrier();
95
-
96
- static NAN_METHOD(New);
97
-
98
- dpiSubscr *dpiSubscrHandle;
99
- uv_async_t async;
100
- uv_mutex_t mutex;
101
- uv_barrier_t barrier;
102
- dpiSubscrMessage *message;
103
- Nan::Persistent<Function> jsCallback;
104
- dpiSubscrNamespace subscrNamespace;
105
- std::string name;
106
-
107
- static Nan::Persistent<FunctionTemplate> subscriptionTemplate_s;
108
- };
109
-
110
- #endif
111
-
package/src/njsUtils.cpp DELETED
@@ -1,158 +0,0 @@
1
- /* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. */
2
-
3
- /******************************************************************************
4
- *
5
- * You may not use the identified files except in compliance with the Apache
6
- * License, Version 2.0 (the "License.")
7
- *
8
- * You may obtain a copy of the License at
9
- * http://www.apache.org/licenses/LICENSE-2.0.
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- *
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- *
18
- * This file uses NAN:
19
- *
20
- * Copyright (c) 2015 NAN contributors
21
- *
22
- * NAN contributors listed at https://github.com/rvagg/nan#contributors
23
- *
24
- * Permission is hereby granted, free of charge, to any person obtaining
25
- * a copy of this software and associated documentation files (the
26
- * "Software"), to deal in the Software without restriction, including
27
- * without limitation the rights to use, copy, modify, merge, publish,
28
- * distribute, sublicense, and/or sell copies of the Software, and to
29
- * permit persons to whom the Software is furnished to do so, subject to
30
- * the following conditions:
31
- *
32
- * The above copyright notice and this permission notice shall be
33
- * included in all copies or substantial portions of the Software.
34
- *
35
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
36
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
37
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
38
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
39
- * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
40
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
41
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42
- *
43
- * NAME
44
- * njsUtils.cpp
45
- *
46
- * DESCRIPTION
47
- * Implementation of Utility class.
48
- *
49
- *****************************************************************************/
50
-
51
- #include "njsCommon.h"
52
- #include "njsSodaDocument.h"
53
- #include "njsUtils.h"
54
-
55
- using namespace node;
56
- using namespace std;
57
- using namespace v8;
58
-
59
- //-----------------------------------------------------------------------------
60
- // njsUtils::GetIntFromJSON()
61
- // Gets a signed integer value from the JSON object for the given key, if
62
- // possible. If null or undefined, leave value alone and do not set error;
63
- // otherwise, set error. Index is the argument index in the caller.
64
- //-----------------------------------------------------------------------------
65
- bool njsUtils::GetIntFromJSON(Local<Object> obj, const char *key, int index,
66
- int32_t *value, string &error)
67
- {
68
- Nan::HandleScope scope;
69
- Local<Value> jsValue;
70
-
71
- MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
72
- if (!mval.ToLocal(&jsValue))
73
- return false;
74
-
75
- if (jsValue->IsInt32()) {
76
- *value = Nan::To<int32_t>(jsValue).FromJust();
77
- return true;
78
- } else if (jsValue->IsUndefined()) {
79
- return true;
80
- } else if (jsValue->IsNumber() || jsValue->IsNull()) {
81
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
82
- index + 1);
83
- return false;
84
- } else {
85
- error = njsMessages::Get(errInvalidPropertyTypeInParam, key,
86
- index + 1);
87
- return false;
88
- }
89
- }
90
-
91
-
92
- //-----------------------------------------------------------------------------
93
- // njsUtils::GetStringFromJSON()
94
- // Gets a string value from the JSON object for the given key, if possible.
95
- // If null or undefined, leave value alone and do not set error; otherwise, set
96
- // error. Index is the argument index in the caller.
97
- //-----------------------------------------------------------------------------
98
- bool njsUtils::GetStringFromJSON(Local<Object> obj, const char *key, int index,
99
- string &value, string &error)
100
- {
101
- Nan::HandleScope scope;
102
- Local<Value> jsValue;
103
-
104
- MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
105
- if (!mval.ToLocal (&jsValue))
106
- return false;
107
-
108
- if (jsValue->IsString()) {
109
- Nan::Utf8String utf8str(jsValue->ToString());
110
- value = std::string(*utf8str, static_cast<size_t>(utf8str.length()));
111
- return true;
112
- } else if (jsValue->IsUndefined()) {
113
- return true;
114
- } else if ( jsValue->IsNull()) {
115
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
116
- index + 1 );
117
- return false;
118
- } else {
119
- error = njsMessages::Get(errInvalidPropertyTypeInParam, key,
120
- index + 1);
121
- return false;
122
- }
123
- }
124
-
125
- //-----------------------------------------------------------------------------
126
- // njsUtils::GetStringArrayFromJSON()
127
- // Utility function to obtain a string array (std::vector<std::string> from
128
- // JSON for a given key. Index is used to repoprt error if any.
129
- //----------------------------------------------------------------------------
130
- bool njsUtils::GetStringArrayFromJSON(Local<Object> obj, const char *key,
131
- int index, std::vector<string> &vec, string &error)
132
- {
133
- Nan::HandleScope scope;
134
- Local<Value> jsValue;
135
-
136
- MaybeLocal<Value> mval = Nan::Get(obj, Nan::New(key).ToLocalChecked());
137
- if (!mval.ToLocal(&jsValue))
138
- return false;
139
-
140
- if (jsValue->IsArray()) {
141
- // The value is expected to be an array (of strings). This is
142
- // validated in js layer
143
- Local<Array> array = jsValue.As<Array>();
144
- for (uint32_t i = 0; i < array->Length(); i++) {
145
- Nan::Utf8String utf8str(Nan::Get(array,
146
- i).ToLocalChecked()->ToString());
147
- vec.push_back(std::string(*utf8str,
148
- static_cast<size_t>(utf8str.length())));
149
- }
150
- } else if (jsValue->IsUndefined()) {
151
- return true;
152
- } else if (jsValue->IsNull()) {
153
- error = njsMessages::Get(errInvalidPropertyValueInParam, key,
154
- index + 1);
155
- return false;
156
- }
157
- return true;
158
- }