@@ -60,12 +60,6 @@ uni::CallbackType OutParam::New(const uni::FunctionCallbackInfo& args) {
6060 OBJ_GET_STRING (opts, " in" , outParam->_inOut .stringVal );
6161 break ;
6262 }
63- case OutParam::OCCIVECTOR: {
64- uni::CallbackType ret = OutParam::GetVectorParam (opts, outParam);
65- if (!ret->IsNull ())
66- return ret;
67- break ;
68- }
6963 default :
7064 UNI_THROW (Exception::Error (String::New (" Unhandled OutPram type!" )));
7165 }
@@ -82,19 +76,6 @@ OutParam::OutParam() {
8276}
8377
8478OutParam::~OutParam () {
85- if (_inOut.collectionValues != NULL ) {
86- // This can be either a char* or int*
87- if (_inOut.elemetnsType == oracle::occi::OCCIINT)
88- delete (int *)(_inOut.collectionValues );
89- else if (_inOut.elemetnsType == oracle::occi::OCCI_SQLT_STR)
90- delete (char *)(_inOut.collectionValues );
91- }
92-
93- if (_inOut.elementLength != 0 )
94- delete _inOut.elementLength ;
95-
96- if (_inOut.stringVal != NULL )
97- delete _inOut.stringVal ;
9879}
9980
10081int OutParam::type () {
@@ -104,99 +85,3 @@ int OutParam::type() {
10485int OutParam::size () {
10586 return _size;
10687}
107-
108- uni::CallbackType OutParam::GetVectorParam (Local<Object> opts, OutParam* outParam) {
109- // Get the array
110- Local<Value> val = opts->Get (String::New (" in" ));
111- if (!val->IsArray ())
112- UNI_THROW (Exception::Error (String::New (" OutParam::OCCIVECTOR must include array object as 'in' property" )));
113-
114- Local<Array> arr = Local<Array>::Cast (val);
115-
116- if (arr->Length () < 1 ) {
117- outParam->_inOut .collectionLength = arr->Length ();
118- outParam->_inOut .collectionValues = new int [0 ];
119- outParam->_inOut .elementsSize = 0 ;
120- outParam->_inOut .elementLength = new ub2[0 ];
121- return v8::Null ();
122- }
123-
124-
125- // Get the vector's elements type if specified, default is int.
126- int type;
127- OBJ_GET_NUMBER (opts, " type" , type, OutParam::OCCIINT);
128-
129- switch (type) {
130- // Here we create the array buffer that will be used later as the value for the param on the sp statement (Connection::SetValuesOnStatement)
131- case OutParam::OCCISTRING: {
132- outParam->_inOut .elemetnsType = oracle::occi::OCCI_SQLT_STR;
133-
134- // Find the longest string, this is necessary in order to create a buffer later.
135- // If "size" was provided by the user we use it as the size of the "longest string".
136- int longestString = 0 ;
137- if (opts->Has (String::New (" size" ))) {
138- longestString = outParam->_size ;
139- } else {
140- // Loop thru all strings and save the length of the longest one.
141- for (unsigned int i = 0 ; i < arr->Length (); i++) {
142- Local<Value> val = arr->Get (i);
143- if (val->ToString ()->Utf8Length () > longestString)
144- longestString = val->ToString ()->Utf8Length ();
145- }
146- }
147-
148- // Add 1 for '\0'
149- ++longestString;
150-
151- // Create a long char* that will hold the entire array, it is important to create a FIXED SIZE array,
152- // meaning all strings have the same allocated length.
153- char * strArr = new char [arr->Length () * longestString];
154- outParam->_inOut .elementLength = new ub2[arr->Length ()];
155-
156- // loop thru the arr and copy the strings into the strArr
157- int bytesWritten = 0 ;
158- for (unsigned int i = 0 ; i < arr->Length (); i++) {
159- Local<Value> val = arr->Get (i);
160- if (!val->IsString ())
161- UNI_THROW (Exception::Error (String::New (" OutParam::OCCIVECTOR of type OCCISTRING must include string types only" )));
162-
163- String::Utf8Value utfStr (val);
164-
165- // Copy this string onto the strArr (we put \0 in the beginning as this is what strcat expects).
166- strArr[bytesWritten] = ' \0 ' ;
167- strncat (strArr + bytesWritten, *utfStr, longestString);
168- bytesWritten += longestString;
169-
170- // Set the length of this element, add +1 for the '\0'
171- outParam->_inOut .elementLength [i] = utfStr.length () + 1 ;
172- }
173-
174- outParam->_inOut .collectionValues = strArr;
175- outParam->_inOut .collectionLength = arr->Length ();
176- outParam->_inOut .elementsSize = longestString;
177- break ;
178- }
179- case OutParam::OCCIINT: {
180- // Allocate memory and copy the ints.
181- int * intArr = new int [arr->Length ()];
182- for (unsigned int i = 0 ; i < arr->Length (); i++) {
183- Local<Value> val = arr->Get (i);
184- if (!val->IsInt32 ()) {
185- UNI_THROW (Exception::Error (String::New (" OutParam::OCCIVECTOR of type OCCIINT must include integer types only" )));
186- }
187-
188- intArr[i] = val->ToInt32 ()->Value ();
189- }
190-
191- outParam->_inOut .collectionValues = intArr;
192- outParam->_inOut .collectionLength = arr->Length ();
193- outParam->_inOut .elementsSize = sizeof (int32_t );
194- outParam->_inOut .elemetnsType = oracle::occi::OCCIINT;
195- break ;
196- }
197- default :
198- UNI_THROW (Exception::Error (String::New (" OutParam::OCCIVECTOR unsupported `type`, only supports OCCIINT and OCCISTRING" )));
199- }
200-
201- return v8::Null ();
202- }
0 commit comments