ext/sfcc/cim_instance.c in sfcc-0.1.2 vs ext/sfcc/cim_instance.c in sfcc-0.5.0
- old
+ new
@@ -1,32 +1,32 @@
#include "cim_instance.h"
#include "cim_object_path.h"
static void
-dealloc(CMPIInstance *instance)
+dealloc(CIMCInstance *inst)
{
- SFCC_DEC_REFCOUNT(instance);
+/* fprintf(stderr, "Sfcc_dealloc_cim_instance %p\n", inst); */
+ inst->ft->release(inst);
}
/**
* call-seq:
* property(name)
*
* Gets a named property value, where name is a Symbol or String
*/
static VALUE property(VALUE self, VALUE name)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
- CMPIData data;
- Data_Get_Struct(self, CMPIInstance, ptr);
- data = ptr->ft->getProperty(ptr, StringValuePtr(name), &status);
+ CIMCInstance *ptr;
+ CIMCStatus status;
+ CIMCData data;
+ Data_Get_Struct(self, CIMCInstance, ptr);
+ data = ptr->ft->getProperty(ptr, to_charptr(name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
-
- sfcc_rb_raise_if_error(status, "Can't retrieve property '%s'", StringValuePtr(name));
+ sfcc_rb_raise_if_error(status, "Can't retrieve property '%s'", to_charptr(name));
return Qnil;
}
/**
* call-seq:
@@ -38,28 +38,28 @@
* its value
*
*/
static VALUE each_property(VALUE self)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
+ CIMCInstance *ptr;
+ CIMCStatus status;
int k=0;
int num_props=0;
- CMPIString *property_name = NULL;
- CMPIData data;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCString *property_name = NULL;
+ CIMCData data;
+ Data_Get_Struct(self, CIMCInstance, ptr);
num_props = ptr->ft->getPropertyCount(ptr, &status);
if (!status.rc) {
for (; k < num_props; ++k) {
data = ptr->ft->getPropertyAt(ptr, k, &property_name, &status);
if (!status.rc) {
rb_yield_values(2, (property_name ? rb_str_intern(rb_str_new2(property_name->ft->getCharPtr(property_name, NULL))) : Qnil), sfcc_cimdata_to_value(data));
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property #%d", k);
- }
+ }
if (property_name) CMRelease(property_name);
}
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property count");
@@ -73,12 +73,12 @@
*
* Gets the number of properties contained in this Instance
*/
static VALUE property_count(VALUE self)
{
- CMPIInstance *ptr = NULL;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCInstance *ptr;
+ Data_Get_Struct(self, CIMCInstance, ptr);
return UINT2NUM(ptr->ft->getPropertyCount(ptr, NULL));
}
/**
* call-seq:
@@ -86,15 +86,15 @@
*
* Adds/replaces a names property
*/
static VALUE set_property(VALUE self, VALUE name, VALUE value)
{
- CMPIInstance *ptr = NULL;
- CMPIData data;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCInstance *ptr;
+ CIMCData data;
+ Data_Get_Struct(self, CIMCInstance, ptr);
data = sfcc_value_to_cimdata(value);
- ptr->ft->setProperty(ptr, StringValuePtr(name), &data.value, data.type);
+ ptr->ft->setProperty(ptr, to_charptr(name), &data.value, data.type);
return value;
}
/**
@@ -104,25 +104,22 @@
* Generates an ObjectPath out of the nameSpace, classname and
* key propeties of this Instance.
*/
static VALUE object_path(VALUE self)
{
- CMPIInstance *ptr = NULL;
- CMPIObjectPath *op;
- CMPIObjectPath *newop;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCInstance *ptr;
+ CIMCObjectPath *op;
+ Data_Get_Struct(self, CIMCInstance, ptr);
op = ptr->ft->getObjectPath(ptr, NULL);
- newop = op->ft->clone(op, NULL);
- op->ft->release(op);
- return Sfcc_wrap_cim_object_path(newop);
+ return Sfcc_wrap_cim_object_path(op);
}
/**
* call-seq:
* set_property_filter(property_list, keys)
*
- * Directs CMPI to ignore any setProperty operations for this
+ * Directs CIMC to ignore any setProperty operations for this
* instance for any properties not in this list.
*
* +property_list+ If not nil, the members of the array define one
* or more Property names to be accepted by set_property operations.
*
@@ -130,16 +127,16 @@
* must be specified.
*
*/
static VALUE set_property_filter(VALUE self, VALUE property_list, VALUE keys)
{
- CMPIStatus status;
- CMPIInstance *ptr = NULL;
+ CIMCStatus status;
+ CIMCInstance *ptr;
char **prop_a;
char **key_a;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ Data_Get_Struct(self, CIMCInstance, ptr);
prop_a = sfcc_value_array_to_string_array(property_list);
key_a = sfcc_value_array_to_string_array(keys);
status = ptr->ft->setPropertyFilter(ptr, prop_a, key_a);
@@ -156,20 +153,20 @@
*
* gets a named qualifier value
*/
static VALUE qualifier(VALUE self, VALUE name)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
- CMPIData data;
- memset(&status, 0, sizeof(CMPIStatus));
- Data_Get_Struct(self, CMPIInstance, ptr);
- data = ptr->ft->getQualifier(ptr, StringValuePtr(name), &status);
+ CIMCInstance *ptr;
+ CIMCStatus status;
+ CIMCData data;
+ memset(&status, 0, sizeof(CIMCStatus));
+ Data_Get_Struct(self, CIMCInstance, ptr);
+ data = ptr->ft->getQualifier(ptr, to_charptr(name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
- sfcc_rb_raise_if_error(status, "Can't retrieve qualifier '%s'", StringValuePtr(name));
+ sfcc_rb_raise_if_error(status, "Can't retrieve qualifier '%s'", to_charptr(name));
return Qnil;
}
/**
* call-seq:
@@ -181,28 +178,28 @@
* its value
*
*/
static VALUE each_qualifier(VALUE self)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
+ CIMCInstance *ptr;
+ CIMCStatus status;
int k=0;
int num_props=0;
- CMPIString *qualifier_name = NULL;
- CMPIData data;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCString *qualifier_name = NULL;
+ CIMCData data;
+ Data_Get_Struct(self, CIMCInstance, ptr);
num_props = ptr->ft->getQualifierCount(ptr, &status);
if (!status.rc) {
for (; k < num_props; ++k) {
data = ptr->ft->getQualifierAt(ptr, k, &qualifier_name, &status);
if (!status.rc) {
rb_yield_values(2, (qualifier_name ? rb_str_new2(qualifier_name->ft->getCharPtr(qualifier_name, NULL)) : Qnil), sfcc_cimdata_to_value(data));
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve qualifier #%d", k);
- }
+ }
if (qualifier_name) CMRelease(qualifier_name);
}
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve qualifier count");
@@ -216,12 +213,12 @@
*
* Gets the number of qualifiers in this instance
*/
static VALUE qualifier_count(VALUE self)
{
- CMPIInstance *ptr = NULL;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCInstance *ptr;
+ Data_Get_Struct(self, CIMCInstance, ptr);
return UINT2NUM(ptr->ft->getQualifierCount(ptr, NULL));
}
/**
* call-seq:
@@ -229,21 +226,21 @@
*
* gets a named property qualifier value
*/
static VALUE property_qualifier(VALUE self, VALUE property_name, VALUE qualifier_name)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
- CMPIData data;
- memset(&status, 0, sizeof(CMPIStatus));
- Data_Get_Struct(self, CMPIInstance, ptr);
- data = ptr->ft->getPropertyQualifier(ptr, StringValuePtr(property_name),
- StringValuePtr(qualifier_name), &status);
+ CIMCInstance *ptr;
+ CIMCStatus status;
+ CIMCData data;
+ memset(&status, 0, sizeof(CIMCStatus));
+ Data_Get_Struct(self, CIMCInstance, ptr);
+ data = ptr->ft->getPropertyQualifier(ptr, to_charptr(property_name),
+ to_charptr(qualifier_name), &status);
if ( !status.rc )
return sfcc_cimdata_to_value(data);
- sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier '%s'", StringValuePtr(qualifier_name));
+ sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier '%s'", to_charptr(qualifier_name));
return Qnil;
}
/**
* call-seq:
@@ -255,28 +252,28 @@
* its value
*
*/
static VALUE each_property_qualifier(VALUE self, VALUE property_name)
{
- CMPIInstance *ptr = NULL;
- CMPIStatus status;
+ CIMCInstance *ptr;
+ CIMCStatus status;
int k=0;
int num_props=0;
- CMPIString *property_qualifier_name = NULL;
- CMPIData data;
- Data_Get_Struct(self, CMPIInstance, ptr);
+ CIMCString *property_qualifier_name = NULL;
+ CIMCData data;
+ Data_Get_Struct(self, CIMCInstance, ptr);
- num_props = ptr->ft->getPropertyQualifierCount(ptr, StringValuePtr(property_name), &status);
+ num_props = ptr->ft->getPropertyQualifierCount(ptr, to_charptr(property_name), &status);
if (!status.rc) {
for (; k < num_props; ++k) {
- data = ptr->ft->getPropertyQualifierAt(ptr, StringValuePtr(property_name), k, &property_qualifier_name, &status);
+ data = ptr->ft->getPropertyQualifierAt(ptr, to_charptr(property_name), k, &property_qualifier_name, &status);
if (!status.rc) {
rb_yield_values(2, (property_qualifier_name ? rb_str_new2(property_qualifier_name->ft->getCharPtr(property_qualifier_name, NULL)) : Qnil), sfcc_cimdata_to_value(data));
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier #%d", k);
- }
+ }
if (property_qualifier_name) CMRelease(property_qualifier_name);
}
}
else {
sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier count");
@@ -290,13 +287,13 @@
*
* Gets the number of qualifiers contained in this property
*/
static VALUE property_qualifier_count(VALUE self, VALUE property_name)
{
- CMPIInstance *ptr = NULL;
- Data_Get_Struct(self, CMPIInstance, ptr);
- return UINT2NUM(ptr->ft->getPropertyQualifierCount(ptr, StringValuePtr(property_name), NULL));
+ CIMCInstance *ptr;
+ Data_Get_Struct(self, CIMCInstance, ptr);
+ return UINT2NUM(ptr->ft->getPropertyQualifierCount(ptr, to_charptr(property_name), NULL));
}
/**
* call-seq
* new()
@@ -304,29 +301,25 @@
* Creates an instance from in +object_path+
*
*/
static VALUE new(VALUE klass, VALUE object_path)
{
- CMPIStatus status;
- CMPIInstance *ptr;
- CMPIInstance *newins;
- CMPIObjectPath *op;
+ CIMCStatus status;
+ CIMCInstance *ptr;
+ CIMCObjectPath *op;
- Data_Get_Struct(object_path, CMPIObjectPath, op);
- ptr = newCMPIInstance(op, &status);
- newins = ptr->ft->clone(ptr, &status);
- ptr->ft->release(ptr);
+ Data_Get_Struct(object_path, CIMCObjectPath, op);
+ ptr = cimcEnv->ft->newInstance(cimcEnv, op, &status);
if (!status.rc)
- return Sfcc_wrap_cim_instance(newins);
+ return Sfcc_wrap_cim_instance(ptr);
sfcc_rb_raise_if_error(status, "Can't create instance");
return Qnil;
}
VALUE
-Sfcc_wrap_cim_instance(CMPIInstance *instance)
+Sfcc_wrap_cim_instance(CIMCInstance *instance)
{
- SFCC_INC_REFCOUNT(instance);
return Data_Wrap_Struct(cSfccCimInstance, NULL, dealloc, instance);
}
VALUE cSfccCimInstance;
void init_cim_instance()