LINUXCNC的python模块生成函数

 
      char *name;
      char *prefix = 0;
      halobject *self = (halobject *)_self;
   
      if(!PyArg_ParseTuple(args, "s|s:hal.component", &name, &prefix)) return -1;
   
      self->items = new itemmap();
   
      self->hal_id = hal_init(name);
      if(self->hal_id <= 0) {
          pyhal_error(self->hal_id);
          return -1;
      }
   
      self->name = strdup(name);
      self->prefix = strdup(prefix ? prefix : name);
      if(!self->name) {
          PyErr_SetString(PyExc_MemoryError, "strdup(name) failed");
          return -1;
      }
      if(!self->prefix) {
          PyErr_SetString(PyExc_MemoryError, "strdup(prefix) failed");
          return -1;
      }

你可能感兴趣的:(LINUXCNC的python模块生成函数)