Example #1
0
static void
WriteProlog(FILE *file, const char *protect, boolean_t more, boolean_t isuser)
{
	if (protect != strNULL) {
		fprintf(file, "#ifndef\t_%s\n", protect);
		fprintf(file, "#define\t_%s\n", protect);
		fprintf(file, "\n");
	}

	fprintf(file, "/* Module %s */\n", SubsystemName);
	fprintf(file, "\n");

	if (more) {
		WriteIncludes(file, isuser, UseSplitHeaders);
	}
	fprintf(file, "#ifdef AUTOTEST\n");
	fprintf(file, "#ifndef FUNCTION_PTR_T\n");
	fprintf(file, "#define FUNCTION_PTR_T\n");
	fprintf(file, "typedef void (*function_ptr_t)");
	fprintf(file, "(mach_port_t, char *, mach_msg_type_number_t);\n");
	fprintf(file, "typedef struct {\n");
	fprintf(file, "        char            *name;\n");
	fprintf(file, "        function_ptr_t  function;\n");
	fprintf(file, "} function_table_entry;\n");
	fprintf(file, "typedef function_table_entry   *function_table_t;\n");
	fprintf(file, "#endif /* FUNCTION_PTR_T */\n");
	fprintf(file, "#endif /* AUTOTEST */\n");
	fprintf(file, "\n#ifndef\t%s_MSG_COUNT\n", SubsystemName);
	fprintf(file, "#define\t%s_MSG_COUNT\t%d\n", SubsystemName, rtNumber);
	fprintf(file, "#endif\t/* %s_MSG_COUNT */\n\n", SubsystemName);
}
Example #2
0
File: header.c Project: Prajna/mach
static void
WriteProlog(FILE *file, const char *protect)
{
    if (protect != strNULL) {
	fprintf(file, "#ifndef\t_%s\n", protect);
	fprintf(file, "#define\t_%s\n", protect);
	fprintf(file, "\n");
    }

    fprintf(file, "/* Module %s */\n", SubsystemName);
    fprintf(file, "\n");

    WriteIncludes(file);
    WriteDefines(file);
}
Example #3
0
int main(int argc, char **argv) 
{
  extern FILE *yyin;
  extern int yylex();

  FILE *cfp = NULL;
  int bmsg = 0;
  char *branch = NULL;
  int inFile;
  int outFile;
  
  if (argc < 3) 
      usage();
    
  if (argv[1][0] == '-') {
    if (argv[1][1] == 'b') {
      branch = argv[2];
      bmsg = 1;
    }
    else 
      usage();
    if (argc != 5)
      usage(); 
  } else if (argc != 3)
    usage();

  inFile = bmsg ? 3 : 1; 
  outFile = inFile + 1;

  if (!(yyin = fopen(argv[inFile], "r"))) {
      printf("Can't open input file: %s", argv[inFile]);
      exit(1);
  }

  LstIni(&lFacH);
  SyntaxError = 0;
  lineno = 1;    
  
  yylex();

  if (!SyntaxError) {
    if (!(cfp = fopen(argv[outFile], "w+"))) {
	printf("Can't open output file: %s", argv[outFile]);
	exit(1);
    }  

    rewind(yyin);
    WriteIncludes(cfp);
    CopyFile(yyin, cfp);
    WriteFacility(cfp, branch);
  }

  fclose(yyin);
  fclose(cfp);

#if defined OS_VMS || defined OS_ELN
  exit(1);
#elif defined OS_POSIX
  exit(EXIT_SUCCESS);
#endif
}
void CSModuleWriter::GenerateNativeSource()
{
    String source = "// This file was autogenerated by JSBind, changes will be lost\n";

    source += "#ifdef ATOMIC_PLATFORM_WINDOWS\n";

    source += "#pragma warning(disable: 4244) // possible loss of data\n";

    source += "#define ATOMIC_EXPORT_API __declspec(dllexport)\n";

    source += "#else\n";

    source += "#define ATOMIC_EXPORT_API\n";

    source += "#endif\n";

    if (module_->Requires("3D"))
    {
        source += "#ifdef ATOMIC_3D\n";
    }

    WriteIncludes(source);

    source += "\n#include <AtomicNET/NETCore/NETCore.h>\n";

    String ns = module_->GetPackage()->GetNamespace();

    source += "\n\nusing namespace " + ns + ";\n\n";

    source += "\n\nextern \"C\" \n{\n \n";

    source += "// Begin Class Declarations\n";

    source += "// End Class Declarations\n\n";

    source += "// Begin Classes\n";

    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        CSClassWriter clsWriter(classes[i]);
        clsWriter.GenerateNativeSource(source);
    }

    source += "// End Classes\n\n";

    // end Atomic namespace
    source += "\n}\n";

    if (module_->Requires("3D"))
    {
        source += "#endif //ATOMIC_3D\n";
    }

    JSBind* jsbind = module_->GetSubsystem<JSBind>();

    String filepath = jsbind->GetDestNativeFolder() + "/CSModule" + module_->name_ + ".cpp";

    File file(module_->GetContext());
    file.Open(filepath, FILE_WRITE);
    file.Write(source.CString(), source.Length());
    file.Close();

}
Example #5
0
void JSBModule::EmitSource(const String& filepath)
{
    File file(JSBind::context_);
    file.Open(filepath, FILE_WRITE);

    source_ = "// This file was autogenerated by JSBind, changes will be lost\n";

    if (Requires("3D"))
    {
        source_ += "#ifdef ATOMIC_3D\n";
    }

    source_ += "#include <Duktape/duktape.h>\n";    
    source_ += "#include <AtomicJS/Javascript/JSVM.h>\n";
    source_ += "#include <AtomicJS/Javascript/JSAPI.h>\n";

    WriteIncludes(source_);

    source_ += "\n\nnamespace Atomic\n{\n \n";

    source_ += "// Begin Class Declarations\n";

    for (unsigned i = 0; i < classes_.Size(); i++)
    {
        classes_[i]->WriteForwardDeclarations(source_);
    }

    source_ += "// End Class Declarations\n\n";

    source_ += "// Begin Classes\n";

    for (unsigned i = 0; i < classes_.Size(); i++)
    {
        classes_[i]->Write(source_);
    }

    source_ += "// End Classes\n\n";


    WriteClassDeclaration(source_);

    WriteClassDefine(source_);

    WriteModulePreInit(source_);

    WriteModuleInit(source_);

    // end Atomic namespace
    source_ += "\n}\n";

    if (Requires("3D"))
    {
        source_ += "#endif //ATOMIC_3D\n";
    }


    file.Write(source_.CString(), source_.Length());

    file.Close();

}
void JSBModuleWriter::GenerateSource(String& sourceOut)
{
    source_ = "// This file was autogenerated by JSBind, changes will be lost\n";

    source_ += "#ifdef ATOMIC_PLATFORM_WINDOWS\n";

    source_ += "#pragma warning(disable: 4244) // possible loss of data\n";

    source_ += "#endif\n";

    if (module_->Requires("3D"))
    {
        source_ += "#ifdef ATOMIC_3D\n";
    }

    source_ += "#include <Duktape/duktape.h>\n";
    source_ += "#include <AtomicJS/Javascript/JSVM.h>\n";
    source_ += "#include <AtomicJS/Javascript/JSAPI.h>\n";

    WriteIncludes(source_);

    String ns = module_->GetPackage()->GetNamespace();

    if (ns != "Atomic")
    {
        source_ += "\n\nusing namespace " + ns + ";\n\n";
    }

    source_ += "\n\nnamespace Atomic\n{\n \n";

    source_ += "// Begin Class Declarations\n";

    WriteForwardDeclarations(source_);

    source_ += "// End Class Declarations\n\n";

    source_ += "// Begin Classes\n";

    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSBClassWriter clsWriter(classes[i]);
        clsWriter.GenerateSource(source_);
    }

    source_ += "// End Classes\n\n";

    WriteClassDeclaration(source_);

    WriteClassDefine(source_);

    WriteModulePreInit(source_);

    WriteModuleInit(source_);

    // end Atomic namespace
    source_ += "\n}\n";

    if (module_->Requires("3D"))
    {
        source_ += "#endif //ATOMIC_3D\n";
    }

    sourceOut = source_;
}
void JSModuleWriter::GenerateSource()
{
    String source = "// This file was autogenerated by JSBind, changes will be lost\n";

    source += "#ifdef ATOMIC_PLATFORM_WINDOWS\n";

    source += "#pragma warning(disable: 4244) // possible loss of data\n";

    source += "#endif\n";

    if (module_->Requires("3D"))
    {
        source += "#ifdef ATOMIC_3D\n";
    }

    source += "#include <Duktape/duktape.h>\n";
    source += "#include <AtomicJS/Javascript/JSVM.h>\n";
    source += "#include <AtomicJS/Javascript/JSAPI.h>\n";

    WriteIncludes(source);

    String ns = module_->GetPackage()->GetNamespace();

    if (ns != "Atomic")
    {
        source += "\n\nusing namespace " + ns + ";\n\n";
    }

    source += "\n\nnamespace Atomic\n{\n \n";

    source += "// Begin Class Declarations\n";

    WriteForwardDeclarations(source);

    source += "// End Class Declarations\n\n";

    source += "// Begin Classes\n";

    Vector<SharedPtr<JSBClass>> classes = module_->classes_.Values();

    for (unsigned i = 0; i < classes.Size(); i++)
    {
        JSClassWriter clsWriter(classes[i]);
        clsWriter.GenerateSource(source);
    }

    source += "// End Classes\n\n";

    WriteClassDeclaration(source);

    WriteClassDefine(source);

    WriteModulePreInit(source);

    WriteModuleInit(source);

    // end Atomic namespace
    source += "\n}\n";

    if (module_->Requires("3D"))
    {
        source += "#endif //ATOMIC_3D\n";
    }

    JSBind* jsbind = module_->GetSubsystem<JSBind>();

    String filepath = jsbind->GetDestNativeFolder() + "/JSModule" + module_->name_ + ".cpp";

    File file(module_->GetContext());
    file.Open(filepath, FILE_WRITE);
    file.Write(source.CString(), source.Length());
    file.Close();

}