Beispiel #1
0
/*
 * GetInstance() -  return the instance data for the specified instance only
 */
static CMPIStatus
GetInstance(CMPIInstanceMI * self,
        const CMPIContext * context,
        const CMPIResult * results,
        const CMPIObjectPath * reference,
        const char ** properties)
{
    Target_Type _context;
    Target_Type _result;
    Target_Type _reference;
    Target_Type _properties;

    CMPIStatus status = {CMPI_RC_OK, NULL};  /* Return status of CIM operations */

    _SBLIM_TRACE(1,("GetInstance() called, self %p, context %p, results %p, reference %p, properties %p", self, context, results, reference, properties));

    TARGET_THREAD_BEGIN_BLOCK; 
    _context = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0);
    _result = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0);
    _reference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0);
    _properties = proplist2target(properties); 

    /* For Python, TargetCall() packs all arguments into a tuple and releases this tuple,
     * effectively DECREFing all elements */

    TargetCall((ProviderMIHandle*)self->hdl, &status, "get_instance", 4, 
                                                               _context,
                                                               _result, 
                                                               _reference,
                                                               _properties);
    TARGET_THREAD_END_BLOCK; 
    _SBLIM_TRACE(1,("GetInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
    return status;
}
Beispiel #2
0
void pythonmod_inform_super(struct module_qstate* qstate, int id, struct module_qstate* super)
{
   struct pythonmod_env* pe = (struct pythonmod_env*)qstate->env->modinfo[id];
   struct pythonmod_qstate* pq = (struct pythonmod_qstate*)qstate->minfo[id];
   PyObject* py_qstate, *py_sqstate, *res;
   PyGILState_STATE gil = PyGILState_Ensure();

   log_query_info(VERB_ALGO, "pythonmod: inform_super, sub is", &qstate->qinfo);
   log_query_info(VERB_ALGO, "super is", &super->qinfo);

   py_qstate = SWIG_NewPointerObj((void*) qstate, SWIGTYPE_p_module_qstate, 0);
   py_sqstate = SWIG_NewPointerObj((void*) super, SWIGTYPE_p_module_qstate, 0);

   res = PyObject_CallFunction(pe->func_inform, "iOOO", id, py_qstate,
	py_sqstate, pq->data);

   if (PyErr_Occurred())
   {
      log_err("pythonmod: Exception occurred in function inform_super");
      log_py_err();
      qstate->ext_state[id] = module_error;
   }
   else if ((res == NULL)  || (!PyObject_IsTrue(res)))
   {
      log_err("pythonmod: python returned bad code in inform_super");
      qstate->ext_state[id] = module_error;
   }

   Py_XDECREF(res);
   Py_XDECREF(py_sqstate);
   Py_XDECREF(py_qstate);

   PyGILState_Release(gil);
}
Beispiel #3
0
/*
 * DeleteInstance() - delete/remove the specified instance.
 */
static CMPIStatus
DeleteInstance(CMPIInstanceMI * self,  
        const CMPIContext * context,
        const CMPIResult * results, 
        const CMPIObjectPath * reference)
{
    Target_Type _context;
    Target_Type _result;
    Target_Type _reference;

    CMPIStatus status = {CMPI_RC_OK, NULL};  

    _SBLIM_TRACE(1,("DeleteInstance() called, context %p, results %p, reference %p", context, results, reference));

    TARGET_THREAD_BEGIN_BLOCK; 
    _context = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0);
    _result = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0);
    _reference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0);

    TargetCall((ProviderMIHandle*)self->hdl, &status, "delete_instance", 3, 
                                                               _context,
                                                               _result, 
                                                               _reference); 
    TARGET_THREAD_END_BLOCK; 
    _SBLIM_TRACE(1,("DeleteInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
    return status;
}
Beispiel #4
0
PyObject * swig_int::__mul__( PyObject * obj1 ) {
    PyObject * ret = NULL ;
    void * argp2 ;


    if ( PyFloat_Check(obj1) ) {
        swig_double * result = new swig_double() ;
        result->value = (double)value * PyFloat_AsDouble(obj1) ;
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_int *"), 0 ))) {
        swig_int * result = new swig_int() ;
        swig_int * temp_m = reinterpret_cast< swig_int * >(argp2) ;
        result->value = value * temp_m->value ;
        result->units = units + "*(" + temp_m->units + ")";
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_double *"), 0 ))) {
        swig_double * result = new swig_double() ;
        swig_double * temp_m = reinterpret_cast< swig_double * >(argp2) ;
        result->value = value * temp_m->value ;
        result->units = units + "*(" + temp_m->units + ")";
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if ( PyInt_Check(obj1) ) {
        swig_int * result = new swig_int() ;
        result->value = value * PyInt_AsLong(obj1) ;
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    }

    return ret ;
}
Beispiel #5
0
static CMPIStatus
associatorNames(
        CMPIAssociationMI* self,
        const CMPIContext* ctx,
        const CMPIResult* rslt,
        const CMPIObjectPath* objName,
        const char* assocClass,
        const char* resultClass,
        const char* role,
        const char* resultRole)
{
    Target_Type _ctx;
    Target_Type _rslt;
    Target_Type _objName ;
    Target_Type _assocClass;
    Target_Type _resultClass;
    Target_Type _role;
    Target_Type _resultRole;

    CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};
   
    _SBLIM_TRACE(1,("associatorNames() called, ctx %p, rslt %p, objName %p, assocClass %s, resultClass %s, role %s, resultRole %s", ctx, rslt, objName, assocClass, resultClass, role, resultRole));

    TARGET_THREAD_BEGIN_BLOCK; 
    _ctx = SWIG_NewPointerObj((void*) ctx, SWIGTYPE_p__CMPIContext, 0);
    _rslt = SWIG_NewPointerObj((void*) rslt, SWIGTYPE_p__CMPIResult, 0);
    _objName = SWIG_NewPointerObj((void*) objName, SWIGTYPE_p__CMPIObjectPath, 0);
    _assocClass = (Target_Type)NULL; 
    _resultClass = (Target_Type)NULL; 
    _role = (Target_Type)NULL; 
    _resultRole = (Target_Type)NULL;
    if (assocClass != NULL)
    {
        _assocClass = string2target(assocClass); 
    }
    if (resultClass != NULL)
    {
        _resultClass = string2target(resultClass); 
    }
    if (role != NULL) 
    { 
        _role = string2target(role); 
    }
    if (resultRole != NULL) 
    { 
        _resultRole = string2target(resultRole); 
    }

    TargetCall((ProviderMIHandle*)self->hdl, &status, "associator_names", 7, 
                                                               _ctx,
                                                               _rslt, 
                                                               _objName,
                                                               _assocClass,
                                                               _resultClass,
                                                               _role,
                                                               _resultRole); 
    TARGET_THREAD_END_BLOCK; 
    _SBLIM_TRACE(1,("associatorNames() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
    return status;
}
Beispiel #6
0
/*
 * EnumInstances() - return a list of all the instances (i.e. return all the instance data)
 */
static CMPIStatus
EnumInstances(CMPIInstanceMI * self,  
        const CMPIContext * context,
        const CMPIResult * result,
        const CMPIObjectPath * reference,
        const char ** properties)
{
    Target_Type _context;
    Target_Type _result;
    Target_Type _reference;
    Target_Type _properties;

    CMPIStatus status = {CMPI_RC_OK, NULL};  /* Return status of CIM operations */
    /*   char * namespace = CMGetCharPtr(CMGetNameSpace(reference, NULL));  Our current CIM namespace */

    _SBLIM_TRACE(1,("EnumInstances() called, self %p, context %p, result %p, reference %p, properties %p", self, context, result, reference, properties));

    TARGET_THREAD_BEGIN_BLOCK; 
    _context = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0);
    _result = SWIG_NewPointerObj((void*) result, SWIGTYPE_p__CMPIResult, 0);
    _reference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0);
    _properties = proplist2target(properties); 

    TargetCall((ProviderMIHandle*)self->hdl, &status, "enum_instances", 4, 
                                                               _context,
                                                               _result, 
                                                               _reference,
                                                               _properties); 
    TARGET_THREAD_END_BLOCK; 
    _SBLIM_TRACE(1,("EnumInstances() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
    return status;
}
Beispiel #7
0
/*
 * CreateInstance() - create a new instance from the specified instance data.
 */
static CMPIStatus
CreateInstance(CMPIInstanceMI * self,
        const CMPIContext * context,
        const CMPIResult * results,
        const CMPIObjectPath * reference,
        const CMPIInstance * newinstance)
{
    Target_Type _context;
    Target_Type _result;
    Target_Type _reference;
    Target_Type _newinst;

    CMPIStatus status = {CMPI_RC_ERR_NOT_SUPPORTED, NULL};   /* Return status of CIM operations. */

   
   /* Creating new instances is not supported for this class. */
  
    _SBLIM_TRACE(1,("CreateInstance() called, context %p, results %p, reference %p, newinstance %p", context, results, reference, newinstance));

    TARGET_THREAD_BEGIN_BLOCK; 
    _context = SWIG_NewPointerObj((void*) context, SWIGTYPE_p__CMPIContext, 0);
    _result = SWIG_NewPointerObj((void*) results, SWIGTYPE_p__CMPIResult, 0);
    _reference = SWIG_NewPointerObj((void*) reference, SWIGTYPE_p__CMPIObjectPath, 0);
    _newinst = SWIG_NewPointerObj((void*) newinstance, SWIGTYPE_p__CMPIInstance, 0);

    TargetCall((ProviderMIHandle*)self->hdl, &status, "create_instance", 4, 
                                                               _context,
                                                               _result, 
                                                               _reference,
                                                               _newinst); 
    TARGET_THREAD_END_BLOCK; 
    _SBLIM_TRACE(1,("CreateInstance() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
    return status;
}
Beispiel #8
0
void multimin_df_cb(const gsl_vector *v, void *params, gsl_vector * g) {
    lua_State * L=((multi_param*)params)->L;
    int df_index=((multi_param*)params)->df_index;
    lua_rawgeti(L,LUA_REGISTRYINDEX,df_index);
    //push the parameters and call it
    array<double> V(v->size,v->data);
    SWIG_NewPointerObj(L,(void *) &V,SWIGTYPE_p_arrayT_double_t,0);
    array<double> G(g->size,g->data);
    SWIG_NewPointerObj(L,(void *) &G,SWIGTYPE_p_arrayT_double_t,0);
    lua_pcall(L, 2, 0, 0);
}
Beispiel #9
0
int multiroot_df_cb(const gsl_vector *v, void *params, gsl_matrix * j) {
    lua_State * L=((multi_param*)params)->L;
    int df_index=((multi_param*)params)->df_index;
    lua_rawgeti(L,LUA_REGISTRYINDEX,df_index);
    //push the parameters and call it
    array<double> V(v->size,v->data);
    SWIG_NewPointerObj(L,(void *) &V,SWIGTYPE_p_arrayT_double_t,0);
    array<double> J(j->size1,j->size2,j->data);
    SWIG_NewPointerObj(L,(void *) &J,SWIGTYPE_p_arrayT_double_t,0);
    lua_pcall(L, 2, 0, 0);
    return GSL_SUCCESS;
}
Beispiel #10
0
PyObject * swig_int::__pow__( PyObject * obj1 ) {
    PyObject * ret = NULL ;
    void * argp2 ;

    if ( units.compare("1")) {
        PyErr_SetString(PyExc_TypeError,"Both arguments must be unitless. Cannot create new unit-ed type.");
        return NULL ;
    }

    if ( PyFloat_Check(obj1) ) {
        swig_double * result = new swig_double() ;
        result->value = pow(value , PyFloat_AsDouble(obj1)) ;
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_int *"), 0 ))) {
        swig_int * temp_m = reinterpret_cast< swig_int * >(argp2) ;
        swig_int * result = new swig_int() ;
        if ( !temp_m->units.compare("1")) {
            result->value = (long long)(pow(value , temp_m->value)) ;
        } else {
            PyErr_SetString(PyExc_TypeError,"Both arguments must be unitless. Cannot create new unit-ed type.");
            return NULL ;
        }
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_double *"), 0 ))) {
        swig_double * result = new swig_double() ;
        swig_double * temp_m = reinterpret_cast< swig_double * >(argp2) ;
        if ( !temp_m->units.compare("1")) {
            result->value = pow(value , temp_m->value) ;
        } else {
            PyErr_SetString(PyExc_TypeError,"Both arguments must be unitless. Cannot create new unit-ed type.");
            return NULL ;
        }
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if ( PyInt_Check(obj1) ) {
        swig_int * result = new swig_int() ;
        int power = PyInt_AsLong(obj1) ;
        result->value = (long long)(pow(value , power)) ;
        result->units = units ;
        for ( int ii = 1 ; ii < power ; ii++ ) {
            result->units = result->units + "*(" + units + ")";
        }
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    }

    return ret ;
}
Beispiel #11
0
static PyObject * 
new_loc_inst(D_Parser* dp, d_loc_t* dlt) {
  PyObject * buf;
  D_ParserPyInterface *ppi = d_interface(dp);
  PyObject *new_loc_args = PyTuple_New(3);
  PyObject *new_loc_inst;
  buf = SWIG_NewPointerObj((void *)dlt, SWIG_TypeQuery("_p_d_loc_t"),0);
  PyTuple_SetItem(new_loc_args, 0, buf);
  buf = SWIG_NewPointerObj((void *)dp, SWIG_TypeQuery("_p_D_Parser"),0);
  PyTuple_SetItem(new_loc_args, 1, buf);
  Py_INCREF(ppi->py_buf_start);
  PyTuple_SetItem(new_loc_args, 2, ppi->py_buf_start);
  new_loc_inst = PyObject_CallObject(ppi->loc_type, new_loc_args);
  Py_DECREF(new_loc_args);
  return new_loc_inst;
}
Beispiel #12
0
PyObject * swig_int::__lshift__( PyObject * obj1 ) {
    swig_int * result ;
    PyObject * ret = NULL ;
    void * argp2 ;

    result = new swig_int() ;

    if ( PyFloat_Check(obj1) ) {
        PyErr_SetString(PyExc_TypeError,"Shift value must be integer");
        return NULL ;
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_int *"), 0 ))) {
        swig_int * temp_m = reinterpret_cast< swig_int * >(argp2) ;
        if ( !temp_m->units.compare("1")) {
            result->value = value << temp_m->value ;
        } else {
            PyErr_SetString(PyExc_TypeError,"Shift value must be unitless.");
            return NULL ;
        }
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_double *"), 0 ))) {
        PyErr_SetString(PyExc_TypeError,"Shift value must be integer");
        return NULL ;
    } else if ( PyInt_Check(obj1) ) {
        result->value = value << PyInt_AsLong(obj1) ;
    }
    result->units = units ;

    ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);

    return ret ;
}
Beispiel #13
0
static PyObject *
make_py_node(D_Parser *dp, D_ParseNode *dpn) {
  PyObject * buf;
  D_ParserPyInterface *ppi = d_interface(dp);
  PyObject *new_node_arg = PyTuple_New(3);
  PyObject *node_inst;
  buf = SWIG_NewPointerObj((void *)dpn, SWIG_TypeQuery("_p_D_ParseNode"),0);
  PyTuple_SetItem(new_node_arg, 0, buf);
  buf = SWIG_NewPointerObj((void *)dp, SWIG_TypeQuery("_p_D_Parser"),0);
  PyTuple_SetItem(new_node_arg, 1, buf);
  Py_INCREF(ppi->py_buf_start);
  PyTuple_SetItem(new_node_arg, 2, ppi->py_buf_start);
  node_inst = PyObject_CallObject(ppi->node_info_type, new_node_arg);
  Py_DECREF(new_node_arg);
  return node_inst;
}
SWIG_Python_InstallConstants(PyObject *d, swig_const_info constants[]) {
  int i;
  PyObject *obj;
  for (i = 0; constants[i].type; i++) {
    switch(constants[i].type) {
    case SWIG_PY_INT:
      obj = PyInt_FromLong(constants[i].lvalue);
      break;
    case SWIG_PY_FLOAT:
      obj = PyFloat_FromDouble(constants[i].dvalue);
      break;
    case SWIG_PY_STRING:
      obj = PyString_FromString((char *) constants[i].pvalue);
      break;
    case SWIG_PY_POINTER:
      obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
      break;
    case SWIG_PY_BINARY:
      obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
      break;
    default:
      obj = 0;
      break;
    }
    if (obj) {
      PyDict_SetItemString(d,constants[i].name,obj);
      Py_DECREF(obj);
    }
  }
}
Beispiel #15
0
/* Function to get the UI Value for a particular option */
static SCM
taxtable_get_value (GNCOption *option, GtkWidget *widget)
{
    GncTaxTable *taxtable;

    taxtable = gnc_simple_combo_get_value (GTK_COMBO_BOX(widget));
    return SWIG_NewPointerObj(taxtable, SWIG_TypeQuery("_p__gncTaxTable"), 0);
}
Beispiel #16
0
/* Function to get the UI Value for a particular option */
static SCM
invoice_get_value (GNCOption *option, GtkWidget *widget)
{
    GncInvoice *invoice;

    invoice = gnc_general_search_get_selected (GNC_GENERAL_SEARCH (widget));
    return SWIG_NewPointerObj(invoice, SWIG_TypeQuery("_p__gncInvoice"), 0);
}
Beispiel #17
0
void multimin_fdf_cb(const gsl_vector *v, void *params, double * f, gsl_vector * g) {
    lua_State * L=((multi_param*)params)->L;
    int fdf_index=((multi_param*)params)->fdf_index;
    if(fdf_index<0) {
        *f=multimin_f_cb(v,params);
        multimin_df_cb(v,params,g);
    } else {
        lua_rawgeti(L,LUA_REGISTRYINDEX,fdf_index);
        //push the parameters and call it
        array<double> V(v->size,v->data);
        SWIG_NewPointerObj(L,(void *) &V,SWIGTYPE_p_arrayT_double_t,0);
        array<double> G(g->size,g->data);
        SWIG_NewPointerObj(L,(void *) &G,SWIGTYPE_p_arrayT_double_t,0);
        lua_pcall(L, 2, 1, 0);
        *f=lua_tonumber(L,-1);
        lua_pop(L,1);
    }
}
Beispiel #18
0
/* Function to get the UI Value for a particular option */
static SCM
vendor_get_value (GNCOption *option, GtkWidget *widget)
{
    GncOwner owner;

    gnc_owner_get_owner (widget, &owner);
    return SWIG_NewPointerObj(owner.owner.undefined,
                              SWIG_TypeQuery("_p__gncVendor"), 0);
}
Beispiel #19
0
int multiroot_fdf_cb(const gsl_vector *v, void *params, gsl_vector * f, gsl_matrix * j) {
    lua_State * L=((multi_param*)params)->L;
    int fdf_index=((multi_param*)params)->fdf_index;
    if(fdf_index<0) {
        multiroot_f_cb(v,params,f);
        multiroot_df_cb(v,params,j);
    } else {
        lua_rawgeti(L,LUA_REGISTRYINDEX,fdf_index);
        //push the parameters and call it
        array<double> V(v->size,v->data);
        SWIG_NewPointerObj(L,(void *) &V,SWIGTYPE_p_arrayT_double_t,0);
        array<double> F(f->size,f->data);
        SWIG_NewPointerObj(L,(void *) &F,SWIGTYPE_p_arrayT_double_t,0);
        array<double> J(j->size1,j->size2,j->data);
        SWIG_NewPointerObj(L,(void *) &J,SWIGTYPE_p_arrayT_double_t,0);
        lua_pcall(L, 3, 0, 0);
    }
    return GSL_SUCCESS;
}
Beispiel #20
0
static SCM
glist_to_scm_list_helper(GList *glist, swig_type_info *wct)
{
    SCM list = SCM_EOL;
    GList *node;

    for (node = glist; node; node = node->next)
        list = scm_cons(SWIG_NewPointerObj(node->data, wct, 0), list);

    return scm_reverse (list);
}
Beispiel #21
0
int main(int argc, char** argv)
{
    bool running = true;
    
    // Initialise lua state
    lua_State* luaState = luaL_newstate();

    // Open lua libs
    luaL_openlibs(luaState);

    // Load config file
    if (luaL_loadfile(luaState, "config.lua") || lua_pcall(luaState, 0, 0, 0))
    {
        error(luaState, "%s", lua_tostring(luaState, -1));
    }

    ColourComponent col;
    col.r = 1;

    // Pass col to lua
    swig_type_info* typeinfo = SWIG_TypeQuery(luaState, "ColourComponent *");

    if (typeinfo == nullptr)
    {
        std::cerr << "Invalid typeinfo" << std::endl;
        system("pause");
        exit(1);
    }
    
    SWIG_NewPointerObj(luaState, &col, typeinfo, 0);
    lua_setglobal(luaState, "col");

    // Do lua prompt in separate thread
    std::thread luaThread(ca2d::luaprompt, luaState);

    // Main loop
    while (running)
    {
        // Wait 2 seconds
        std::chrono::milliseconds time(2000);
        std::this_thread::sleep_for(time);

        // Output colour value
        std::cout << "col.r == " << col.r << std::endl;
    }

    // Wait for threads to finish
    luaThread.join();

    // Clean up
    lua_close(luaState);

    system("pause");
}
Beispiel #22
0
bool PushPointer( lua_State* L, void* ptr, const char* type_name, int owned )
{
    swig_type_info * pTypeInfo = querySwigType(type_name);
    if (pTypeInfo == 0)
    {
        return false;   
    }

    SWIG_NewPointerObj(L, ptr, pTypeInfo, owned);
    return true;
}
Beispiel #23
0
/* Function to get the UI Value for a particular option */
static SCM
owner_get_value (GNCOption *option, GtkWidget *widget)
{
    static GncOwner owner;	/* XXX: might cause trouble? */
    GncOwnerType type;

    type = get_owner_type_from_option (option);
    owner.type = type;
    gnc_owner_get_owner (widget, &owner);

    return SWIG_NewPointerObj(&owner, SWIG_TypeQuery("_p__gncOwner"), 0);
}
Beispiel #24
0
static PyObject *_wrap_new_Pdbl(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    double *result;
    
    if(!PyArg_ParseTuple(args,(char *)":new_Pdbl")) goto fail;
    result = (double *)new_Pdbl();
    
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_double, 0);
    return resultobj;
    fail:
    return NULL;
}
Beispiel #25
0
static PyObject *_wrap_rlib_init(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    rlib *result;
    
    if(!PyArg_ParseTuple(args,(char *)":rlib_init")) goto fail;
    result = (rlib *)rlib_init();
    
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_rlib, 0);
    return resultobj;
    fail:
    return NULL;
}
PyObject *
convertEpetraVectorToPython(const Teuchos::RCP< const Epetra_Vector > *cev)
{
  // SWIG initialization
  static swig_type_info * swig_ENV_ptr =
    SWIG_TypeQuery("Teuchos::RCP< PyTrilinos::Epetra_NumPyVector >*");
  //
  // Convert to PyTrilinos::Epetra_NumPyVector
  const Teuchos::RCP< Epetra_NumPyVector > *env = new
    Teuchos::RCP< Epetra_NumPyVector >(new Epetra_NumPyVector(View, **cev));
  return SWIG_NewPointerObj((void*)env, swig_ENV_ptr, 1);
}
Beispiel #27
0
double multimin_f_cb(const gsl_vector *v, void *params) {
    lua_State * L=((multi_param*)params)->L;
    int f_index=((multi_param*)params)->f_index;
    lua_rawgeti(L,LUA_REGISTRYINDEX,f_index);
    //push the parameters and call it
    array<double> V(v->size,v->data);
    SWIG_NewPointerObj(L,(void *) &V,SWIGTYPE_p_arrayT_double_t,0);
    lua_pcall(L, 1, 1, 0);
    double ret=lua_tonumber(L,-1);
    lua_pop(L,1);
    return ret;
}
Beispiel #28
0
PyObject * swig_int::__mod__( PyObject * obj1 ) {
    PyObject * ret = NULL ;
    void * argp2 ;

    if ( PyFloat_Check(obj1) ) {
        swig_double * result = new swig_double() ;
        result->value = fmod(value , PyFloat_AsDouble(obj1)) ;
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_int *"), 0 ))) {
        swig_int * result = new swig_int() ;
        swig_int * temp_m = reinterpret_cast< swig_int * >(argp2) ;
        if ( !temp_m->units.compare("1")) {
            result->value = value % temp_m->value ;
        } else {
            PyErr_SetString(PyExc_TypeError,"Divisor must be unitless.  Cannot create new unit-ed type.");
            return NULL ;
        }
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    } else if (SWIG_IsOK(SWIG_ConvertPtr(obj1, &argp2,SWIG_TypeQuery("swig_double *"), 0 ))) {
        swig_double * result = new swig_double() ;
        swig_double * temp_m = reinterpret_cast< swig_double * >(argp2) ;
        if ( !temp_m->units.compare("1")) {
            result->value = fmod( value , temp_m->value) ;
        } else {
            PyErr_SetString(PyExc_TypeError,"Divisor must be unitless.  Cannot create new unit-ed type.");
            return NULL ;
        }
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_double *"), SWIG_POINTER_OWN);
    } else if ( PyInt_Check(obj1) ) {
        swig_int * result = new swig_int() ;
        result->value = value % PyInt_AsLong(obj1) ;
        result->units = units ;
        ret = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIG_TypeQuery("swig_int *"), SWIG_POINTER_OWN);
    }

    return ret ;
}
Beispiel #29
0
// this code pushes a C++ pointer as well as the SWIG type onto the Lua stack
bool push_pointer(lua_State*L, void* ptr, const char* type_name, int owned = 0) {
  // task 1: get the object 'type' which is registered with SWIG
  // you need to call SWIG_TypeQuery() with the class name
  // (normally, just look in the wrapper file to get this)
  swig_type_info * pTypeInfo = SWIG_TypeQuery(L, type_name);
  if (pTypeInfo == 0)
    return false;   // error
  // task 2: push the pointer to the Lua stack
  // this requires a pointer & the type
  // the last param specifies if Lua is responsible for deleting the object
  SWIG_NewPointerObj(L, ptr, pTypeInfo, owned);
  return true;
}
Beispiel #30
0
static PyObject *_wrap_copy_Pint(PyObject *self, PyObject *args) {
    PyObject *resultobj;
    int arg1 ;
    int *result;
    
    if(!PyArg_ParseTuple(args,(char *)"i:copy_Pint",&arg1)) goto fail;
    result = (int *)copy_Pint(arg1);
    
    resultobj = SWIG_NewPointerObj((void *) result, SWIGTYPE_p_int, 0);
    return resultobj;
    fail:
    return NULL;
}