2 * try to convert 'input' of type 'inputType' to 'output' of type 'outputType' * return FALSE on success */
| 455 | * return FALSE on success |
| 456 | */ |
| 457 | BOOLEAN iiConvert (int inputType, int outputType, int index, leftv input, leftv output,const struct sConvertTypes *dConvertTypes) |
| 458 | { |
| 459 | output->Init(); |
| 460 | if ((inputType==outputType) |
| 461 | || (outputType==DEF_CMD) |
| 462 | || ((outputType==IDHDL)&&(input->rtyp==IDHDL))) |
| 463 | { |
| 464 | memcpy(output,input,sizeof(*output)); |
| 465 | input->Init(); |
| 466 | return FALSE; |
| 467 | } |
| 468 | else if (outputType==ANY_TYPE) |
| 469 | { |
| 470 | output->rtyp=ANY_TYPE; |
| 471 | output->data=(char *)(long)input->Typ(); |
| 472 | /* the name of the object:*/ |
| 473 | if (input->e==NULL) |
| 474 | { |
| 475 | if (input->rtyp==IDHDL) |
| 476 | /* preserve name: copy it */ |
| 477 | output->name=omStrDup(IDID((idhdl)(input->data))); |
| 478 | else if (input->name!=NULL) |
| 479 | { |
| 480 | if (input->rtyp==ALIAS_CMD) |
| 481 | output->name=omStrDup(input->name); |
| 482 | else |
| 483 | { |
| 484 | output->name=input->name; |
| 485 | input->name=NULL; |
| 486 | } |
| 487 | } |
| 488 | else if ((input->rtyp==POLY_CMD) && (input->name==NULL)) |
| 489 | { |
| 490 | if (input->data!=NULL) |
| 491 | { |
| 492 | int nr=pIsPurePower((poly)input->data); |
| 493 | if (nr!=0) |
| 494 | { |
| 495 | if (pGetExp((poly)input->data,nr)==1) |
| 496 | { |
| 497 | output->name=omStrDup(currRing->names[nr-1]); |
| 498 | } |
| 499 | else |
| 500 | { |
| 501 | char *tmp=(char *)omAlloc(8); |
| 502 | snprintf(tmp,8,"%c%d",*(currRing->names[nr-1]), |
| 503 | (int)pGetExp((poly)input->data,nr)); |
| 504 | output->name=tmp; |
| 505 | } |
| 506 | } |
| 507 | else if(pIsConstant((poly)input->data)) |
| 508 | { |
| 509 | StringSetS(""); |
| 510 | number n=(pGetCoeff((poly)input->data)); |
| 511 | n_Write(n, currRing->cf); |
| 512 | (pGetCoeff((poly)input->data))=n; // n_Write may have changed n |
| 513 | output->name=StringEndS(); |
| 514 | } |
no test coverage detected