Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: zeusever/lemon-lib
base: master
...
head fork: zeusever/lemon-lib
compare: ppc
  • 1 commit
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 09, 2012
yayanyang update
Signed-off-by: yayanyang <yayanyang@gmail.com>
299f775
87 ppc/abi.cpp
View
@@ -1,11 +1,82 @@
#include <lemon/ppc/abi.h>
#include <lemon/sys/errorcode.h>
+#include <lemon/ppc/package.hpp>
-//LEMON_PPC_API
-// LemonPPCPackage
-// LemonCreatePPC(
-// __lemon_in const lemon_char_t * assemblyFile,
-// __lemon_inout LemonErrorInfo *errorCode)
-//{
-//
-//}
+LEMON_PPC_API
+ LemonPPCPackage
+ LemonCreatePPC(
+ __lemon_in const lemon_char_t * assemblyFile,
+ __lemon_inout LemonErrorInfo *errorCode)
+{
+ try
+ {
+ return (LemonPPCPackage)new lemon::ppc::core::Package(lemon::to_locale(assemblyFile).c_str());
+ }
+ catch(const lemon::error_info &e)
+ {
+ *errorCode = e;
+
+ return LEMON_HANDLE_NULL_VALUE;
+ }
+}
+
+LEMON_PPC_API
+ void
+ LemonClosePPC(
+ __lemon_in LemonPPCPackage package)
+{
+ delete (lemon::ppc::core::Package*)package;
+}
+
+LEMON_PPC_API
+ void
+ LemonPPCScanFile(
+ __lemon_in LemonPPCPackage package,
+ __lemon_in const lemon_char_t * filePath,
+ __lemon_in const lemon_char_t * targetPath,
+ __lemon_inout LemonErrorInfo *errorCode)
+{
+ try
+ {
+ ((lemon::ppc::core::Package*)package)->Scan(filePath,targetPath);
+ }
+ catch(const lemon::error_info &e)
+ {
+ *errorCode = e;
+ }
+}
+
+LEMON_PPC_API
+ void
+ LemonGeneratePPC(
+ __lemon_in LemonPPCPackage package,
+ __lemon_in const lemon_char_t * targetPath,
+ __lemon_inout LemonErrorInfo *errorCode)
+{
+ try
+ {
+ ((lemon::ppc::core::Package*)package)->Generate(targetPath);
+ }
+ catch(const lemon::error_info &e)
+ {
+ *errorCode = e;
+ }
+}
+
+LEMON_PPC_API
+ const lemon_char_t *
+ LemonPPCPackageName(
+ __lemon_in LemonPPCPackage package,
+ __lemon_inout LemonErrorInfo *errorCode)
+{
+ try
+ {
+ return ((lemon::ppc::core::Package*)package)->GetName().c_str();
+ }
+ catch(const lemon::error_info &e)
+ {
+ *errorCode = e;
+
+ return LEMON_HANDLE_NULL_VALUE;
+ }
+}
12 ppc/abi.h
View
@@ -26,8 +26,6 @@ typedef struct LemonTraceMessage{
size_t DataLength;
- lemon_byte_t Data[1];
-
}LemonTraceMessage;
LEMON_PPC_API
@@ -39,8 +37,7 @@ LEMON_PPC_API
LEMON_PPC_API
void
LemonClosePPC(
- __lemon_in LemonPPCPackage package,
- __lemon_inout LemonErrorInfo *errorCode);
+ __lemon_in LemonPPCPackage package);
LEMON_PPC_API
@@ -54,7 +51,14 @@ LEMON_PPC_API
LEMON_PPC_API
void
LemonGeneratePPC(
+ __lemon_in LemonPPCPackage package,
__lemon_in const lemon_char_t * targetPath,
__lemon_inout LemonErrorInfo *errorCode);
+LEMON_PPC_API
+ const lemon_char_t *
+ LemonPPCPackageName(
+ __lemon_in LemonPPCPackage package,
+ __lemon_inout LemonErrorInfo *errorCode);
+
#endif //LEMON_PPC_ABI_H
12 ppc/codegen.cpp
View
@@ -58,7 +58,7 @@ namespace lemon{namespace ppc{namespace core{
void CXXCodeGen::PackageIdGetFunctionG(std::ostream & stream)
{
- const lemon_byte_t * bytes = (const lemon_byte_t*)&_moduleGuid;
+ const lemon_byte_t * bytes = (const lemon_byte_t*)&_packageId;
char buffer[128] = {0};
@@ -87,8 +87,6 @@ namespace lemon{namespace ppc{namespace core{
{
const Package::Catalog & catalog = _package.GetCatalog();
- size_t counter = 0;
-
for(size_t i = 0 ; i < catalog.size(); ++i)
{
std::string flag = catalog[i].Text;
@@ -97,11 +95,9 @@ namespace lemon{namespace ppc{namespace core{
{
stream << "#ifndef " << flag << std::endl;
- stream << "#define " << flag << "\t" << counter << std::endl;
+ stream << "#define " << flag << "\t" << catalog[i].Value << std::endl;
stream << "#endif //" << flag << "\n" << std::endl;
-
- ++ counter;
}
}
}
@@ -143,7 +139,7 @@ namespace lemon{namespace ppc{namespace core{
stream << ">" << std::endl;
- stream << "\tvoid operator()(TraceLog & log, size_t level, size_t catalog,const char*,";
+ stream << "\tvoid operator()(Tracelog & log, size_t level, size_t catalog,const char*";
for(size_t i = 0; i < args; ++ i)
{
@@ -169,7 +165,7 @@ namespace lemon{namespace ppc{namespace core{
for(size_t i = 0; i < args; ++ i)
{
- stream << "\t\tlength = lemon::ppc::type_trait<A" << i << ">::write(message,length,a" << i << ")" << std::endl << std::endl;
+ stream << "\t\tlength = lemon::ppc::type_trait<A" << i << ">::write(message,length,a" << i << ");" << std::endl << std::endl;
}
stream << "\t\tlog.trace(message);" << std::endl << std::endl;
20 ppc/package.cpp
View
@@ -28,7 +28,7 @@ namespace lemon{namespace ppc{namespace core{
{
CXXCodeGen gen(*this,_asts.size());
- std::ofstream stream(lemon::to_locale(source).c_str(),std::ios::trunc);
+ std::ofstream stream(lemon::to_locale(object).c_str(),std::ios::trunc);
if(!stream.is_open())
{
@@ -62,6 +62,7 @@ namespace lemon{namespace ppc{namespace core{
.def("name",&Package::Name)
.def("errorinfo",&Package::PushErrorInfo)
.def("tracelog",&Package::SetTraceLogMacroName)
+ .def("catalog",&Package::PushCatalogItem)
;
std::stringstream stream;
@@ -74,7 +75,7 @@ namespace lemon{namespace ppc{namespace core{
stream << "\tpkg:name(assembly.name)" << std::endl;
- stream << "\tpkg:tracelog(assembly.tracelog)" << std::endl;
+ stream << "\tpkg:tracelog(assembly.tracelog.macro)" << std::endl;
stream << "\t for i,v in ipairs(assembly.errorcode) do " << std::endl;
@@ -82,6 +83,12 @@ namespace lemon{namespace ppc{namespace core{
stream << "end" <<std::endl;
+ stream << "\t for i,v in ipairs(assembly.tracelog.catalog) do " << std::endl;
+
+ stream << "\t\tif v.description ~= nil then pkg:catalog(v.name,v.description,i) else pkg:catalog(v.name,\"\",i) end" << std::endl;
+
+ stream << "end" <<std::endl;
+
stream << "end" << std::endl;
luabind::dostring(L,stream.str().c_str());
@@ -137,6 +144,13 @@ namespace lemon{namespace ppc{namespace core{
void Package::Name(const char *name)
{
- _name = name;
+ _name = lemon::from_utf8(name);
+ }
+
+ void Package::PushCatalogItem(const char * name,const char * description,size_t id)
+ {
+ CatalogItem item = {name,description,id};
+
+ _catalog.push_back(item);
}
}}}
10 ppc/package.hpp
View
@@ -21,6 +21,8 @@ namespace lemon{namespace ppc{namespace core{
{
std::string Text;
+ std::string Description;
+
size_t Value;
};
@@ -53,9 +55,9 @@ namespace lemon{namespace ppc{namespace core{
const lemon::uuid_t &Guid() const { return _guid; }
- const std::string TraceLogMacroName() const { return _traceLogMacroName; }
+ const std::string& TraceLogMacroName() const { return _traceLogMacroName; }
- const std::string GetName() const { return _name ; }
+ const lemon::String& GetName() const { return _name ; }
private:
@@ -69,6 +71,8 @@ namespace lemon{namespace ppc{namespace core{
void SetTraceLogMacroName(const std::string & val) { _traceLogMacroName = val; }
+ void PushCatalogItem(const char * name,const char * description,size_t id);
+
private:
ASTs _asts;
@@ -81,7 +85,7 @@ namespace lemon{namespace ppc{namespace core{
std::string _traceLogMacroName;
- std::string _name;
+ lemon::String _name;
};
}}}
7 sys/filesystem.cpp
View
@@ -145,6 +145,13 @@ LEMON_SYS_API
DWORD attributes = GetFileAttributesW(directory);
+ if(INVALID_FILE_ATTRIBUTES == attributes)
+ {
+ LEMON_WIN32_ERROR(*errorCode,GetLastError());
+
+ return lemon_false;
+ }
+
return ((FILE_ATTRIBUTE_DIRECTORY & attributes) == FILE_ATTRIBUTE_DIRECTORY)?lemon_true:lemon_false;
}

No commit comments for this range

Something went wrong with that request. Please try again.