public override void generate_error_domain_declaration(ErrorDomain edomain, CCodeFile decl_space) { if (add_symbol_declaration(decl_space, edomain, get_ccode_name(edomain))) { return; } var cenum = new CCodeEnum(get_ccode_name(edomain)); foreach (ErrorCode ecode in edomain.get_codes()) { if (ecode.value == null) { cenum.add_value(new CCodeEnumValue(get_ccode_name(ecode))); } else { ecode.value.emit(this); cenum.add_value(new CCodeEnumValue(get_ccode_name(ecode), get_cvalue(ecode.value))); } } decl_space.add_type_definition(cenum); string quark_fun_name = get_ccode_lower_case_prefix(edomain) + "quark"; var error_domain_define = new CCodeMacroReplacement(get_ccode_upper_case_name(edomain), quark_fun_name + " ()"); decl_space.add_type_definition(error_domain_define); var cquark_fun = new CCodeFunction(quark_fun_name, get_ccode_name(gquark_type.data_type)); decl_space.add_function_declaration(cquark_fun); }
public override void visit_error_domain(ErrorDomain edomain) { if (edomain.comment != null) { cfile.add_type_definition(new CCodeComment(edomain.comment.content)); } generate_error_domain_declaration(edomain, cfile); if (!edomain.is_internal_symbol()) { generate_error_domain_declaration(edomain, header_file); } if (!edomain.is_private_symbol()) { generate_error_domain_declaration(edomain, internal_header_file); } string quark_fun_name = get_ccode_lower_case_prefix(edomain) + "quark"; var cquark_fun = new CCodeFunction(quark_fun_name, get_ccode_name(gquark_type.data_type)); push_function(cquark_fun); var cquark_call = new CCodeFunctionCall(new CCodeIdentifier("g_quark_from_static_string")); cquark_call.add_argument(new CCodeConstant("\"" + CCodeBaseModule.get_quark_name(edomain) + "\"")); ccode.add_return(cquark_call); pop_function(); cfile.add_function(cquark_fun); }
public ErrorType(ErrorDomain error_domain, ErrorCode error_code, SourceReference source_reference = null) { this.error_domain = error_domain; this.data_type = error_domain; this.error_code = error_code; this.source_reference = source_reference; }
public override void visit_error_domain(ErrorDomain ed) { current_scope = ed.scope; ed.accept_children(this); current_scope = current_scope.parent_scope; }
public void ValidUser(string email, string password) { ErrorDomain ret = new ErrorDomain(); if (DomainBase.provider.GetService <IUserRepository>().Signin(email, password).id == null) { throw new ArgumentException("Invalid e-mail or password", "3"); } if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { throw new ArgumentException("Missing Filds", "2"); } }
public void ValidUser(UserDomain user) { ErrorDomain ret = new ErrorDomain(); if (DomainBase.provider.GetService <IUserRepository>().EmailExists(user.email)) { throw new ArgumentException("E-mail already exists", "1"); } if (string.IsNullOrEmpty(user.email) || string.IsNullOrEmpty(user.firstName) || string.IsNullOrEmpty(user.lastName) || string.IsNullOrEmpty(user.password)) { throw new ArgumentException("Missing Filds", "2"); } }
/// <summary> /// Adds the specified error domain to this namespace. /// /// <param name="edomain">an error domain</param> /// </summary> public override void add_error_domain(ErrorDomain edomain) { // namespaces do not support private memebers if (edomain.access == SymbolAccessibility.PRIVATE) { edomain.access = SymbolAccessibility.INTERNAL; } if (edomain.owner == null) { edomain.source_reference.file.add_node(edomain); } error_domains.Add(edomain); scope.add(edomain.name, edomain); }
public override void visit_error_domain(ErrorDomain edomain) { var edomain_dbus_name = get_dbus_name(edomain); if (edomain_dbus_name == null) { base.visit_error_domain(edomain); return; } cfile.add_include("gio/gio.h"); generate_error_domain_declaration(edomain, cfile); if (!edomain.is_internal_symbol()) { generate_error_domain_declaration(edomain, header_file); } if (!edomain.is_private_symbol()) { generate_error_domain_declaration(edomain, internal_header_file); } var error_entries = new CCodeInitializerList(); foreach (ErrorCode ecode in edomain.get_codes()) { var ecode_dbus_name = get_dbus_name(ecode); if (ecode_dbus_name == null) { ecode_dbus_name = Symbol.lower_case_to_camel_case(ecode.name.ToLower()); } var error_entry = new CCodeInitializerList(); error_entry.append(new CCodeIdentifier(get_ccode_name(ecode))); error_entry.append(new CCodeConstant("\"%s.%s\"".printf(edomain_dbus_name, ecode_dbus_name))); error_entries.append(error_entry); } var cdecl = new CCodeDeclaration("const GDBusErrorEntry"); cdecl.add_declarator(new CCodeVariableDeclarator(get_ccode_lower_case_name(edomain) + "_entries[]", error_entries)); cdecl.modifiers = CCodeModifiers.STATIC; cfile.add_constant_declaration(cdecl); string quark_fun_name = get_ccode_lower_case_prefix(edomain) + "quark"; var cquark_fun = new CCodeFunction(quark_fun_name, get_ccode_name(gquark_type.data_type)); push_function(cquark_fun); string quark_name = "%squark_volatile".printf(get_ccode_lower_case_prefix(edomain)); ccode.add_declaration("gsize", new CCodeVariableDeclarator(quark_name, new CCodeConstant("0")), CCodeModifiers.STATIC | CCodeModifiers.VOLATILE); var register_call = new CCodeFunctionCall(new CCodeIdentifier("g_dbus_error_register_error_domain")); register_call.add_argument(new CCodeConstant("\"" + CCodeBaseModule.get_quark_name(edomain) + "\"")); register_call.add_argument(new CCodeUnaryExpression(CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier(quark_name))); register_call.add_argument(new CCodeIdentifier(get_ccode_lower_case_name(edomain) + "_entries")); var nentries = new CCodeFunctionCall(new CCodeIdentifier("G_N_ELEMENTS")); nentries.add_argument(new CCodeIdentifier(get_ccode_lower_case_name(edomain) + "_entries")); register_call.add_argument(nentries); ccode.add_expression(register_call); ccode.add_return(new CCodeCastExpression(new CCodeIdentifier(quark_name), "GQuark")); pop_function(); cfile.add_function(cquark_fun); }
public static JumpTarget error_target(BasicBlock basic_block, CatchClause catch_clause, ErrorDomain error_domain, ErrorCode error_code, Class error_class) { JumpTarget @this = new JumpTarget(); @this.basic_block = basic_block; @this.catch_clause = catch_clause; @this.error_domain = error_domain; @this.error_code = error_code; @this.error_class = error_class; @this.is_error_target = true; return(@this); }
public override void visit_error_domain(ErrorDomain ed) { ed.accept_children(this); }
public virtual void add_error_domain(ErrorDomain edomain) { Report.error(edomain.source_reference, "unexpected declaration"); }
public override void visit_error_domain(ErrorDomain ed) { check_unused_attr(ed); ed.accept_children(this); }
/// <summary> /// Visit operation called for error domains. /// /// <param name="edomain">an error domain</param> /// </summary> public virtual void visit_error_domain(ErrorDomain edomain) { }