cmpi-bindings 0.9.5 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/src/cmpi_provider.c +1 -107
- data/ext/src/target_ruby.c +185 -0
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 107a02c0b033ad9845df5c4b8a1d4053d270f87c
|
4
|
+
data.tar.gz: c88d671fd2a43e905af5891e3b62f42b6e161840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45538fbf49c3ca8b9c36a28f89d2bdc07415223340fa0e942a81e14a9314bd9bf94872f0baee792c71a2f899fa6a926cefcab9abc4a8e7c03bb70ed6d7ab798a
|
7
|
+
data.tar.gz: 624d9b9c47ea84ce82f90c09b070ccecaa70ffe755f30e398649700b479022f0cab146417c017f278f8fe3acc9808af939ae71c32466597217863aa8f1e2846c
|
data/ext/src/cmpi_provider.c
CHANGED
@@ -874,27 +874,6 @@ references(
|
|
874
874
|
}
|
875
875
|
|
876
876
|
|
877
|
-
#if defined(SWIGRUBY)
|
878
|
-
/*
|
879
|
-
* Check type of VALUE
|
880
|
-
*
|
881
|
-
* return 0 if ok
|
882
|
-
* return -1 if bad type, set status accordingly
|
883
|
-
*
|
884
|
-
*/
|
885
|
-
|
886
|
-
static int
|
887
|
-
check_ruby_type( VALUE value, int type, const char *message, CMPIStatus *status, ProviderMIHandle* hdl )
|
888
|
-
{
|
889
|
-
if (TYPE(value) != type) {
|
890
|
-
status->rc = CMPI_RC_ERR_TYPE_MISMATCH;
|
891
|
-
status->msg = CMNewString(hdl->broker, message, NULL);
|
892
|
-
return -1;
|
893
|
-
}
|
894
|
-
return 0;
|
895
|
-
}
|
896
|
-
#endif
|
897
|
-
|
898
877
|
/*
|
899
878
|
* invokeMethod
|
900
879
|
*/
|
@@ -919,93 +898,8 @@ invokeMethod(
|
|
919
898
|
_ctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0);
|
920
899
|
_objName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0);
|
921
900
|
|
922
|
-
/* Ruby style method invocation */
|
923
901
|
#if defined(SWIGRUBY)
|
924
|
-
|
925
|
-
/* de-camelize method name, might need 2time length */
|
926
|
-
char *methodname = alloca(strlen(method) * 2 + 1);
|
927
|
-
decamelize(method, methodname);
|
928
|
-
|
929
|
-
/* access method arguments information via <decamelized>_args */
|
930
|
-
int argsnamesize = strlen(methodname) + 5 + 1;
|
931
|
-
char *argsname = alloca(argsnamesize); /* "<name>_args" */
|
932
|
-
snprintf(argsname, argsnamesize, "%s_args", methodname);
|
933
|
-
|
934
|
-
/* get the args array, gives names of input and output arguments */
|
935
|
-
VALUE args = rb_funcall(((ProviderMIHandle*)self->hdl)->implementation, rb_intern(argsname), 0);
|
936
|
-
if (check_ruby_type(args, T_ARRAY, "invoke: <method>_args must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0)
|
937
|
-
return status;
|
938
|
-
|
939
|
-
VALUE argsin = rb_ary_entry(args, 0); /* array of input arg names */
|
940
|
-
if (check_ruby_type(argsin, T_ARRAY, "invoke: Input arguments must be Array", &status, (ProviderMIHandle*)self->hdl ) < 0)
|
941
|
-
return status;
|
942
|
-
|
943
|
-
int number_of_arguments = RARRAY_LEN(argsin) / 2;
|
944
|
-
_SBLIM_TRACE(1,("%s -> %d input args", argsname, number_of_arguments));
|
945
|
-
/* 3 args will be added by TargetCall, 2 args are added here, others are input args to function */
|
946
|
-
VALUE *input = alloca((3 + 2 + number_of_arguments) * sizeof(VALUE));
|
947
|
-
input[3] = _ctx;
|
948
|
-
input[4] = _objName;
|
949
|
-
/* loop over input arg names and types and get CMPIData via CMGetArg() */
|
950
|
-
int i;
|
951
|
-
for (i = 0; i < number_of_arguments; ++i) {
|
952
|
-
const char *argname;
|
953
|
-
CMPIData data;
|
954
|
-
argname = target_charptr(rb_ary_entry(argsin, i*2));
|
955
|
-
data = CMGetArg(in, argname, &status);
|
956
|
-
if (status.rc != CMPI_RC_OK) {
|
957
|
-
if ((data.state & CMPI_nullValue)
|
958
|
-
||(data.state & CMPI_notFound)) {
|
959
|
-
input[5+i] = Target_Null;
|
960
|
-
continue;
|
961
|
-
}
|
962
|
-
_SBLIM_TRACE(1,("Failed (rc %d) to get input arg %d:%s for %s", status.rc, i>>1, argname, method));
|
963
|
-
return status;
|
964
|
-
}
|
965
|
-
input[5+i] = data_value(&data);
|
966
|
-
}
|
967
|
-
|
968
|
-
/* actual provider call, passes output args and return value via 'result' */
|
969
|
-
VALUE result = TargetCall((ProviderMIHandle*)self->hdl, &status, methodname, -(2+number_of_arguments), input);
|
970
|
-
|
971
|
-
/* argsout is array of [<return_type>, <output_arg_name>, <output_arg_type>, ... */
|
972
|
-
VALUE argsout = rb_ary_entry(args, 1);
|
973
|
-
CMPIValue value;
|
974
|
-
CMPIType expected_type;
|
975
|
-
CMPIType actual_type;
|
976
|
-
if (check_ruby_type(argsout, T_ARRAY, "invoke: Output arguments must be Array", &status, (ProviderMIHandle*)self->hdl) < 0)
|
977
|
-
return status;
|
978
|
-
number_of_arguments = (RARRAY_LEN(argsout) - 1);
|
979
|
-
|
980
|
-
if (number_of_arguments > 0) {
|
981
|
-
/* if output args are defined, result must be an array
|
982
|
-
* result[0] is the return value
|
983
|
-
* result[1..n] are the output args in argsout order
|
984
|
-
*/
|
985
|
-
if (check_ruby_type(result, T_ARRAY, "invoke: function with output arguments must return Array", &status, (ProviderMIHandle*)self->hdl) < 0)
|
986
|
-
return status;
|
987
|
-
|
988
|
-
/* loop over output arg names and types and set CMPIData via CMSetArg() */
|
989
|
-
for (i = 0; i < number_of_arguments; i += 2) {
|
990
|
-
const char *argname;
|
991
|
-
argname = target_charptr(rb_ary_entry(argsout, i+1));
|
992
|
-
expected_type = FIX2ULONG(rb_ary_entry(argsout, i+2));
|
993
|
-
actual_type = target_to_value(rb_ary_entry(result, (i >> 1) + 1), &value, expected_type);
|
994
|
-
status = CMAddArg(out, argname, &value, actual_type);
|
995
|
-
if (status.rc != CMPI_RC_OK) {
|
996
|
-
_SBLIM_TRACE(1,("Failed (rc %d) to set output arg %d:%s for %s; expected type %x, actual type %x", status.rc, i>>1, argname, method, expected_type, actual_type));
|
997
|
-
return status;
|
998
|
-
}
|
999
|
-
}
|
1000
|
-
/* result[0] is the return value */
|
1001
|
-
result = rb_ary_entry(result, 0);
|
1002
|
-
|
1003
|
-
}
|
1004
|
-
expected_type = FIX2ULONG(rb_ary_entry(argsout, 0));
|
1005
|
-
actual_type = target_to_value(result, &value, expected_type);
|
1006
|
-
CMReturnData(rslt, &value, actual_type);
|
1007
|
-
CMReturnDone(rslt);
|
1008
|
-
|
902
|
+
TargetInvoke((ProviderMIHandle*)self->hdl, _ctx, rslt, _objName, method, in, out, &status);
|
1009
903
|
#else
|
1010
904
|
Target_Type _rslt;
|
1011
905
|
Target_Type _in;
|
data/ext/src/target_ruby.c
CHANGED
@@ -515,3 +515,188 @@ TargetCleanup(ProviderMIHandle * hdl)
|
|
515
515
|
return;
|
516
516
|
}
|
517
517
|
|
518
|
+
|
519
|
+
/*
|
520
|
+
* Check type of VALUE
|
521
|
+
* - used by invokeMethod -
|
522
|
+
*
|
523
|
+
* return 0 if ok
|
524
|
+
* return -1 if bad type, set status accordingly
|
525
|
+
*
|
526
|
+
*/
|
527
|
+
|
528
|
+
static int
|
529
|
+
check_ruby_type( VALUE value, int type, const char *message, CMPIStatus *status, ProviderMIHandle* hdl )
|
530
|
+
{
|
531
|
+
if (TYPE(value) != type) {
|
532
|
+
status->rc = CMPI_RC_ERR_TYPE_MISMATCH;
|
533
|
+
status->msg = CMNewString(hdl->broker, message, NULL);
|
534
|
+
return -1;
|
535
|
+
}
|
536
|
+
return 0;
|
537
|
+
}
|
538
|
+
|
539
|
+
|
540
|
+
/*
|
541
|
+
* protected_target_to_value
|
542
|
+
* call target_to_value via rb_protect in order to catch exceptions
|
543
|
+
*
|
544
|
+
*/
|
545
|
+
|
546
|
+
static VALUE
|
547
|
+
call_ttv(VALUE args)
|
548
|
+
{
|
549
|
+
VALUE *values = (VALUE *)args;
|
550
|
+
return target_to_value((Target_Type)values[0], (CMPIValue *)values[1], (CMPIType)values[2]);
|
551
|
+
}
|
552
|
+
|
553
|
+
static VALUE
|
554
|
+
protected_target_to_value(ProviderMIHandle *hdl, Target_Type data, CMPIValue *value, CMPIType type, CMPIStatus *status)
|
555
|
+
{
|
556
|
+
int error = 0;
|
557
|
+
VALUE args[3];
|
558
|
+
VALUE result;
|
559
|
+
args[0] = (VALUE)data;
|
560
|
+
args[1] = (VALUE)value;
|
561
|
+
args[2] = (VALUE)type;
|
562
|
+
result = rb_protect(call_ttv, (VALUE)args, &error);
|
563
|
+
|
564
|
+
if (error) {
|
565
|
+
CMPIString *trace = get_exc_trace(hdl->broker);
|
566
|
+
char *trace_s;
|
567
|
+
char* str;
|
568
|
+
if (trace) {
|
569
|
+
trace_s = CMGetCharPtr(trace);
|
570
|
+
}
|
571
|
+
else {
|
572
|
+
trace_s = "Unknown reason";
|
573
|
+
}
|
574
|
+
str = fmtstr("Ruby: %s", trace_s);
|
575
|
+
if (trace)
|
576
|
+
trace->ft->release(trace);
|
577
|
+
_SBLIM_TRACE(1,("%s", str));
|
578
|
+
status->rc = CMPI_RC_ERR_FAILED;
|
579
|
+
status->msg = hdl->broker->eft->newString(hdl->broker, str, NULL);
|
580
|
+
free(str);
|
581
|
+
}
|
582
|
+
else {
|
583
|
+
status->rc = CMPI_RC_OK;
|
584
|
+
}
|
585
|
+
return result;
|
586
|
+
}
|
587
|
+
|
588
|
+
/*
|
589
|
+
* TargetInvoke
|
590
|
+
* Ruby style method invocation
|
591
|
+
*/
|
592
|
+
static void
|
593
|
+
TargetInvoke(
|
594
|
+
ProviderMIHandle* hdl,
|
595
|
+
Target_Type _ctx,
|
596
|
+
const CMPIResult* rslt,
|
597
|
+
Target_Type _objName,
|
598
|
+
const char* method,
|
599
|
+
const CMPIArgs* in,
|
600
|
+
CMPIArgs* out,
|
601
|
+
CMPIStatus *status)
|
602
|
+
{
|
603
|
+
/* de-camelize method name, might need 2time length */
|
604
|
+
char *methodname = alloca(strlen(method) * 2 + 1);
|
605
|
+
decamelize(method, methodname);
|
606
|
+
|
607
|
+
/* access method arguments information via <decamelized>_args */
|
608
|
+
int argsnamesize = strlen(methodname) + 5 + 1;
|
609
|
+
char *argsname = alloca(argsnamesize); /* "<name>_args" */
|
610
|
+
snprintf(argsname, argsnamesize, "%s_args", methodname);
|
611
|
+
|
612
|
+
/* get the args array, gives names of input and output arguments */
|
613
|
+
VALUE args = rb_funcall(hdl->implementation, rb_intern(argsname), 0);
|
614
|
+
if (check_ruby_type(args, T_ARRAY, "invoke: <method>_args must be Array", status, hdl ) < 0) {
|
615
|
+
return;
|
616
|
+
}
|
617
|
+
|
618
|
+
VALUE argsin = rb_ary_entry(args, 0); /* array of input arg names */
|
619
|
+
if (check_ruby_type(argsin, T_ARRAY, "invoke: Input arguments of <method>_args must be Array", status, hdl ) < 0) {
|
620
|
+
return;
|
621
|
+
}
|
622
|
+
|
623
|
+
int number_of_arguments = RARRAY_LEN(argsin) / 2;
|
624
|
+
_SBLIM_TRACE(1,("%s -> %d input args", argsname, number_of_arguments));
|
625
|
+
/* 3 args will be added by TargetCall, 2 args are added here, others are input args to function */
|
626
|
+
VALUE *input = alloca((3 + 2 + number_of_arguments) * sizeof(VALUE));
|
627
|
+
input[3] = _ctx;
|
628
|
+
input[4] = _objName;
|
629
|
+
/* loop over input arg names and types and get CMPIData via CMGetArg() */
|
630
|
+
int i;
|
631
|
+
for (i = 0; i < number_of_arguments; ++i) {
|
632
|
+
const char *argname;
|
633
|
+
CMPIData data;
|
634
|
+
argname = target_charptr(rb_ary_entry(argsin, i*2));
|
635
|
+
data = CMGetArg(in, argname, status);
|
636
|
+
if (status->rc != CMPI_RC_OK) {
|
637
|
+
if ((data.state & CMPI_nullValue)
|
638
|
+
||(data.state & CMPI_notFound)) {
|
639
|
+
input[5+i] = Target_Null;
|
640
|
+
continue;
|
641
|
+
}
|
642
|
+
_SBLIM_TRACE(1,("Failed (rc %d) to get input arg %d:%s for %s", status->rc, i>>1, argname, method));
|
643
|
+
return;
|
644
|
+
}
|
645
|
+
input[5+i] = data_value(&data);
|
646
|
+
}
|
647
|
+
|
648
|
+
/* actual provider call, passes output args and return value via 'result' */
|
649
|
+
VALUE result = TargetCall(hdl, status, methodname, -(2+number_of_arguments), input);
|
650
|
+
|
651
|
+
/* check CMPIStatus */
|
652
|
+
if (status->rc != CMPI_RC_OK) {
|
653
|
+
return;
|
654
|
+
}
|
655
|
+
|
656
|
+
/* argsout (from <method>_args) is array of [<return_type>, <output_arg_name>, <output_arg_type>, ... */
|
657
|
+
VALUE argsout = rb_ary_entry(args, 1);
|
658
|
+
CMPIValue value;
|
659
|
+
CMPIType expected_type;
|
660
|
+
CMPIType actual_type;
|
661
|
+
if (check_ruby_type(argsout, T_ARRAY, "invoke: Output arguments of <method>_args must be Array", status, hdl) < 0) {
|
662
|
+
return;
|
663
|
+
}
|
664
|
+
number_of_arguments = (RARRAY_LEN(argsout) - 1);
|
665
|
+
|
666
|
+
if (number_of_arguments > 0) {
|
667
|
+
/* if output args are defined, result must be an array
|
668
|
+
* result[0] is the return value
|
669
|
+
* result[1..n] are the output args in argsout order
|
670
|
+
*/
|
671
|
+
if (check_ruby_type(result, T_ARRAY, "invoke: function with output arguments must return Array", status, hdl) < 0) {
|
672
|
+
return;
|
673
|
+
}
|
674
|
+
/* loop over output arg names and types and set CMPIData via CMSetArg() */
|
675
|
+
for (i = 0; i < number_of_arguments; i += 2) {
|
676
|
+
const char *argname;
|
677
|
+
argname = target_charptr(rb_ary_entry(argsout, i+1));
|
678
|
+
expected_type = FIX2ULONG(rb_ary_entry(argsout, i+2));
|
679
|
+
actual_type = protected_target_to_value(hdl, rb_ary_entry(result, (i >> 1) + 1), &value, expected_type, status);
|
680
|
+
if (status->rc != CMPI_RC_OK) {
|
681
|
+
_SBLIM_TRACE(0,("Failed (rc %d) type conversion for output arg %d:%s in call to %s; expected type %x, actual type %x", status->rc, i>>1, argname, method, expected_type, actual_type));
|
682
|
+
return;
|
683
|
+
}
|
684
|
+
*status = CMAddArg(out, argname, &value, actual_type);
|
685
|
+
if (status->rc != CMPI_RC_OK) {
|
686
|
+
_SBLIM_TRACE(1,("Failed (rc %d) to set output arg %d:%s for %s; expected type %x, actual type %x", status->rc, i>>1, argname, method, expected_type, actual_type));
|
687
|
+
return;
|
688
|
+
}
|
689
|
+
}
|
690
|
+
/* result[0] is the return value */
|
691
|
+
result = rb_ary_entry(result, 0);
|
692
|
+
|
693
|
+
}
|
694
|
+
expected_type = FIX2ULONG(rb_ary_entry(argsout, 0));
|
695
|
+
actual_type = protected_target_to_value(hdl, result, &value, expected_type, status);
|
696
|
+
if (status->rc != CMPI_RC_OK) {
|
697
|
+
_SBLIM_TRACE(0,("Failed (rc %d) type conversion for return value of %s; expected type %x, actual type %x", status->rc, method, expected_type, actual_type));
|
698
|
+
return;
|
699
|
+
}
|
700
|
+
CMReturnData(rslt, &value, actual_type);
|
701
|
+
CMReturnDone(rslt);
|
702
|
+
}
|
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cmpi-bindings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaus Kämpf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mocha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0.9'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.9'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: yard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.5'
|
55
55
|
description: The cmpi-bindings gem provides a Ruby API to write CIM providers
|
@@ -60,13 +60,13 @@ extensions:
|
|
60
60
|
- ext/cmpi-bindings/extconf.rb
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- lib/cmpi.rb
|
64
|
-
- lib/cmpi/provider.rb
|
65
|
-
- ext/cmpi-bindings/string_array.h
|
66
63
|
- ext/cmpi-bindings/cmpi_wrap.c
|
64
|
+
- ext/cmpi-bindings/extconf.rb
|
65
|
+
- ext/cmpi-bindings/string_array.h
|
67
66
|
- ext/src/cmpi_provider.c
|
68
67
|
- ext/src/target_ruby.c
|
69
|
-
-
|
68
|
+
- lib/cmpi.rb
|
69
|
+
- lib/cmpi/provider.rb
|
70
70
|
homepage: http://www.github.com/kkaempf/cmpi-bindings
|
71
71
|
licenses: []
|
72
72
|
metadata: {}
|
@@ -77,17 +77,17 @@ require_paths:
|
|
77
77
|
- lib
|
78
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- -
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: 1.3.6
|
88
88
|
requirements: []
|
89
89
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.0
|
90
|
+
rubygems_version: 2.2.0
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
93
|
summary: Write CIM providers in Ruby
|