Skip to content

Commit

Permalink
Changed C++ generator from csharp_ prefix to api_.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomspilman committed Sep 10, 2024
1 parent dce38c5 commit 95ab28e
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 85 deletions.
10 changes: 6 additions & 4 deletions Tools/MonoGame.Generator.CTypes/EnumWritter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ class EnumWritter
public EnumWritter()
{
_outputText = new StringBuilder($"""
//
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//
#pragma once
#include "csharp_common.h"
#include "api_common.h"
""");
Expand Down Expand Up @@ -105,7 +107,7 @@ public void Flush(string dirPath)
foreach (var pair in _types)
Generate(pair.Value);

var path = Path.Combine(dirPath, "csharp_enums.h");
var path = Path.Combine(dirPath, "api_enums.h");
var text = _outputText.ToString().ReplaceLineEndings();

File.WriteAllText(path, text);
Expand Down
10 changes: 4 additions & 6 deletions Tools/MonoGame.Generator.CTypes/PInvokeWritter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ public PinvokeWritter(Type type, StructWritter structWritter, EnumWritter enumWr
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//
#pragma once
#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"
Expand Down Expand Up @@ -136,7 +134,7 @@ public void Flush(string dirPath)
foreach (var method in _methods)
GenerateMethod(method);

var path = Path.Combine(dirPath, $"csharp_{_name}.h");
var path = Path.Combine(dirPath, $"api_{_name}.h");
var text = _outputText.ToString().ReplaceLineEndings();

File.WriteAllText(path, text);
Expand Down
2 changes: 1 addition & 1 deletion Tools/MonoGame.Generator.CTypes/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using MonoGame.Generator.CTypes;

var repoDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../../../");
var monogamePlatformDir = Path.Combine(repoDirectory, "src/monogame/include");
var monogamePlatformDir = Path.Combine(repoDirectory, "native/monogame/include");
var monogameFrameworkPath = Path.Combine(repoDirectory, "Artifacts/MonoGame.Framework/Native/Debug/MonoGame.Framework.dll");
var assembly = Assembly.LoadFile(monogameFrameworkPath);
var enumWritter = new EnumWritter();
Expand Down
10 changes: 6 additions & 4 deletions Tools/MonoGame.Generator.CTypes/StructWritter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public StructWritter(EnumWritter enumWritter)
_enumWritter = enumWritter;

_outputText = new StringBuilder($"""
//
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//
#pragma once
#include "csharp_common.h"
#include "api_common.h"
""");
Expand Down Expand Up @@ -135,7 +137,7 @@ public void Flush(string dirPath)
foreach (var pair in _types)
Generate(pair.Value);

var path = Path.Combine(dirPath, "csharp_structs.h");
var path = Path.Combine(dirPath, "api_structs.h");
var text = _outputText.ToString().ReplaceLineEndings();

File.WriteAllText(path, text);
Expand Down
2 changes: 1 addition & 1 deletion native/monogame/common/MGI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

#include "csharp_MGI.h"
#include "api_MGI.h"

#define STBI_NO_PSD
#define STBI_NO_BMP
Expand Down
4 changes: 2 additions & 2 deletions native/monogame/common/MGM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

struct MGG_Texture;

#include "csharp_MGM.h"
#include "api_MGM.h"

#include "stl_common.h"
#include "mg_common.h"


struct MGM_Song
Expand Down
4 changes: 2 additions & 2 deletions native/monogame/faudio/MGA_faudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

#include "csharp_MGA.h"
#include "api_MGA.h"

#include "stl_common.h"
#include "mg_common.h"


// TODO: Implement against the C++ API for FAudio.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"


struct MGA_System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"


struct MGG_GraphicsSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"


struct MGM_Song;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

//
// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "csharp_enums.h"
#include "csharp_structs.h"
#include "api_common.h"
#include "api_enums.h"
#include "api_structs.h"


struct MGP_Platform;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "api_common.h"

enum class MGSoundState : mgint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

// This code is auto generated, don't modify it by hand.
// To regenerate it run: Tools/MonoGame.Generator.CTypes
//

#pragma once

#include "csharp_common.h"
#include "api_common.h"

struct ReverbSettings
{
Expand Down
21 changes: 20 additions & 1 deletion native/monogame/include/mg_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#pragma once

#include <stdio.h>
#include <assert.h>

#include <vector>
#include <string>
#include <queue>
#include <map>
#include <functional>


#ifdef _MSC_VER
Expand Down Expand Up @@ -36,8 +43,20 @@ inline void MG_Print_StdOut(const char* file, int line, const char* message)
#define MG_NOT_IMPLEMEMTED MG_ERROR_PRINT("NOT IMPLEMENTED!"); MG_GENERATE_TRAP()


template <class T>
void mg_remove(std::vector<T>& vector, const T& element)
{
auto new_end = std::remove(vector.begin(), vector.end(), element);
assert(new_end != vector.end());
vector.erase(new_end, vector.end());
}


template <class T>
bool mg_contains(std::vector<T>& vector, const T& element)
{
auto found = std::find(vector.begin(), vector.end(), element);
return found != vector.end();
}



29 changes: 0 additions & 29 deletions native/monogame/include/stl_common.h

This file was deleted.

4 changes: 2 additions & 2 deletions native/monogame/sdl/MGP_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

#include "csharp_MGP.h"
#include "api_MGP.h"

#include "stl_common.h"
#include "mg_common.h"

#include <sdl.h>

Expand Down
3 changes: 1 addition & 2 deletions native/monogame/vulkan/MGG_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.

#include "csharp_MGG.h"
#include "api_MGG.h"

#include "stl_common.h"
#include "mg_common.h"


Expand Down

0 comments on commit 95ab28e

Please sign in to comment.