Lines Matching defs:factory

2  * Implementation of the ANTLR3 string and string factory classes
38 static pANTLR3_STRING newRaw8 (pANTLR3_STRING_FACTORY factory);
39 static pANTLR3_STRING newRawUTF16 (pANTLR3_STRING_FACTORY factory);
40 static pANTLR3_STRING newSize8 (pANTLR3_STRING_FACTORY factory, ANTLR3_UINT32 size);
41 static pANTLR3_STRING newSizeUTF16 (pANTLR3_STRING_FACTORY factory, ANTLR3_UINT32 size);
42 static pANTLR3_STRING newPtr8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string, ANTLR3_UINT32 size);
43 static pANTLR3_STRING newPtrUTF16_8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string, ANTLR3_UINT32 size);
44 static pANTLR3_STRING newPtrUTF16_UTF16 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string, ANTLR3_UINT32 size);
45 static pANTLR3_STRING newStr8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string);
46 static pANTLR3_STRING newStrUTF16_8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string);
47 static pANTLR3_STRING newStrUTF16_UTF16 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 string);
48 static void destroy (pANTLR3_STRING_FACTORY factory, pANTLR3_STRING string);
49 static pANTLR3_STRING printable8 (pANTLR3_STRING_FACTORY factory, pANTLR3_STRING string);
50 static pANTLR3_STRING printableUTF16 (pANTLR3_STRING_FACTORY factory, pANTLR3_STRING string);
51 static void closeFactory(pANTLR3_STRING_FACTORY factory);
100 pANTLR3_STRING_FACTORY factory;
104 factory = (pANTLR3_STRING_FACTORY) ANTLR3_CALLOC(1, sizeof(ANTLR3_STRING_FACTORY));
106 if (factory == NULL)
113 factory->strings = antlr3VectorNew(0);
114 factory->index = 0;
116 if (factory->strings == NULL)
118 ANTLR3_FREE(factory);
149 factory->newRaw = newRawUTF16;
150 factory->newSize = newSizeUTF16;
151 factory->newPtr = newPtrUTF16_UTF16;
152 factory->newPtr8 = newPtrUTF16_8;
153 factory->newStr = newStrUTF16_UTF16;
154 factory->newStr8 = newStrUTF16_8;
155 factory->printable = printableUTF16;
156 factory->destroy = destroy;
157 factory->close = closeFactory;
165 factory->newRaw = newRaw8;
166 factory->newSize = newSize8;
167 factory->newPtr = newPtr8;
168 factory->newPtr8 = newPtr8;
169 factory->newStr = newStr8;
170 factory->newStr8 = newStr8;
171 factory->printable = printable8;
172 factory->destroy = destroy;
173 factory->close = closeFactory;
176 return factory;
182 * \param factory
186 newRaw8 (pANTLR3_STRING_FACTORY factory)
200 string->factory = factory;
204 factory->strings->set(factory->strings, factory->index, (void *) string, (void (ANTLR3_CDECL *)(void *))(stringFree), ANTLR3_TRUE);
205 string->index = factory->index++;
211 * \param factory
215 newRawUTF16 (pANTLR3_STRING_FACTORY factory)
229 string->factory = factory;
233 factory->strings->set(factory->strings, factory->index, (void *) string, (void (ANTLR3_CDECL *)(void *))(stringFree), ANTLR3_TRUE);
234 string->index = factory->index++;
351 return string->factory->newPtr(string->factory, (pANTLR3_UINT8)(string->chars), string->len);
372 utf8String = string->factory->newStr8(string->factory, (pANTLR3_UINT8)"");
416 * \param[in] factory - Pointer to the string factory that owns strings
421 newSize8 (pANTLR3_STRING_FACTORY factory, ANTLR3_UINT32 size)
425 string = factory->newRaw(factory);
444 * \param[in] factory - Pointer to the string factory that owns strings
449 newSizeUTF16 (pANTLR3_STRING_FACTORY factory, ANTLR3_UINT32 size)
453 string = factory->newRaw(factory);
471 * \param[in] factory - Pointer to the string factory that owns the strings
476 newPtr8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr, ANTLR3_UINT32 size)
480 string = factory->newSize(factory, size);
504 * \param[in] factory - Pointer to the string factory that owns the strings
509 newPtrUTF16_8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr, ANTLR3_UINT32 size)
515 string = factory->newSize(factory, size);
552 * \param[in] factory - Pointer to the string factory that owns the strings
557 newPtrUTF16_UTF16 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr, ANTLR3_UINT32 size)
561 string = factory->newSize(factory, size);
587 * \param[in] factory - Pointer to the string factory that owns strings.
592 newStr8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr)
594 return factory->newPtr8(factory, ptr, (ANTLR3_UINT32)strlen((const char *)ptr));
598 * \param[in] factory - Pointer to the string factory that owns strings.
603 newStrUTF16_8 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr)
605 return factory->newPtr8(factory, ptr, (ANTLR3_UINT32)strlen((const char *)ptr));
609 * \param[in] factory - Pointer to the string factory that owns strings.
614 newStrUTF16_UTF16 (pANTLR3_STRING_FACTORY factory, pANTLR3_UINT8 ptr)
628 return factory->newPtr(factory, ptr, count);
632 destroy (pANTLR3_STRING_FACTORY factory, pANTLR3_STRING string)
638 // Ensure that the string was not factory made, or we would try
639 // to delete memory that wasn't allocated outside the factory
643 factory->strings->del(factory->strings, strIndex);
645 // One less string in the vector, so decrement the factory index
649 factory->index--;
655 if (strIndex< factory->index)
663 for (i = strIndex; i < factory->index; i++)
667 ((pANTLR3_STRING)(factory->strings->elements[i].element))->index = i;
671 // The string has been destroyed and the elements of the factory are reindexed.
677 printable8(pANTLR3_STRING_FACTORY factory, pANTLR3_STRING instr)
688 string = factory->newSize(factory, instr->len *2 + 1);
724 printableUTF16(pANTLR3_STRING_FACTORY factory, pANTLR3_STRING instr)
737 string = factory->newSize(factory, instr->len *2 + 1);
782 closeFactory (pANTLR3_STRING_FACTORY factory)
787 factory->strings->free(factory->strings);
789 /* Delete the space for the factory itself
791 ANTLR3_FREE((void *)factory);
1288 newStr = string->factory->newPtr(string->factory, string->chars + startIndex, endIndex - startIndex);
1305 newStr = string->factory->newPtr(string->factory, (pANTLR3_UINT8)((pANTLR3_UINT16)(string->chars) + startIndex), endIndex - startIndex);
1372 newStr = newRaw8(string->factory);