| 4473 | } |
| 4474 | |
| 4475 | asCObjectProperty *asCBuilder::AddPropertyToClass(sClassDeclaration *decl, const asCString &name, const asCDataType &dt, bool isPrivate, bool isProtected, bool isInherited, asCScriptCode *file, asCScriptNode *node) |
| 4476 | { |
| 4477 | if( node ) |
| 4478 | { |
| 4479 | asASSERT(!isInherited); |
| 4480 | |
| 4481 | // Check if the property is allowed |
| 4482 | if( !dt.CanBeInstantiated() ) |
| 4483 | { |
| 4484 | if( file && node ) |
| 4485 | { |
| 4486 | asCString str; |
| 4487 | if( dt.IsAbstractClass() ) |
| 4488 | str.Format(TXT_ABSTRACT_CLASS_s_CANNOT_BE_INSTANTIATED, dt.Format(decl->typeInfo->nameSpace).AddressOf()); |
| 4489 | else if( dt.IsInterface() ) |
| 4490 | str.Format(TXT_INTERFACE_s_CANNOT_BE_INSTANTIATED, dt.Format(decl->typeInfo->nameSpace).AddressOf()); |
| 4491 | else |
| 4492 | // TODO: Improve error message to explain why |
| 4493 | str.Format(TXT_DATA_TYPE_CANT_BE_s, dt.Format(decl->typeInfo->nameSpace).AddressOf()); |
| 4494 | WriteError(str, file, node); |
| 4495 | } |
| 4496 | return 0; |
| 4497 | } |
| 4498 | |
| 4499 | // Register the initialization expression (if any) to be compiled later |
| 4500 | asCScriptNode *declNode = node; |
| 4501 | asCScriptNode *initNode = 0; |
| 4502 | if( node->next && node->next->nodeType != snIdentifier ) |
| 4503 | { |
| 4504 | asASSERT( node->next->nodeType == snAssignment ); |
| 4505 | initNode = node->next; |
| 4506 | } |
| 4507 | |
| 4508 | sPropertyInitializer p(name, declNode, initNode, file); |
| 4509 | decl->propInits.PushLast(p); |
| 4510 | } |
| 4511 | else |
| 4512 | { |
| 4513 | // If the declaration node is not given, then |
| 4514 | // this property is inherited from a base class |
| 4515 | asASSERT(isInherited); |
| 4516 | } |
| 4517 | |
| 4518 | // Add the property to the object type |
| 4519 | return CastToObjectType(decl->typeInfo)->AddPropertyToClass(name, dt, isPrivate, isProtected, isInherited); |
| 4520 | } |
| 4521 | |
| 4522 | bool asCBuilder::DoesMethodExist(asCObjectType *objType, int methodId, asUINT *methodIndex) |
| 4523 | { |
no test coverage detected