| 983 | } |
| 984 | |
| 985 | void OpInfo::WriteClassDef(WritableFile* cc) const { |
| 986 | string class_def; |
| 987 | strings::StrAppend(&class_def, |
| 988 | GetConstructorDecl(strings::StrCat(op_name, "::"), |
| 989 | /* include_attr */ true), |
| 990 | " {\n"); |
| 991 | strings::StrAppend(&class_def, GetConstructorBody()); |
| 992 | strings::StrAppend(&class_def, "}\n\n"); |
| 993 | |
| 994 | if (has_optional_attrs) { |
| 995 | strings::StrAppend(&class_def, |
| 996 | GetConstructorDecl(strings::StrCat(op_name, "::"), |
| 997 | /* include_attr */ false)); |
| 998 | strings::StrAppend(&class_def, "\n : ", op_name, "("); |
| 999 | int i = 0; |
| 1000 | for (; i < arg_names.size(); ++i) { |
| 1001 | if (i > 0) strings::StrAppend(&class_def, ", "); |
| 1002 | strings::StrAppend(&class_def, arg_names[i]); |
| 1003 | } |
| 1004 | if (i > 0) strings::StrAppend(&class_def, ", "); |
| 1005 | strings::StrAppend(&class_def, op_name, "::Attrs()"); |
| 1006 | strings::StrAppend(&class_def, ") {}\n\n"); |
| 1007 | } |
| 1008 | TF_CHECK_OK(cc->Append(class_def)); |
| 1009 | } |
| 1010 | |
| 1011 | void WriteCCOp(const OpDef& graph_op_def, const ApiDef& api_def, |
| 1012 | const std::vector<string>& aliases, WritableFile* h, |