| 594 | } |
| 595 | |
| 596 | data_map PythonGenerator::getTypeInfo(DataType *t) |
| 597 | { |
| 598 | data_map info; |
| 599 | info["name"] = filterName(getOutputName(t, false)); |
| 600 | info["isNonEncapsulatedUnion"] = false; |
| 601 | switch (t->getDataType()) |
| 602 | { |
| 603 | case DataType::data_type_t::kAliasType: |
| 604 | { |
| 605 | info = getTypeInfo(t->getTrueDataType()); |
| 606 | break; |
| 607 | } |
| 608 | case DataType::data_type_t::kArrayType: |
| 609 | { |
| 610 | // Array type requires the array element count to come after the variable/member name. |
| 611 | ArrayType *a = dynamic_cast<ArrayType *>(t); |
| 612 | assert(a); |
| 613 | info["type"] = "array"; |
| 614 | info["elementCount"] = a->getElementCount(); |
| 615 | info["elementType"] = getTypeInfo(a->getElementType()); |
| 616 | break; |
| 617 | } |
| 618 | case DataType::data_type_t::kBuiltinType: |
| 619 | { |
| 620 | assert(dynamic_cast<const BuiltinType *>(t)); |
| 621 | info["type"] = getBuiltinTypename(dynamic_cast<const BuiltinType *>(t)); |
| 622 | break; |
| 623 | } |
| 624 | case DataType::data_type_t::kEnumType: |
| 625 | { |
| 626 | info["type"] = "enum"; |
| 627 | break; |
| 628 | } |
| 629 | case DataType::data_type_t::kFunctionType: |
| 630 | { |
| 631 | info["type"] = "function"; |
| 632 | FunctionType *funType = dynamic_cast<FunctionType *>(t); |
| 633 | assert(funType); |
| 634 | const FunctionType::c_function_list_t &callbacks = funType->getCallbackFuns(); |
| 635 | if (callbacks.size() > 1) |
| 636 | { |
| 637 | info["tableName"] = "_" + funType->getName(); |
| 638 | } |
| 639 | else if (callbacks.size() == 1) |
| 640 | { |
| 641 | info["tableName"] = ""; |
| 642 | info["callbackName"] = callbacks[0]->getName(); |
| 643 | } |
| 644 | else |
| 645 | { |
| 646 | throw semantic_error( |
| 647 | "Function has function type parameter (callback parameter), but in " |
| 648 | "IDL is missing function definition, which can be passed there."); |
| 649 | } |
| 650 | break; |
| 651 | } |
| 652 | case DataType::data_type_t::kListType: |
| 653 | { |
nothing calls this directly
no test coverage detected