source: trunk/src/tools/moc/mwerks_mac.cpp@ 603

Last change on this file since 603 was 561, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.1 sources.

File size: 7.6 KB
RevLine 
[2]1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the tools applications of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
[561]24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
[2]27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
[561]36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
[2]38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifdef MOC_MWERKS_PLUGIN
43
44#include "mwerks_mac.h"
45#include "qt_mac.h"
46
47/* compiler headers */
48#include "DropInCompilerLinker.h"
49#include "CompilerMapping.h"
50#include "CWPluginErrors.h"
51
52/* standard headers */
53#include <stdio.h>
54#include <string.h>
55
56QT_BEGIN_NAMESPACE
57
58//qglobal.cpp
59const unsigned char * p_str(const char * c);
60QCString pstring2qstring(const unsigned char *c);
61
62#if CW_USE_PRAGMA_EXPORT
63#pragma export on
64#endif
65
66CWPLUGIN_ENTRY(CWPlugin_GetDropInFlags)(const DropInFlags** flags, long* flagsSize)
67{
68 static const DropInFlags sFlags = {
69 kCurrentDropInFlagsVersion,
70 CWDROPINCOMPILERTYPE,
71 DROPINCOMPILERLINKERAPIVERSION_7,
72 kCompAlwaysReload|kCompRequiresProjectBuildStartedMsg,
73 Lang_C_CPP,
74 DROPINCOMPILERLINKERAPIVERSION
75 };
76 *flags = &sFlags;
77 *flagsSize = sizeof(sFlags);
78 return cwNoErr;
79}
80
81
82
83CWPLUGIN_ENTRY(CWPlugin_GetDropInName)(const char** dropinName)
84{
85 static const char sDropInName[] = "McMoc";
86 *dropinName = sDropInName;
87 return cwNoErr;
88}
89
90CWPLUGIN_ENTRY(CWPlugin_GetDisplayName)(const char** displayName)
91{
92 static const char sDisplayName[] = "McMoc";
93 *displayName = sDisplayName;
94 return cwNoErr;
95}
96
97CWPLUGIN_ENTRY(CWPlugin_GetTargetList)(const CWTargetList** targetList)
98{
99 static CWDataType sCPU = targetCPUAny;
100 static CWDataType sOS = targetOSMacintosh;
101 static CWTargetList sTargetList = {kCurrentCWTargetListVersion, 1, &sCPU, 1, &sOS};
102 *targetList = &sTargetList;
103 return cwNoErr;
104}
105
106CWPLUGIN_ENTRY(CWPlugin_GetDefaultMappingList)(const CWExtMapList** defaultMappingList)
107{
108 static CWExtensionMapping sExtension[] = { {'TEXT', ".mocs", kPrecompile } };
109 static CWExtMapList sExtensionMapList = {kCurrentCWExtMapListVersion, 3, sExtension};
110 *defaultMappingList = &sExtensionMapList;
111 return cwNoErr;
112}
113
114#if CW_USE_PRAGMA_EXPORT
115#pragma export off
116#endif
117typedef short CWFileRef;
118
119static int line_count = 0;
120moc_status do_moc(CWPluginContext, const QCString &, const QCString &, CWFileSpec *, bool);
121
122static CWResult mocify(CWPluginContext context, const QCString &source)
123{
124 CWDisplayLines(context, line_count++);
125
126 source.stripWhiteSpace();
127
128 CWResult err;
129 bool dotmoc=false;
130 QCString stem = source, ext;
131 int dotpos = stem.findRev('.');
132 if(dotpos != -1) {
133 ext = stem.right(stem.length() - (dotpos+1));
134 stem = stem.left(dotpos);