Changeset 2998
- Timestamp:
- 11/07/08 09:17:57 (2 months ago)
- Files:
-
- openwsman/trunk/src/plugins/swig/src/swig-plugin.c (modified) (9 diffs)
- openwsman/trunk/src/plugins/swig/src/target_python.c (modified) (9 diffs)
- openwsman/trunk/src/plugins/swig/src/target_ruby.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openwsman/trunk/src/plugins/swig/src/swig-plugin.c
r2993 r2998 200 200 TARGET_THREAD_BEGIN_BLOCK; 201 201 _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 202 rc = TargetCall( _TARGET_MODULE, "identify", 1, _context);202 rc = TargetCall(cntx->indoc, _TARGET_MODULE, "identify", 1, _context); 203 203 TARGET_THREAD_END_BLOCK; 204 204 return rc; … … 210 210 void *opaqueData ) 211 211 { 212 Target_Type _context; 212 Target_Type _context, _enumInfo; 213 Target_Type _status; 213 214 int rc; 214 215 TARGET_THREAD_BEGIN_BLOCK; 215 216 _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 216 rc = TargetCall(_TARGET_MODULE, "enumerate", 1, _context ); 217 _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 218 _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 219 rc = TargetCall(cntx->indoc, _TARGET_MODULE, "enumerate", 3, _context, _enumInfo, _status ); 217 220 TARGET_THREAD_END_BLOCK; 218 221 return rc; … … 226 229 { 227 230 Target_Type _context; 231 Target_Type _enumInfo; 232 Target_Type _status; 228 233 int rc; 229 234 TARGET_THREAD_BEGIN_BLOCK; 230 235 _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 231 rc = TargetCall(_TARGET_MODULE, "release", 0 ); 236 _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 237 _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 238 rc = TargetCall(cntx->indoc, _TARGET_MODULE, "release", 3, _context, _enumInfo, _status ); 232 239 TARGET_THREAD_END_BLOCK; 233 240 return rc; … … 241 248 { 242 249 Target_Type _context; 250 Target_Type _enumInfo; 251 Target_Type _status; 243 252 int rc; 244 253 TARGET_THREAD_BEGIN_BLOCK; 245 254 _context = SWIG_NewPointerObj((void*) cntx, SWIGTYPE_p__WS_CONTEXT, 0); 246 rc = TargetCall(_TARGET_MODULE, "pull", 1, _context ); 255 _enumInfo = SWIG_NewPointerObj((void*) enumInfo, SWIGTYPE_p___WsEnumerateInfo, 0); 256 _status = SWIG_NewPointerObj((void*) status, SWIGTYPE_p__WsmanStatus, 0); 257 rc = TargetCall(cntx->indoc, _TARGET_MODULE, "pull", 3, _context, _enumInfo, _status ); 247 258 TARGET_THREAD_END_BLOCK; 248 259 return rc; … … 253 264 Swig_Get_EP( SoapOpH op, void* appData, void *opaqueData ) 254 265 { 255 Target_Type _context; 256 int rc; 257 TARGET_THREAD_BEGIN_BLOCK; 258 rc = TargetCall(_TARGET_MODULE, "get", 0 ); 266 Target_Type _op; 267 int rc; 268 WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 269 TARGET_THREAD_BEGIN_BLOCK; 270 _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 271 272 rc = TargetCall(in_doc, _TARGET_MODULE, "get", 1, _op ); 259 273 TARGET_THREAD_END_BLOCK; 260 274 return rc; … … 265 279 Swig_Custom_EP( SoapOpH op, void* appData, void *opaqueData ) 266 280 { 267 Target_Type _context; 268 int rc; 269 TARGET_THREAD_BEGIN_BLOCK; 270 rc = TargetCall(_TARGET_MODULE, "custom", 0 ); 281 Target_Type _op; 282 int rc; 283 WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 284 TARGET_THREAD_BEGIN_BLOCK; 285 _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 286 rc = TargetCall(in_doc, _TARGET_MODULE, "custom", 1, _op ); 271 287 TARGET_THREAD_END_BLOCK; 272 288 return rc; … … 277 293 Swig_Put_EP( SoapOpH op, void* appData, void *opaqueData ) 278 294 { 279 Target_Type _context; 280 int rc; 281 TARGET_THREAD_BEGIN_BLOCK; 282 rc = TargetCall(_TARGET_MODULE, "put", 0 ); 295 Target_Type _op; 296 int rc; 297 WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 298 TARGET_THREAD_BEGIN_BLOCK; 299 _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 300 rc = TargetCall(in_doc, _TARGET_MODULE, "put", 1, _op ); 283 301 TARGET_THREAD_END_BLOCK; 284 302 return rc; … … 289 307 Swig_Create_EP( SoapOpH op, void* appData, void *opaqueData ) 290 308 { 291 Target_Type _context; 292 int rc; 293 TARGET_THREAD_BEGIN_BLOCK; 294 rc = TargetCall(_TARGET_MODULE, "create", 0 ); 309 Target_Type _op; 310 int rc; 311 WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 312 TARGET_THREAD_BEGIN_BLOCK; 313 _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 314 rc = TargetCall(in_doc, _TARGET_MODULE, "create", 1, _op ); 295 315 TARGET_THREAD_END_BLOCK; 296 316 return rc; … … 302 322 Swig_Delete_EP( SoapOpH op, void* appData, void *opaqueData ) 303 323 { 304 Target_Type _context; 305 int rc; 306 TARGET_THREAD_BEGIN_BLOCK; 307 rc = TargetCall(_TARGET_MODULE, "delete", 0 ); 324 Target_Type _op; 325 int rc; 326 WsXmlDocH in_doc = soap_get_op_doc( op, 1 ); 327 TARGET_THREAD_BEGIN_BLOCK; 328 _op = SWIG_NewPointerObj((void*) op, SWIGTYPE_p___SoapOp, 0); 329 rc = TargetCall(in_doc, _TARGET_MODULE, "delete", 1, _op ); 308 330 TARGET_THREAD_END_BLOCK; 309 331 return rc; openwsman/trunk/src/plugins/swig/src/target_python.c
r2993 r2998 187 187 188 188 static int 189 TargetCall( PyObject* instance,189 TargetCall(WsXmlDocH doc, PyObject* instance, 190 190 const char* opname, int nargs, ...) 191 191 { 192 int rc = 1;193 192 va_list vargs; 194 193 PyObject *pyargs = NULL; … … 210 209 211 210 free(str); 212 rc = 1;213 211 goto cleanup; 214 212 } … … 221 219 status.fault_detail_code = 0; 222 220 free(str); 223 rc = 1;224 221 goto cleanup; 225 222 } … … 241 238 if (PyErr_Occurred()) 242 239 { 243 status.fault_code = WSA_ENDPOINT_UNAVAILABLE;240 status.fault_code = WSMAN_INTERNAL_ERROR; 244 241 status.fault_detail_code = 0; 245 242 PyErr_Clear(); 246 rc = 1;247 243 goto cleanup; 248 244 } … … 252 248 { 253 249 TARGET_THREAD_BEGIN_ALLOW; 254 char* str = fmtstr("Python function \"%s\" didn't return a two-tuple", 255 opname); 256 debug("%s", str); 257 status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 258 status.fault_detail_code = 0; 259 free(str); 260 rc = 1; 250 status.fault_msg = fmtstr("Python function \"%s\" didn't return a two-tuple", opname); 251 status.fault_code = WSMAN_INTERNAL_ERROR; 252 status.fault_detail_code = 0; 261 253 TARGET_THREAD_END_ALLOW; 262 254 goto cleanup; … … 272 264 { 273 265 TARGET_THREAD_BEGIN_ALLOW; 274 char* str = fmtstr("Python function \"%s\" didn't return a {<int>, <int>) two-tuple", opname); 275 debug("%s", str); 276 status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 277 status.fault_detail_code = 0; 278 free(str); 279 rc = 1; 266 status.fault_msg = fmtstr("Python function \"%s\" didn't return a {<int>, <int>) two-tuple", opname); 267 status.fault_code = WSMAN_INTERNAL_ERROR; 268 status.fault_detail_code = 0; 280 269 TARGET_THREAD_END_ALLOW; 281 270 goto cleanup; … … 284 273 if (detail == Py_None) 285 274 { 286 status.fault_code = WS A_ENDPOINT_UNAVAILABLE;275 status.fault_code = WSMAN_INTERNAL_ERROR; 287 276 status.fault_detail_code = 0; 288 277 } … … 291 280 status.fault_detail_code = PyInt_AsLong(detail); 292 281 } 293 rc = code != 0;294 282 cleanup: 283 if (status.fault_code != WSMAN_RC_OK) 284 wsman_generate_fault( doc, status.fault_code, status.fault_detail_code, status.fault_msg ); 295 285 Py_DecRef(pyargs); 296 286 Py_DecRef(pyfunc); 297 287 Py_DecRef(result); 298 288 299 return rc;289 return status.fault_code != WSMAN_RC_OK; 300 290 } 301 291 … … 355 345 return -1; 356 346 } 347 *data = _TARGET_MODULE; 357 348 } 358 349 pthread_mutex_unlock(&_PLUGIN_INIT_MUTEX); openwsman/trunk/src/plugins/swig/src/target_ruby.c
r2993 r2998 202 202 /* 203 203 * TargetCall 204 * Call function 'opname' with nargs arguments within managed interface hdl->instance 204 * Call function 'opname' with nargs arguments within instance 205 * 206 * doc: in_doc from context, needed for fault generation 207 * instance: klass 208 * opname: name of method to call 209 * nargs: number of arguments 210 * ...: arguments as varargs 211 * 205 212 */ 206 213 207 214 static int 208 TargetCall( VALUE instance, const char* opname, int nargs, ...)215 TargetCall(WsXmlDocH doc, VALUE instance, const char* opname, int nargs, ...) 209 216 { 210 217 int i; … … 212 219 va_list vargs; 213 220 WsmanStatus status; 221 wsman_status_init(&status); 214 222 215 223 debug("TargetCall(Ruby): %s", opname); … … 250 258 { 251 259 char *trace = get_exc_trace(); 252 char *str = fmtstr("Ruby: calling '%s' failed: %s", opname, trace); 253 error("%s", str); 260 status.fault_msg = fmtstr("Ruby: calling '%s' failed: %s", opname, trace); 261 status.fault_code = WSMAN_INTERNAL_ERROR; 262 status.fault_detail_code = 0; 263 error("%s", status.fault_msg); 254 264 return 1; 255 265 } 256 wsman_status_init(&status);257 266 258 267 if (NIL_P(result)) /* not or wrongly implemented */ … … 265 274 if (result != Qtrue) 266 275 { 276 int len; 267 277 VALUE resulta = rb_check_array_type(result); 268 VALUE code, detail;278 269 279 if (NIL_P(resulta)) 270 280 { 271 message(fmtstr("Ruby: calling '%s' returned unknown result", opname));272 status.fault_code = WS A_ENDPOINT_UNAVAILABLE;281 status.fault_msg = fmtstr("Ruby: calling '%s' returned unknown result", opname); 282 status.fault_code = WSMAN_INTERNAL_ERROR; 273 283 status.fault_detail_code = 0; 274 284 return 1; 275 285 } 276 286 277 code = rb_ary_entry(resulta, 0); 278 detail = rb_ary_entry(resulta, 1); 279 if (!FIXNUM_P(code)) 287 len = RARRAY(resulta)->len; 288 if (len > 0) 280 289 { 281 message(fmtstr("Ruby: calling '%s' returned non-numeric code", opname)); 282 status.fault_code = WSA_ENDPOINT_UNAVAILABLE; 283 status.fault_detail_code = 0; 284 return 1; 290 VALUE code = rb_ary_entry(resulta, 0); 291 if (!FIXNUM_P(code)) 292 { 293 status.fault_msg = fmtstr("Ruby: calling '%s' returned non-numeric code", opname); 294 status.fault_code = WSMAN_INTERNAL_ERROR; 295 status.fault_detail_code = 0; 296 return 1; 297 } 298 status.fault_code = FIX2LONG(code); 285 299 } 286 status.fault_code = FIX2LONG(code); 287 status.fault_detail_code = FIX2LONG(detail); 288 return 1; 300 301 if (len > 1) 302 { 303 VALUE detail = rb_ary_entry(resulta, 1); 304 if (!FIXNUM_P(detail)) 305 { 306 status.fault_msg = fmtstr("Ruby: calling '%s' returned non-numeric detail", opname); 307 status.fault_code = WSMAN_INTERNAL_ERROR; 308 status.fault_detail_code = 0; 309 return 1; 310 } 311 status.fault_detail_code = FIX2LONG(detail); 312 } 313 if (len > 2) 314 { 315 VALUE str = rb_ary_entry(resulta, 2); 316 status.fault_msg = StringValuePtr(str); 317 } 318 wsman_generate_fault( doc, status.fault_code, status.fault_detail_code, status.fault_msg ); 289 319 } 290 320
