@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));
 }
Beispiel #2
0
 public static boolean Eq(
     Xop_ctx ctx,
     byte[] lhs,
     byte[]
         rhs) { // PATCH.PHP: php allows "003" == "3.0"; ASSUME: numbers are either int or int-like
   // decimal; long, float, decimal not supported
   int lhs_len = lhs.length, rhs_len = rhs.length;
   boolean rv = true;
   if (lhs_len == rhs_len) {
     for (int i = 0; i < lhs_len; i++) {
       if (lhs[i] != rhs[i]) {
         rv = false;
         break;
       }
     }
     if (rv) return true;
   } else if (lhs_len == 0
       || rhs_len == 0) // one side is empty String and the other side is String; return false;
   return false;
   Gfo_number_parser lhs_parser = ctx.Tmp_mgr().Pfunc_num_parser_0();
   Gfo_number_parser rhs_parser = ctx.Tmp_mgr().Pfunc_num_parser_1();
   lhs_parser.Parse(lhs, 0, lhs_len);
   if (lhs_parser.Has_err()) return false;
   rhs_parser.Parse(rhs, 0, rhs_len);
   if (rhs_parser.Has_err()) return false;
   return lhs_parser.Has_frac() || rhs_parser.Has_frac()
       ? lhs_parser.Rv_as_dec().Eq(rhs_parser.Rv_as_dec())
       : lhs_parser.Rv_as_int() == rhs_parser.Rv_as_int();
 }