Esempio n. 1
0
 @Override
 public void Func_evaluate(Bry_bfr bfr, Xop_ctx ctx, Xot_invk caller, Xot_invk self, byte[] src) {
   byte[] user_name = Eval_argx(ctx, src, caller, self);
   byte[] when_m = Bry_.Empty, when_f = Bry_.Empty, when_u = Bry_.Empty;
   int self_args_len = self.Args_len();
   if (self_args_len == 0) return; // per MW: EX: {{gender:name}} -> ""
   else {
     if (self_args_len > 0) {
       when_m =
           when_u =
               Pf_func_.Eval_arg_or_empty(
                   ctx, src, caller, self, self_args_len, 0); // default when_u to when_m
       if (self_args_len > 1) {
         when_f = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 1);
         if (self_args_len > 2) {
           when_u = Pf_func_.Eval_arg_or_empty(ctx, src, caller, self, self_args_len, 2);
         }
       }
     }
   }
   if (self_args_len == 1) {
     bfr.Add(when_m);
     return;
   } // per MW: EX: {{gender:name|a}} -> "a"
   int gender = Get_gender(ctx.App().User(), user_name);
   Xol_lang_itm lang = ctx.Page().Lang();
   bfr.Add(lang.Gender().Gender_eval(gender, when_m, when_f, when_u));
 }
Esempio n. 2
0
 public boolean Expr(Scrib_proc_args args, Scrib_proc_rslt rslt) {
   byte[] expr_bry =
       args.Xstr_bry_or_null(
           0); // NOTE: some modules will pass in an int; PAGE:en.w:531_BC DATE:2016-04-29
   Bry_bfr tmp_bfr = core.Wiki().Utl__bfr_mkr().Get_b128();
   Pfunc_expr.Evaluate(tmp_bfr, core.Ctx(), expr_bry);
   String expr_rslt = tmp_bfr.To_str_and_rls();
   return rslt.Init_obj(
       expr_rslt); // NOTE: always return rslt; don't throw error even if expr is invalid;
                   // EX:mw.ParserFuntion.expr('fail'); PAGE:es.w:Freer_(Texas) DATE:2015-07-28
 }