| 185 | } |
| 186 | |
| 187 | bool FilterUtility::EvaluateFilter(ScriptFrame& frame, Expression *filter, |
| 188 | const Object::Ptr& target, const String& variableName) |
| 189 | { |
| 190 | if (!filter) |
| 191 | return true; |
| 192 | |
| 193 | Type::Ptr type = target->GetReflectionType(); |
| 194 | String varName; |
| 195 | |
| 196 | if (variableName.IsEmpty()) |
| 197 | varName = type->GetName().ToLower(); |
| 198 | else |
| 199 | varName = variableName; |
| 200 | |
| 201 | Namespace::Ptr frameNS; |
| 202 | |
| 203 | if (frame.Self.IsEmpty()) { |
| 204 | frameNS = new Namespace(); |
| 205 | frame.Self = frameNS; |
| 206 | } else { |
| 207 | /* Enforce a namespace object for 'frame.self'. */ |
| 208 | ASSERT(frame.Self.IsObjectType<Namespace>()); |
| 209 | |
| 210 | frameNS = frame.Self; |
| 211 | |
| 212 | ASSERT(frameNS != ScriptGlobal::GetGlobals()); |
| 213 | } |
| 214 | |
| 215 | frameNS->Set("obj", target); |
| 216 | frameNS->Set(varName, target); |
| 217 | |
| 218 | for (int fid = 0; fid < type->GetFieldCount(); fid++) { |
| 219 | Field field = type->GetFieldInfo(fid); |
| 220 | |
| 221 | if ((field.Attributes & FANavigation) == 0) |
| 222 | continue; |
| 223 | |
| 224 | Object::Ptr joinedObj = target->NavigateField(fid); |
| 225 | |
| 226 | if (field.NavigationName) |
| 227 | frameNS->Set(field.NavigationName, joinedObj); |
| 228 | else |
| 229 | frameNS->Set(field.Name, joinedObj); |
| 230 | } |
| 231 | |
| 232 | return Convert::ToBool(filter->Evaluate(frame)); |
| 233 | } |
| 234 | |
| 235 | static void FilteredAddTarget(ScriptFrame& permissionFrame, Expression *permissionFilter, |
| 236 | ScriptFrame& frame, Expression *ufilter, std::vector<Value>& result, const String& variableName, const Object::Ptr& target) |
nothing calls this directly
no test coverage detected